/* assets/css/main.css
   ───────────────────────────────────────────────────
   Aesthetic: "Sacred Night"
   Dark navy canvas · Gold accents · Geometric pattern
   Fonts: Lateef (Arabic feel) + DM Sans (body)
   ─────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Lateef:wght@400;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* ── Tokens ───────────────────────────────────────── */
:root {
  --bg-base    : #0c1220;
  --bg-card    : #131c2e;
  --bg-card2   : #192035;
  --bg-input   : #1e2840;
  --border     : rgba(167,143,72,.18);
  --border-glow: rgba(212,175,89,.35);
  --gold       : #d4af57;
  --gold-light : #f0d080;
  --gold-dim   : #a07835;
  --teal       : #2dd4bf;
  --text-hi    : #f0e8d0;
  --text-mid   : #9fa8ba;
  --text-lo    : #4e576a;
  --done-bg    : rgba(45,212,191,.07);
  --done-text  : #2dd4bf;
  --radius     : 14px;
  --radius-sm  : 8px;
  --shadow     : 0 8px 32px rgba(0,0,0,.55);
  --font-display: 'Lateef', serif;
  --font-body   : 'DM Sans', sans-serif;
}

/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family   : var(--font-body);
  background    : var(--bg-base);
  color         : var(--text-hi);
  min-height    : 100vh;
  line-height   : 1.6;
  overflow-x    : hidden;
  /* Subtle star-field background */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(45,212,191,.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(212,175,89,.05) 0%, transparent 60%);
}

/* Geometric star-pattern overlay */
body::before {
  content : '';
  position: fixed;
  inset   : 0;
  pointer-events: none;
  opacity : .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 5l4 11h12l-10 7 4 11-10-7-10 7 4-11-10-7h12z' fill='%23d4af57' stroke='none'/%3E%3C/svg%3E");
  background-size: 60px 60px;
}

/* ── Layout ───────────────────────────────────────── */
.app-wrapper {
  max-width : 860px;
  margin    : 0 auto;
  padding   : 24px 16px 64px;
}

/* ── Header ───────────────────────────────────────── */
.app-header {
  text-align: center;
  padding   : 48px 0 36px;
  position  : relative;
}

.app-header .crescent { font-size: 56px; line-height: 1; display: block; margin-bottom: 8px; }

.app-header h1 {
  font-family : var(--font-display);
  font-size   : clamp(2rem, 5vw, 3.2rem);
  font-weight : 700;
  color       : var(--gold-light);
  letter-spacing: .03em;
  text-shadow : 0 0 40px rgba(212,175,89,.4);
}

.app-header .subtitle {
  font-size  : .9rem;
  color      : var(--text-mid);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top : 4px;
}

/* Gold divider */
.gold-divider {
  width     : 120px;
  height    : 2px;
  margin    : 18px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ── Card component ───────────────────────────────── */
.card {
  background   : var(--bg-card);
  border       : 1px solid var(--border);
  border-radius: var(--radius);
  padding      : 24px;
  margin-bottom: 20px;
  box-shadow   : var(--shadow);
  transition   : border-color .3s;
}
.card:hover { border-color: var(--border-glow); }

.card-title {
  font-size     : .72rem;
  font-weight   : 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color         : var(--gold-dim);
  margin-bottom : 18px;
  display       : flex;
  align-items   : center;
  gap           : 8px;
}
.card-title::after {
  content   : '';
  flex      : 1;
  height    : 1px;
  background: var(--border);
}

/* ── Progress section ─────────────────────────────── */
.progress-header {
  display        : flex;
  justify-content: space-between;
  align-items    : center;
  margin-bottom  : 14px;
  flex-wrap      : wrap;
  gap            : 8px;
}

.progress-percent {
  font-family: var(--font-display);
  font-size  : 2.8rem;
  font-weight: 700;
  color      : var(--gold-light);
  line-height: 1;
}

.progress-info { text-align: right; }

.progress-label {
  font-size  : .95rem;
  color      : var(--teal);
  font-weight: 500;
}

.progress-stats {
  font-size: .8rem;
  color    : var(--text-mid);
  margin-top: 2px;
}
.progress-stats span { color: var(--text-hi); font-weight: 600; }

/* Progress bar track */
.progress-track {
  height       : 10px;
  background   : var(--bg-input);
  border-radius: 999px;
  overflow     : hidden;
  border       : 1px solid var(--border);
}

.progress-fill {
  height       : 100%;
  width        : 0%;
  border-radius: 999px;
  transition   : width .5s cubic-bezier(.4,0,.2,1), background .4s;
}

.progress-fill.bar-low  { background: linear-gradient(90deg, #4e576a, #64748b); }
.progress-fill.bar-mid  { background: linear-gradient(90deg, #0e7490, #06b6d4); }
.progress-fill.bar-high { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.progress-fill.bar-full { background: linear-gradient(90deg, var(--gold-dim), var(--gold), var(--gold-light)); box-shadow: 0 0 12px rgba(212,175,89,.5); }

/* ── Day navigation ───────────────────────────────── */
.day-nav {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  gap            : 12px;
  margin-bottom  : 18px;
}

#current-day-label {
  font-family: var(--font-display);
  font-size  : 1.5rem;
  font-weight: 600;
  color      : var(--gold-light);
}

.btn-nav {
  background  : var(--bg-input);
  border      : 1px solid var(--border);
  border-radius: var(--radius-sm);
  color       : var(--text-hi);
  padding     : 7px 14px;
  cursor      : pointer;
  font-size   : .85rem;
  font-family : var(--font-body);
  transition  : background .2s, border-color .2s, transform .15s;
}
.btn-nav:hover:not(:disabled) {
  background  : var(--bg-card2);
  border-color: var(--gold-dim);
  transform   : translateY(-1px);
}
.btn-nav:disabled { opacity: .35; cursor: default; }

/* ── History grid ─────────────────────────────────── */
.history-grid {
  display              : grid;
  grid-template-columns: repeat(10, 1fr);
  gap                  : 5px;
}

@media (max-width: 520px) {
  .history-grid { grid-template-columns: repeat(6, 1fr); }
}

.history-cell {
  aspect-ratio : 1;
  background   : var(--bg-input);
  border       : 1px solid var(--border);
  border-radius: 6px;
  cursor       : pointer;
  position     : relative;
  overflow     : hidden;
  transition   : border-color .2s, transform .15s;
  display      : flex;
  flex-direction: column;
  align-items  : center;
  justify-content: flex-end;
}

.history-cell:hover {
  border-color: var(--gold-dim);
  transform   : translateY(-2px);
}

.history-cell.is-active {
  border-color: var(--gold);
  box-shadow  : 0 0 10px rgba(212,175,89,.35);
}

.history-cell .day-num {
  font-size : .6rem;
  color     : var(--text-lo);
  position  : absolute;
  top       : 4px;
  left      : 0;
  right     : 0;
  text-align: center;
  z-index   : 1;
}

.history-cell.is-active .day-num { color: var(--gold); }

.cell-bar {
  width     : 100%;
  background: linear-gradient(to top, var(--teal), rgba(45,212,191,.3));
  min-height: 2px;
  transition: height .4s ease;
}

/* ── Checklist ────────────────────────────────────── */
#activity-list {
  list-style: none;
  display   : flex;
  flex-direction: column;
  gap       : 8px;
}

.activity-item {
  background   : var(--bg-card2);
  border       : 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding      : 12px 14px;
  transition   : background .25s, border-color .25s, opacity .25s;
  opacity      : 0;
}

/* entrance animation */
.activity-item.item-enter { animation: slideIn .35s forwards ease-out; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.activity-item.is-done {
  background  : var(--done-bg);
  border-color: rgba(45,212,191,.2);
}

.activity-view {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  gap            : 8px;
}

.activity-label {
  display    : flex;
  align-items: center;
  gap        : 10px;
  cursor     : pointer;
  flex       : 1;
  min-width  : 0;
}

/* Hidden native checkbox */
.activity-label input[type="checkbox"] { display: none; }

/* Custom checkmark */
.checkmark {
  width        : 20px;
  height       : 20px;
  border       : 2px solid var(--border-glow);
  border-radius: 6px;
  flex-shrink  : 0;
  position     : relative;
  transition   : background .2s, border-color .2s;
}

.activity-item.is-done .checkmark {
  background  : var(--teal);
  border-color: var(--teal);
}
.activity-item.is-done .checkmark::after {
  content   : '';
  position  : absolute;
  top: 3px; left: 6px;
  width: 5px; height: 9px;
  border: 2px solid #0c1220;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.activity-icon { font-size: 1.1rem; }

.activity-name {
  font-size  : .9rem;
  font-weight: 500;
  color      : var(--text-hi);
  overflow   : hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item.is-done .activity-name {
  color          : var(--done-text);
  text-decoration: line-through;
  text-decoration-color: rgba(45,212,191,.4);
}

.activity-actions { display: flex; gap: 4px; flex-shrink: 0; }

.icon-btn {
  background   : transparent;
  border       : 1px solid transparent;
  border-radius: 6px;
  cursor       : pointer;
  padding      : 4px 7px;
  font-size    : .85rem;
  transition   : background .2s, border-color .2s;
}
.icon-btn:hover {
  background  : var(--bg-input);
  border-color: var(--border);
}

/* Inline edit */
.activity-edit {
  display    : flex;
  align-items: center;
  gap        : 8px;
  flex-wrap  : wrap;
}

.edit-icon-input {
  width       : 44px;
  text-align  : center;
  font-size   : 1.1rem;
  padding     : 6px 4px;
}

.edit-name-input { flex: 1; min-width: 120px; }

/* ── Add activity form ────────────────────────────── */
.add-form {
  display  : flex;
  gap      : 8px;
  flex-wrap: wrap;
}

.add-form input, .edit-icon-input, .edit-name-input {
  background   : var(--bg-input);
  border       : 1px solid var(--border);
  border-radius: var(--radius-sm);
  color        : var(--text-hi);
  font-family  : var(--font-body);
  font-size    : .88rem;
  padding      : 9px 12px;
  outline      : none;
  transition   : border-color .2s;
}

.add-form input:focus,
.edit-icon-input:focus,
.edit-name-input:focus { border-color: var(--gold-dim); }

#new-activity-name { flex: 1; min-width: 160px; }
#new-activity-icon { width: 60px; text-align: center; font-size: 1.1rem; }

/* Input shake animation */
.input-shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0);   }
  20%      { transform: translateX(-6px);}
  40%      { transform: translateX( 6px);}
  60%      { transform: translateX(-4px);}
  80%      { transform: translateX( 4px);}
}

/* ── Buttons ──────────────────────────────────────── */
.btn-primary, .btn-save-edit {
  background   : linear-gradient(135deg, var(--gold-dim), var(--gold));
  border       : none;
  border-radius: var(--radius-sm);
  color        : #0c1220;
  cursor       : pointer;
  font-family  : var(--font-body);
  font-size    : .88rem;
  font-weight  : 600;
  padding      : 9px 18px;
  transition   : transform .15s, box-shadow .2s;
  white-space  : nowrap;
}
.btn-primary:hover, .btn-save-edit:hover {
  transform : translateY(-1px);
  box-shadow: 0 4px 16px rgba(212,175,89,.35);
}

.btn-ghost, .btn-cancel-edit {
  background   : transparent;
  border       : 1px solid var(--border);
  border-radius: var(--radius-sm);
  color        : var(--text-mid);
  cursor       : pointer;
  font-family  : var(--font-body);
  font-size    : .85rem;
  padding      : 8px 14px;
  transition   : background .2s, color .2s;
}
.btn-ghost:hover, .btn-cancel-edit:hover {
  background: var(--bg-input);
  color     : var(--text-hi);
}

/* ── Empty state ──────────────────────────────────── */
#empty-state {
  text-align: center;
  padding   : 40px 0;
  color     : var(--text-lo);
  font-size : .9rem;
}
#empty-state .empty-icon { font-size: 2rem; margin-bottom: 8px; }

/* ── Footer ───────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding   : 32px 0 0;
  color     : var(--text-lo);
  font-size : .75rem;
  letter-spacing: .06em;
}

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 600px) {
  .app-header h1 { font-size: 2rem; }
  .card { padding: 18px 14px; }
}
