/* ============================================================
   AFIYAH INFINITY — COMPONENT STYLES
   ============================================================ */

/* ---- Header / greeting ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 78%, transparent);
}

.app-header__brand { display: flex; align-items: center; gap: 10px; }
.app-header__logo { width: 34px; height: 34px; }
.app-header__wordmark { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.02em; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid rgba(201,154,69,0.4);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--gold);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

.greeting-block .eyebrow { margin-bottom: 2px; }
.greeting-block h1 { margin-bottom: 4px; }

/* ---- Bottom nav (Sister: Home, Quick, Learn, Wellness, Goals, AI Coach) ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.25);
}
[data-theme="ivory_fajr"] .bottom-nav { border-top-color: rgba(0,0,0,0.08); }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  min-width: 52px;
  transition: color var(--ease-fast);
  cursor: pointer;
  position: relative;
}
.nav-item span { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.01em; }
.nav-item.active { color: var(--gold); }
.nav-item.active::before {
  content: "";
  position: absolute;
  top: -8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--gold);
}
.nav-item .icon { width: 22px; height: 22px; }

/* ---- Sidebar (desktop admin / partner / mentor) ---- */
.portal-layout { display: flex; min-height: 100dvh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: sticky;
  top: 0;
  height: 100dvh;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--space-2); }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast);
}
.sidebar__link:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sidebar__link.active { background: rgba(201,154,69,0.12); color: var(--gold); }
.sidebar__footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: var(--space-4); }

.portal-main { flex: 1; min-width: 0; padding: var(--space-6); }
.portal-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ---- Stat tiles ---- */
.stat-tile {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid rgba(255,255,255,0.05);
}
.stat-tile__label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-tile__value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; margin: 6px 0 2px; }
.stat-tile__delta { font-size: 0.78rem; font-weight: 700; }
.stat-tile__delta.up { color: var(--success); }
.stat-tile__delta.down { color: var(--danger); }

/* ---- Data table (admin) ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.06); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 640px; background: var(--surface); }
.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.88rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ---- Status stepper (verification) ---- */
.stepper { display: flex; flex-direction: column; gap: 0; }
.stepper__item { display: flex; gap: 14px; }
.stepper__rail { display: flex; flex-direction: column; align-items: center; }
.stepper__dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1.5px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.stepper__dot.done { background: var(--gold); border-color: var(--gold); color: #1A1204; }
.stepper__dot.current { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 4px rgba(201,154,69,0.15); }
.stepper__line { width: 2px; flex: 1; background: rgba(255,255,255,0.1); min-height: 28px; }
.stepper__dot.done + .stepper__line { background: var(--gold); }
.stepper__body { padding-bottom: var(--space-5); flex: 1; }
.stepper__title { font-weight: 700; margin-bottom: 2px; }

/* ---- Upload box ---- */
.upload-box {
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease-fast), background var(--ease-fast);
}
.upload-box:hover { border-color: var(--gold); background: rgba(201,154,69,0.04); }
.upload-box.has-file { border-style: solid; border-color: var(--success); background: rgba(78,154,115,0.06); }

/* ---- Theme picker tiles ---- */
.theme-tile {
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: border-color var(--ease-fast), transform var(--ease-fast);
}
.theme-tile:hover { transform: translateY(-2px); }
.theme-tile.selected { border-color: var(--gold); }
.theme-tile__swatch { height: 74px; border-radius: var(--radius-sm); margin-bottom: 10px; }
.theme-tile__check {
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold);
  display: none;
  align-items: center; justify-content: center;
  color: #1A1204;
}
.theme-tile.selected .theme-tile__check { display: flex; }

/* ---- Locked module ---- */
.locked-card {
  position: relative;
  overflow: hidden;
}
.locked-card::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(6,19,22,0.55);
  backdrop-filter: blur(1px);
}
[data-theme="ivory_fajr"] .locked-card::after { background: rgba(248,243,233,0.6); }
.locked-card__badge {
  position: absolute; top: var(--space-4); right: var(--space-4);
  z-index: 2;
}

/* ---- Disclaimer note ---- */
.disclaimer-note {
  display: flex; gap: 10px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: rgba(201,154,69,0.08);
  border: 1px solid rgba(201,154,69,0.18);
  font-size: 0.8rem;
  color: var(--muted);
  align-items: flex-start;
}
.disclaimer-note .icon { color: var(--gold); margin-top: 1px; }

/* ---- AI Coach chat ---- */
.chat-shell { display: flex; flex-direction: column; height: 100%; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}
.chat-bubble {
  max-width: 84%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
}
.chat-bubble.ai {
  background: var(--surface);
  border: 1px solid rgba(201,154,69,0.15);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bubble.user {
  background: linear-gradient(135deg, var(--gold), var(--antique-gold));
  color: #1A1204;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  max-width: 100%;
}
.chat-references {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(201,154,69,0.15);
}
.chat-reference {
  font-size: 0.76rem;
  color: var(--gold);
  font-style: italic;
}
.chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--gold);
  animation: chatTyping 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: var(--space-3) 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.chat-input-row input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--text);
}
.chat-input-row input:focus { outline: none; border-color: var(--gold); }
.chat-send {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--antique-gold));
  color: #1A1204;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-prompt-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 var(--space-2); }
.chat-chip {
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(201,154,69,0.25);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-chip:hover { background: rgba(201,154,69,0.1); }

.chat-fab {
  position: fixed;
  bottom: 92px; right: 20px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--antique-gold));
  box-shadow: var(--shadow-gold-glow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 60;
  color: #1A1204;
  border: none;
}

/* ---- Modal / sheet ---- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(6,10,12,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay.centered { align-items: center; padding: var(--space-5); }
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-5);
  max-height: 88dvh;
  overflow-y: auto;
  animation: sheetUp var(--ease-standard) both;
}
.overlay.centered .sheet { border-radius: var(--radius-xl); max-height: 82dvh; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.2); margin: 0 auto var(--space-4); }

/* ---- Toast ---- */
.toast-stack {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 440px; padding: 0 16px;
}
.toast {
  background: var(--surface);
  border: 1px solid rgba(201,154,69,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  font-size: 0.85rem;
  display: flex; align-items: center; gap: 10px;
  animation: fadeIn var(--ease-standard) both;
}
.toast .icon { color: var(--gold); }

/* ---- Feed / list items ---- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: var(--space-3) 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.list-item:last-child { border-bottom: none; }
.list-item__icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: rgba(201,154,69,0.12);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 700; font-size: 0.9rem; }
.list-item__meta { font-size: 0.78rem; color: var(--muted); }

/* ---- Loading skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  animation: skeletonLoad 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonLoad { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Auth pattern background ---- */
.auth-backdrop {
  position: relative;
  overflow: hidden;
}
.auth-backdrop::before {
  content: "";
  position: absolute;
  inset: -20%;
  background-image: radial-gradient(circle at 20% 20%, rgba(201,154,69,0.10), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(14,90,72,0.35), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(201,154,69,0.08), transparent 40%);
  pointer-events: none;
}

/* ---- Responsive: reveal desktop nav / hide mobile nav ---- */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .portal-main { padding: var(--space-4); padding-bottom: 90px; }
}

@media (min-width: 881px) {
  .bottom-nav.governance-nav { display: none; }
}

.stat-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 340px) {
  .stat-grid-4 { grid-template-columns: 1fr; }
}
