/* ============================================================
   PRISM — Components
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 26px; border-radius: var(--radius-pill); border: none;
  font-weight: 600; font-size: 0.95rem; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out-soft), box-shadow var(--dur-fast), background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  will-change: transform;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(108,92,231,0.34); }
.btn-secondary {
  background: var(--surface); color: var(--text-primary); border: 1.5px solid var(--border-hairline-strong);
}
.btn-secondary:hover { border-color: var(--prism-indigo); color: var(--prism-indigo-dark); transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 10px 16px; }
.btn-ghost:hover { color: var(--prism-indigo-dark); background: var(--bg-alt); }
.btn-on-dark { background: rgba(255,255,255,0.1); color: #fff; border: 1.5px solid rgba(255,255,255,0.25); backdrop-filter: blur(6px); }
.btn-on-dark:hover { background: rgba(255,255,255,0.18); transform: translateY(-2px); }
.btn-sm { padding: 9px 18px; font-size: 0.85rem; }
.btn-lg { padding: 17px 34px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-sm); transition: transform var(--dur-med) var(--ease-out-soft), box-shadow var(--dur-med);
}
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-pad { padding: 28px; }
.card-pad-sm { padding: 18px; }
.card-dark { background: var(--gradient-cosmic); color: var(--text-on-dark); border: 1px solid rgba(255,255,255,0.08); }
.card-glass {
  background: var(--surface-glass); backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.5); box-shadow: var(--shadow-md);
}

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill);
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
  background: var(--bg-alt); color: var(--prism-indigo-dark);
}
.badge-success { background: rgba(34,197,94,0.12); color: #15803D; }
.badge-warning { background: rgba(245,158,11,0.14); color: #B45309; }
.badge-pink { background: rgba(244,114,182,0.14); color: #BE185D; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1.5px solid var(--border-hairline-strong); color: var(--text-secondary);
  font-weight: 600; font-size: 0.9rem; transition: all var(--dur-fast) var(--ease-out-soft);
}
.chip:hover { border-color: var(--prism-violet); color: var(--prism-indigo-dark); transform: translateY(-1px); }
.chip.is-selected { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }

/* Mood / emoji selector */
.mood-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 640px) { .mood-grid { grid-template-columns: repeat(3, 1fr); } }
.mood-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 8px;
  border-radius: var(--radius-md); border: 1.5px solid var(--border-hairline-strong); background: var(--surface);
  transition: all var(--dur-fast) var(--ease-out-soft); font-weight: 600; font-size: 0.85rem; color: var(--text-secondary);
}
.mood-btn .mood-emoji { font-size: 1.7rem; transition: transform var(--dur-fast) var(--ease-out-soft); }
.mood-btn:hover { border-color: var(--prism-violet); transform: translateY(-3px); }
.mood-btn:hover .mood-emoji { transform: scale(1.15); }
.mood-btn.is-selected { border-color: var(--prism-indigo); background: var(--bg-alt); color: var(--prism-indigo-dark); box-shadow: var(--shadow-sm); }

/* ---------- Top marketing nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50; background: rgba(250,250,254,0.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-hairline); height: var(--header-h);
}
.topnav-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.28rem; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--gradient-brand); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 8px; border-radius: 3px; background: #fff; opacity: 0.85; transform: rotate(45deg); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 10px 16px; border-radius: var(--radius-pill); font-weight: 600; font-size: 0.92rem; color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-out-soft);
}
.nav-links a:hover, .nav-links a.is-active { background: var(--bg-alt); color: var(--prism-indigo-dark); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; }
@media (max-width: 980px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
}

/* ---------- App shell (logged-in) ---------- */
.app-shell { display: grid; grid-template-columns: var(--nav-width) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border-hairline); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.92rem; color: var(--text-secondary); }
.sidebar-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-link:hover { background: var(--bg-alt); color: var(--prism-indigo-dark); }
.sidebar-link.is-active { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow); }
.sidebar-cta { margin-top: auto; }
.app-main { padding: 32px 40px 80px; max-width: 1180px; width: 100%; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-main { padding: 24px 20px 64px; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--ink-800); color: var(--text-on-dark-muted); padding: 72px 0 32px; }
.footer-grid { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 32px; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
.footer-col h4 { color: var(--text-on-dark); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 16px; }
.footer-col a { display: block; padding: 6px 0; font-size: 0.9rem; transition: color var(--dur-fast); }
.footer-col a:hover { color: #fff; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 56px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.82rem; flex-wrap: wrap; gap: 12px; }

/* ---------- Stat tile ---------- */
.stat-tile { display: flex; flex-direction: column; gap: 4px; }
.stat-tile .stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.stat-tile .stat-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }

/* ---------- Progress bar ---------- */
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--bg-alt); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-pill); background: var(--gradient-brand); transition: width var(--dur-slow) var(--ease-out-soft); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 600; font-size: 0.88rem; color: var(--text-secondary); }
.field input, .field select, .field textarea {
  padding: 13px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-hairline-strong);
  background: var(--surface); color: var(--text-primary); transition: border-color var(--dur-fast);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--prism-indigo); outline: none; }
.field-hint { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Toggle switch ---------- */
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--border-hairline-strong); border-radius: var(--radius-pill); transition: background var(--dur-fast); }
.switch-track::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--dur-fast) var(--ease-out-soft); box-shadow: var(--shadow-xs); }
.switch input:checked + .switch-track { background: var(--gradient-brand); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* ---------- Avatar ---------- */
.avatar { border-radius: 50%; background: var(--gradient-brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

/* ---------- Section heading pattern ---------- */
.section-head { max-width: 620px; margin: 0 auto 48px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.section-head.align-left { margin: 0 0 40px; text-align: left; }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Empty / Error states ---------- */
.state-panel { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.state-panel .state-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--bg-alt); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink-800); color: #fff; padding: 14px 22px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 0.88rem; transition: all var(--dur-med) var(--ease-out-soft); z-index: 200; pointer-events: none; }
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Table ---------- */
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th { text-align: left; font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 10px 14px; border-bottom: 1.5px solid var(--border-hairline); }
.table-clean td { padding: 14px; border-bottom: 1px solid var(--border-hairline); font-size: 0.92rem; }
.table-clean tr:last-child td { border-bottom: none; }
