/*
 * portal.css — Client Portal & Admin Dashboard styles
 * Author: Claude
 * Used by: login.html, portal/*, admin/*
 */

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

:root {
  --navy:        #1B3A5C;
  --navy-light:  #2A527A;
  --navy-dark:   #122840;
  --gold:        #C8982A;
  --gold-light:  #DDB84A;
  --gold-bg:     #FBF6ED;
  --white:       #FFFFFF;
  --off-white:   #F9F8F6;
  --border:      #E8E4DC;
  --text:        #2C2C2C;
  --text-mid:    #666666;
  --text-light:  #999999;
  --success:     #2E7D32;
  --success-bg:  #E8F5E9;
  --error:       #C62828;
  --error-bg:    #FFEBEE;
  --warn:        #E65100;
  --warn-bg:     #FFF3E0;
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius:      8px;
  --shadow:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:   0 4px 24px rgba(0,0,0,0.12);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--off-white);
  line-height: 1.5;
}

h1, h2, h3, h4, h5 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--navy);
  line-height: 1.2;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-gold   { background: var(--gold); color: #fff; }
.btn-gold:hover  { background: var(--gold-light); }

.btn-navy   { background: var(--navy); color: #fff; }
.btn-navy:hover  { background: var(--navy-light); }

.btn-outline { background: transparent; border-color: var(--navy); color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-ghost  { background: transparent; color: var(--text-mid); }
.btn-ghost:hover  { background: var(--border); color: var(--text); }

.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #a31515; }

.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-gold   { background: var(--gold-bg); color: var(--gold); }
.badge-silver { background: #F0F0F0; color: #555; }
.badge-navy   { background: var(--navy); color: #fff; }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-red    { background: var(--error-bg); color: var(--error); }
.badge-grey   { background: #f0f0f0; color: var(--text-mid); }


/* ╔══════════════════════════════════════════════════════════╗
   ║  LOGIN PAGE                                               ║
   ╚══════════════════════════════════════════════════════════╝ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
  padding: 2rem 1rem;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo .logo-the {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.login-logo .logo-main {
  display: block;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.login-logo .logo-divider {
  display: block;
  width: 40px;
  height: 2px;
  background: var(--gold);
  margin: 0.5rem auto 0;
}

.login-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

/* ── Form ── */
.form-field { margin-bottom: 1.1rem; }
.form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  outline: none;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus { border-color: var(--gold); }

.form-field input.error { border-color: var(--error); }
.form-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.3rem;
  display: none;
}
.form-error.show { display: block; }

.form-hint {
  font-size: 0.78rem;
  color: var(--text-mid);
  margin-top: 0.3rem;
}

.login-alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.87rem;
  margin-bottom: 1rem;
  display: none;
}
.login-alert.error   { background: var(--error-bg); color: var(--error); display: block; }
.login-alert.success { background: var(--success-bg); color: var(--success); display: block; }

.forgot-link {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-mid);
  margin-top: 0.4rem;
}
.forgot-link:hover { color: var(--gold); }

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-light);
}
.login-footer a { color: var(--text-mid); }
.login-footer a:hover { color: var(--gold); }


/* ╔══════════════════════════════════════════════════════════╗
   ║  PORTAL / ADMIN SHELL                                     ║
   ╚══════════════════════════════════════════════════════════╝ */

/* ── Page wrapper ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
}
.sidebar-logo .logo-the {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.sidebar-logo .logo-main {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 0.75rem 1.5rem 0.3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  position: relative;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(200,152,42,0.15);
  color: var(--gold);
  border-left-color: var(--gold);
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Conversation history submenu ── */
.sidebar-history-wrap {
  padding: 0 0.6rem 0.5rem;
  overflow-y: auto;
  max-height: 320px;
}

.sidebar-history-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  border-left: 2px solid transparent;
}
.sidebar-history-item:hover {
  background: rgba(255,255,255,0.07);
}
.sidebar-history-item.active {
  background: rgba(200,152,42,0.15);
  border-left-color: var(--gold);
}

.history-preview {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.sidebar-history-item.active .history-preview { color: var(--gold); }

.history-date {
  font-size: 0.67rem;
  color: rgba(255,255,255,0.35);
  display: block;
}

.sidebar-load-more {
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 0.72rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.sidebar-load-more:hover { color: var(--gold); }

.sidebar-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-user {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-tier {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}
.sidebar-signout {
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.sidebar-signout:hover { color: rgba(255,255,255,0.8); }
.sidebar-signout svg { width: 16px; height: 16px; }

/* ── Main content area ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--navy);
  flex: 1;
}
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--text);
}
.sidebar-toggle svg { width: 22px; height: 22px; }

/* ── Page body ── */
.page-body {
  padding: 2rem 1.75rem;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-sm { padding: 1.1rem 1.25rem; }
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title svg { width: 18px; height: 18px; color: var(--gold); }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-mid);
  margin-bottom: 0.35rem;
}
.stat-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.2rem;
}

/* ── Nav cards (dashboard) ── */
.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.nav-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.nav-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--gold);
  text-decoration: none;
}
.nav-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gold-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}
.nav-card-icon svg { width: 22px; height: 22px; }
.nav-card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  color: var(--navy);
}
.nav-card-desc {
  font-size: 0.82rem;
  color: var(--text-mid);
  line-height: 1.4;
}
.nav-card-arrow {
  font-size: 1.2rem;
  color: var(--gold);
  margin-top: auto;
  align-self: flex-end;
}

/* ── Progress bar ── */
.usage-bar-wrap { margin-top: 0.35rem; }
.usage-bar {
  height: 8px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
  margin-top: 0.3rem;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 50px;
  background: var(--gold);
  transition: width 0.5s ease;
}
.usage-bar-fill.danger { background: var(--error); }
.usage-bar-fill.warn   { background: var(--warn); }
.usage-label {
  font-size: 0.75rem;
  color: var(--text-mid);
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}


/* ╔══════════════════════════════════════════════════════════╗
   ║  AI COACH CHAT                                            ║
   ╚══════════════════════════════════════════════════════════╝ */

.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.chat-meta-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-mid);
  flex-shrink: 0;
}
.chat-meta-bar strong { color: var(--navy); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-welcome {
  text-align: center;
  max-width: 480px;
  padding: 2rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.chat-shell { position: relative; }
.chat-welcome a { pointer-events: all; }
.chat-welcome-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gold-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--gold);
}
.chat-welcome-icon svg { width: 30px; height: 30px; }
.chat-welcome h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}
.chat-welcome p {
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.55;
}

/* Message bubbles */
.msg {
  display: flex;
  gap: 0.75rem;
  max-width: 70%;
}
.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  align-self: flex-end;
  overflow: hidden;
}
.msg-user .msg-avatar    { background: var(--navy); }
.msg-ai .msg-avatar      { background: var(--gold); }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 100%;
}
.msg-user .msg-bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-ai .msg-bubble {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.85rem 1rem;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-6px); }
}

/* Session prompt */
.session-prompt {
  background: var(--gold-bg);
  border: 1px solid rgba(200,152,42,0.3);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  align-self: center;
  max-width: 500px;
}
.session-prompt svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }

/* Chat input area */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 1rem 1.75rem;
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 140px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--gold); }
.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gold);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.chat-send-btn:hover { background: var(--gold-light); }
.chat-send-btn:disabled { background: var(--border); cursor: not-allowed; }
.chat-send-btn svg { width: 20px; height: 20px; }

.chat-footer-note {
  font-size: 0.72rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 0.5rem;
}

/* Limit warning */
.limit-warning {
  background: var(--warn-bg);
  border: 1px solid rgba(230,81,0,0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.83rem;
  color: var(--warn);
  text-align: center;
  display: none;
}
.limit-warning.show { display: block; }


/* ╔══════════════════════════════════════════════════════════╗
   ║  ADMIN TABLE                                              ║
   ╚══════════════════════════════════════════════════════════╝ */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: 0.85rem;
}
.data-table th {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}
.data-table th:first-child { border-radius: 12px 0 0 0; }
.data-table th:last-child  { border-radius: 0 12px 0 0; }
.data-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--off-white); }
.data-table .td-name { font-weight: 600; color: var(--navy); }
.data-table .td-muted { color: var(--text-mid); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-mid);
}
.empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin: 0 auto 0.75rem; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem 0 0.5rem;
}
.page-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-mid);
  transition: background 0.15s, color 0.15s;
}
.page-btn:hover   { background: var(--off-white); }
.page-btn.active  { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Search ── */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-input-wrap svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-mid);
}
.search-input {
  width: 100%;
  padding: 0.6rem 0.9rem 0.6rem 2.2rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.87rem;
  outline: none;
}
.search-input:focus { border-color: var(--gold); }


/* ╔══════════════════════════════════════════════════════════╗
   ║  PROFILE PAGE                                             ║
   ╚══════════════════════════════════════════════════════════╝ */
.profile-section {
  max-width: 600px;
}
.avatar-upload-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid var(--gold-bg);
}
.avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-btn { font-size: 0.8rem; }

/* ── Section divider ── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Subscription card ── */
.subscription-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.subscription-card::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(200,152,42,0.15);
}
.subscription-tier-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}
.subscription-price { font-size: 2rem; font-weight: 700; color: #fff; margin: 0.2rem 0; }
.subscription-price span { font-size: 0.9rem; font-weight: 400; color: rgba(255,255,255,0.6); }
.subscription-meta { font-size: 0.82rem; color: rgba(255,255,255,0.6); margin-top: 0.75rem; }

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--navy);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }


/* ╔══════════════════════════════════════════════════════════╗
   ║  REFERENCE MATERIALS (ADMIN)                              ║
   ╚══════════════════════════════════════════════════════════╝ */
.ref-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  margin-bottom: 0.6rem;
}
.ref-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--gold-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}
.ref-item-icon svg { width: 18px; height: 18px; }
.ref-item-body { flex: 1; min-width: 0; }
.ref-item-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ref-item-meta { font-size: 0.75rem; color: var(--text-mid); margin-top: 2px; }
.ref-item-actions { display: flex; gap: 0.4rem; align-items: center; }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Conversation transcript ── */
.transcript-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
}
.transcript-item:hover { background: var(--off-white); padding-left: 0.5rem; transition: padding 0.15s; }
.transcript-date { font-size: 0.75rem; color: var(--text-mid); margin-bottom: 0.15rem; }
.transcript-preview { color: var(--text); }


/* ╔══════════════════════════════════════════════════════════╗
   ║  ONBOARDING CHECKLIST                                     ║
   ╚══════════════════════════════════════════════════════════╝ */
.onboarding-card {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  border-radius: 12px;
  padding: 1.5rem;
  color: #fff;
  margin-bottom: 1.5rem;
}
.onboarding-card h3 {
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.onboarding-card p { font-size: 0.82rem; color: rgba(255,255,255,0.7); margin-bottom: 1rem; }
.onboarding-steps { display: flex; flex-direction: column; gap: 0.5rem; }
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
}
.onboarding-step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}
.onboarding-step.done .onboarding-step-dot {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.onboarding-step.done span { text-decoration: line-through; opacity: 0.6; }


/* ╔══════════════════════════════════════════════════════════╗
   ║  MOBILE RESPONSIVE                                        ║
   ╚══════════════════════════════════════════════════════════╝ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw rgba(0,0,0,0.4);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .page-body { padding: 1.25rem 1rem; }
  .topbar { padding: 0 1rem; }
  .chat-messages { padding: 1rem; }
  .chat-input-area { padding: 0.75rem 1rem; }
  .msg { max-width: 88%; }
  .chat-meta-bar { padding: 0.5rem 1rem; flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .nav-cards { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 2rem 1.5rem 1.5rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .nav-cards { grid-template-columns: 1fr; }
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(200,152,42,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--off-white);
}
.page-loading .spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 { margin-bottom: 0.75rem; }
.modal p  { font-size: 0.88rem; color: var(--text-mid); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Rich text from AI ── */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-family: inherit;
  font-weight: 700;
  margin: 0.75rem 0 0.35rem;
  color: inherit;
}
.msg-bubble ul, .msg-bubble ol {
  padding-left: 1.25rem;
  margin: 0.4rem 0;
}
.msg-bubble li { margin-bottom: 0.2rem; }
.msg-bubble code {
  background: rgba(0,0,0,0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'Courier New', monospace;
}
.msg-bubble a { color: var(--gold); }
.msg-user .msg-bubble a { color: rgba(255,255,255,0.8); }

/* Message column wrapper (bubble + timestamp) */
.msg-col {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.msg-time {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}
.msg-user .msg-time { text-align: right; }
.msg-ai  .msg-time  { text-align: left;  }
