/* ──────────────────────────────────────────────────────────────────────
   ADTV Visual Brain — shared.css
   Anchor: LIJIN-12 (CSS refactor)

   What lives here:
     • Design tokens   (CSS custom properties in :root)
     • Reset baseline  (* / body)
     • [hidden] override (HTML attribute fights flex/block specificity)
     • Top bar + user pill + user menu  (used on home/brains/questionnaires/admin/voice-review)
     • Buttons (.btn variants)
     • Status pills
     • Form row inputs (used inside modals)
     • Modal chrome
     • Pagination
     • Search input

   What does NOT live here:
     • body { background: ... } — varies per page (solid dark vs radial gradient)
     • .card — name is overloaded (auth card, chooser card, brain card, etc.); each page defines its own
     • Page-specific layout
   ────────────────────────────────────────────────────────────────────── */

:root {
  /* ── Brand palette ────────────────────────────────────────────────── */
  --brand-primary:        #6366f1;  /* indigo-500 — primary brand */
  --brand-light:          #818cf8;  /* indigo-400 */
  --brand-violet:         #a78bfa;  /* violet-400 */
  --brand-pale:           #a5b4fc;  /* indigo-300 */
  --brand-faint:          #c7d2fe;  /* indigo-200 */

  /* ── Surfaces ─────────────────────────────────────────────────────── */
  --bg-base:              #0a0a0f;
  --bg-app:               #0f0f1e;
  --bg-app-soft:          #1a1a2e;
  --bg-app-tinted:        #1a1a3e;
  --bg-card:              rgba(15, 15, 25, 0.85);
  --bg-topbar:            rgba(15, 15, 25, 0.9);
  --bg-menu:              rgba(20, 20, 30, 0.95);
  --bg-modal:             linear-gradient(180deg, #1a1a2e 0%, #181828 100%);
  --bg-input:             rgba(255, 255, 255, 0.04);
  --bg-input-hover:       rgba(255, 255, 255, 0.07);
  --bg-input-focus:       rgba(99, 102, 241, 0.06);
  --bg-row-hover:         rgba(255, 255, 255, 0.02);
  --bg-app-radial:        radial-gradient(circle at top, #1a1a3e 0%, #0f0f1e 60%);

  /* ── Borders ──────────────────────────────────────────────────────── */
  --border-faint:         rgba(255, 255, 255, 0.06);
  --border-muted:         rgba(255, 255, 255, 0.08);
  --border-strong:        rgba(255, 255, 255, 0.1);
  --border-brand-faint:   rgba(99, 102, 241, 0.1);
  --border-brand:         rgba(99, 102, 241, 0.15);
  --border-brand-medium:  rgba(99, 102, 241, 0.25);
  --border-brand-strong:  rgba(99, 102, 241, 0.4);
  --border-danger:        rgba(239, 68, 68, 0.3);

  /* ── Text ─────────────────────────────────────────────────────────── */
  --text-primary:         #fff;
  --text-base:            #e5e5e5;
  --text-soft:            #e8e8f0;
  --text-muted:           #ccc;
  --text-muted2:          #aaa;
  --text-quiet:           #888;
  --text-faint:           #666;
  --text-fainter:         #555;
  --text-fainter2:        #444;
  --text-fainter3:        #333;

  /* ── Status palette ──────────────────────────────────────────────── */
  --status-success:       #4ade80;
  --status-success-soft:  #86efac;
  --status-warning:       #fbbf24;
  --status-warning-alt:   #fb923c;
  --status-danger:        #f87171;
  --status-danger-strong: #ef4444;
  --status-danger-soft:   #fca5a5;
  --status-info:          #818cf8;

  /* ── Gradients ────────────────────────────────────────────────────── */
  --gradient-brand:       linear-gradient(135deg, #6366f1, #818cf8);
  --gradient-brand-3:     linear-gradient(135deg, #6366f1, #818cf8, #a78bfa);
  --gradient-avatar:      linear-gradient(135deg, #6366f1, #a78bfa);
  --gradient-violet:      linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  /* ── Radii ────────────────────────────────────────────────────────── */
  --radius-xs:            4px;
  --radius-sm:            6px;
  --radius:               8px;
  --radius-md:            10px;
  --radius-lg:            12px;
  --radius-xl:            14px;
  --radius-2xl:           16px;
  --radius-pill:          24px;

  /* ── Shadows ──────────────────────────────────────────────────────── */
  --shadow-brand-soft:    0 2px 12px rgba(99, 102, 241, 0.25);
  --shadow-brand:         0 4px 14px rgba(99, 102, 241, 0.35);
  --shadow-brand-strong:  0 4px 20px rgba(99, 102, 241, 0.3);
  --shadow-deep:          0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-modal:         0 20px 60px rgba(0, 0, 0, 0.6);

  /* ── Type ─────────────────────────────────────────────────────────── */
  --font-base:            'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:            'SF Mono', Menlo, Consolas, monospace;

  /* ── Motion ───────────────────────────────────────────────────────── */
  --ease-out:             cubic-bezier(0.22, 1, 0.36, 1);   /* entrances/settles */
  --ease-in-out:          cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:             120ms;   /* hover / press */
  --dur:                  200ms;   /* default transition */
  --dur-slow:             360ms;   /* entrances */
}

/* ── HTML attribute override ──────────────────────────────────────────
   The `hidden` attribute defaults to display:none, but our flex/block
   utilities can override it via specificity. Force it back. */
[hidden] { display: none !important; }

/* ── Reset ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: var(--font-base);
  color: var(--text-base);
  /* background lives in the page-specific CSS — solid dark for auth pages,
     radial gradient for app pages, etc. */
}

/* ══════════════════════════════════════════════════════════════════════
   TOP BAR + USER PILL + DROPDOWN MENU
   Used on: home, brains, questionnaires, admin, voice-review.
   ══════════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-brand-faint);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left  { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; position: relative; }

.topbar-logo {
  width: 36px; height: 36px;
  background: var(--gradient-brand);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-soft);
}
.topbar-logo svg { width: 18px; height: 18px; color: var(--text-primary); }

.topbar-title    { font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.topbar-subtitle { font-size: 11px; color: var(--text-fainter); letter-spacing: 0.05em; line-height: 1; margin-top: 2px; }

/* "Home" pill button (right side, before user pill) */
.topbar-home {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  color: var(--text-muted); font-size: 12px;
  text-decoration: none; transition: all 0.2s; cursor: pointer;
}
.topbar-home:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--border-brand-medium);
  color: var(--brand-light);
}
.topbar-home svg { width: 14px; height: 14px; }

/* User pill (avatar + name + role badge) */
.user-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-pill);
  padding: 6px 16px 6px 6px;
  cursor: pointer; transition: background 0.2s;
}
.user-pill:hover { background: var(--bg-input-hover); }

.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gradient-avatar);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-primary);
}
.user-name { font-size: 13px; color: var(--text-muted); }

.role-badge {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: var(--radius-xs); font-weight: 600;
}
.role-admin  { background: rgba(99, 102, 241, 0.15); color: var(--brand-light); }
.role-viewer { background: rgba(255, 255, 255, 0.06); color: var(--text-quiet); }

/* Dropdown menu hung under the user pill */
.user-menu {
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  background: var(--bg-menu);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: 8px;
  min-width: 220px; display: none;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-deep);
  z-index: 100;
}
.user-menu.show { display: block; }
.user-menu-item {
  display: block; padding: 10px 14px;
  border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px;
  cursor: pointer; transition: background 0.15s;
  text-decoration: none; border: none; background: none;
  width: 100%; text-align: left;
}
.user-menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.user-menu-item.danger { color: var(--status-danger); }
.user-menu-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* ══════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn-primary {
  background: var(--gradient-brand);
  color: var(--text-primary); border-color: var(--border-brand-strong);
}
.btn-primary:hover    { box-shadow: var(--shadow-brand); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: var(--bg-input); color: var(--text-muted);
  border: 1px solid var(--border-muted);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════════════════════════════
   STATUS PILLS (used in admin tables, can be reused anywhere)
   ══════════════════════════════════════════════════════════════════════ */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-md); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.pill-active   { background: rgba(74, 222, 128, 0.12); color: var(--status-success); }
.pill-inactive { background: rgba(255, 255, 255, 0.06); color: var(--text-quiet); }
.pill-pending  { background: rgba(245, 158, 11, 0.14); color: var(--status-warning); }
.pill-danger   { background: rgba(239,  68, 68, 0.14); color: var(--status-danger); }

/* ══════════════════════════════════════════════════════════════════════
   FORM ROW (modal forms — admin)
   ══════════════════════════════════════════════════════════════════════ */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; margin-bottom: 6px;
  font-size: 12px; color: var(--text-muted2); font-weight: 500;
}
.form-row .hint { font-size: 11px; color: var(--text-fainter); margin-top: 4px; }
.form-row input[type="text"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 8px 12px; color: var(--text-base);
  font-size: 13px; outline: none;
  font-family: inherit;
}
.form-row select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  /* Chevron drawn with two background-image gradients, matches dark theme */
  background-image: linear-gradient(45deg, transparent 50%, var(--text-quiet) 50%),
                    linear-gradient(135deg, var(--text-quiet) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.form-row select:disabled { opacity: 0.6; cursor: not-allowed; }
.form-row input[type="text"]:focus,
.form-row input[type="password"]:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--border-brand-strong); }
.form-row.checkbox       { display: flex; align-items: center; gap: 8px; }
.form-row.checkbox input { margin: 0; }
.form-row.checkbox label { margin: 0; cursor: pointer; }

.form-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--status-danger);
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12px; margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 5, 15, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-modal);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 24px;
}
.modal h2          { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal p.modal-sub { margin: 0 0 20px; font-size: 13px; color: var(--text-faint); }
.modal-actions     { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ══════════════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════════════ */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding: 0 4px;
  font-size: 12px; color: var(--text-quiet);
}
.pag-controls { display: flex; align-items: center; gap: 6px; }
.pag-btn {
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  color: var(--text-muted); cursor: pointer; font-size: 12px;
}
.pag-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.pag-btn:disabled             { opacity: 0.4; cursor: not-allowed; }
.pag-info                     { padding: 0 8px; }

/* ══════════════════════════════════════════════════════════════════════
   SEARCH INPUT (admin tables and any standalone search box)
   ══════════════════════════════════════════════════════════════════════ */
.search-bar { margin-bottom: 18px; }
.search-input {
  width: 100%; max-width: 360px;
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  color: var(--text-base); font-size: 13px; outline: none;
}
.search-input:focus       { border-color: var(--border-brand-strong); }
.search-input::placeholder { color: var(--text-fainter); }
