/* ============================================================
   BNI Review Platform — app.css
   ============================================================ */

:root {
  --green:       #22c55e;
  --green-bg:    #052e16;
  --green-mid:   #166534;
  --green-light: #dcfce7;
  --amber:       #f59e0b;
  --amber-bg:    #451a03;
  --amber-mid:   #92400e;
  --amber-light: #fef3c7;
  --red:         #ef4444;
  --red-bg:      #450a0a;
  --red-mid:     #991b1b;
  --red-light:   #fee2e2;
  --bg:          #0a0a0f;
  --surface:     #111118;
  --surface2:    #1a1a24;
  --surface3:    #22222f;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.13);
  --text:        #f1f0f5;
  --text2:       #9896a8;
  --text3:       #6b697a;
  --accent:      #7c6fff;
  --accent2:     #a78bfa;
  --radius:      14px;
  --radius-sm:   8px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.between { justify-content: space-between; }
.center  { align-items: center; }
.gap8    { gap: 8px; }

/* ── Login page ─────────────────────────────────────────────── */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; position: relative;
}
.login-bg {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% -10%,
    rgba(124,111,255,0.15) 0%, transparent 70%);
  z-index: 0;
}
.login-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, black 0%, transparent 80%);
}
.login-wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px; padding: 20px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 16px; margin-bottom: 16px;
}
.login-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; color: var(--text); line-height: 1.2; margin-bottom: 6px;
}
.login-sub { font-size: 14px; color: var(--text2); }
.login-card {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 28px;
}
.login-hint { font-size: 12px; color: var(--text3); text-align: center; margin-top: 10px; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-switcher {
  display: flex; background: var(--surface2); border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 22px;
}
.tab-btn {
  flex: 1; padding: 8px; text-align: center;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: 6px; color: var(--text2); background: none; border: none;
  transition: all 0.2s; font-family: inherit;
}
.tab-btn.active { background: var(--surface3); color: var(--text); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert-success {
  background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3);
  color: var(--green); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
}
.alert-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s; white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6d5fe8; }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-green { background: var(--green-mid); color: var(--green-light); }
.btn-green:hover { background: #15803d; }
.btn-red { background: var(--red-mid); color: var(--red-light); }
.btn-red:hover { background: #b91c1c; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Form elements ──────────────────────────────────────────── */
.input, .select {
  width: 100%; padding: 10px 14px;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px;
  transition: border-color 0.2s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text3); }
.select option { background: var(--surface3); }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px; font-weight: 500; color: var(--text2);
  letter-spacing: 0.5px; text-transform: uppercase;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-mid); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-mid); }
.badge-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-mid);   }
.badge-gray  { background: var(--surface2); color: var(--text2); border: 1px solid var(--border2);   }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  background: rgba(10,10,15,0.9); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.brand-tl   { display: flex; gap: 4px; align-items: center; }
.brand-dot  { width: 9px; height: 9px; border-radius: 50%; }
.brand-name {
  font-family: 'DM Serif Display', serif; font-size: 18px;
  color: var(--text); letter-spacing: -0.3px;
}
.brand-sep  { color: var(--text3); font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 100px; padding: 4px 12px 4px 4px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
}
.user-name { font-size: 13px; font-weight: 500; }

/* ── App layout ─────────────────────────────────────────────── */
.app-body { display: flex; min-height: calc(100vh - 60px); }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 220px; background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-section {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text3);
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 14px; cursor: pointer;
  transition: all 0.15s; border: 1px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: rgba(124,111,255,0.12); color: var(--accent2);
  border-color: rgba(124,111,255,0.2);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ── Main content ───────────────────────────────────────────── */
.main { flex: 1; padding: 28px; overflow-y: auto; min-width: 0; }
.page-header { margin-bottom: 24px; }
.page-title {
  font-family: 'DM Serif Display', serif; font-size: 26px;
  color: var(--text); margin-bottom: 4px;
}
.page-sub { font-size: 14px; color: var(--text2); }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.stat-label { font-size: 11px; color: var(--text2); font-weight:600; text-transform:uppercase; letter-spacing:0.5px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text3); margin-top: 4px; }
.stat-card.green { border-color: var(--green-mid); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.amber { border-color: var(--amber-mid); }
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.red   { border-color: var(--red-mid); }
.stat-card.red   .stat-value { color: var(--red); }

/* ── Chapter cards ──────────────────────────────────────────── */
.chapters-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.chapter-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: all 0.2s;
  display: flex; gap: 16px; align-items: flex-start;
  text-decoration: none; color: inherit;
}
.chapter-card:hover {
  border-color: var(--border2); background: var(--surface2); transform: translateY(-2px);
}
.chapter-card.status-green { border-left: 3px solid var(--green); }
.chapter-card.status-amber { border-left: 3px solid var(--amber); }
.chapter-card.status-red   { border-left: 3px solid var(--red);   }
.chapter-card.status-none  { border-left: 3px solid var(--border2); }
.chapter-info    { flex: 1; min-width: 0; }
.chapter-name    { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.chapter-meta    { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.chapter-score   { font-size: 24px; font-weight: 700; line-height: 1; }
.chapter-score.green { color: var(--green); }
.chapter-score.amber { color: var(--amber); }
.chapter-score.red   { color: var(--red);   }
.chapter-score-label { font-size: 12px; color: var(--text2); margin-top: 3px; }

/* ── Score bar ──────────────────────────────────────────────── */
.score-bar-wrap { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.score-bar-fill.green { background: var(--green); }
.score-bar-fill.amber { background: var(--amber); }
.score-bar-fill.red   { background: var(--red);   }

/* ── Detail view ────────────────────────────────────────────── */
.detail-header {
  display: flex; align-items: flex-start; gap: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.detail-tl-wrap { flex-shrink: 0; }
.detail-info    { flex: 1; min-width: 200px; }
.detail-title   { font-family: 'DM Serif Display', serif; font-size: 22px; margin-bottom: 4px; }
.detail-city    { color: var(--text2); font-size: 14px; margin-bottom: 14px; }
.big-score      { font-size: 52px; font-weight: 700; line-height: 1; }
.big-score.green { color: var(--green); }
.big-score.amber { color: var(--amber); }
.big-score.red   { color: var(--red);   }
.big-score.none  { color: var(--text3); }
.score-legend {
  display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px;
}
.legend-item {
  font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 5px;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Params table ───────────────────────────────────────────── */
.params-table { width: 100%; border-collapse: collapse; }
.params-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.params-table td {
  padding: 12px 14px; font-size: 14px;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.params-table tr:last-child td { border-bottom: none; }
.params-table tbody tr:hover td { background: var(--surface2); }
.param-indicator {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; margin-right: 8px; flex-shrink: 0;
}

/* ── Score pills ────────────────────────────────────────────── */
.score-pill {
  display: inline-block; padding: 3px 10px;
  border-radius: 100px; font-size: 13px; font-weight: 600;
  min-width: 42px; text-align: center;
}
.pill-full    { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-mid); }
.pill-partial { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-mid); }
.pill-zero    { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-mid);   }

/* ── Enter scores ───────────────────────────────────────────── */
.param-input-row {
  display: grid; grid-template-columns: 1fr 64px 130px;
  gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.param-input-row:last-child { border-bottom: none; }
.param-input-name { font-size: 14px; }
.param-input-max  { font-size: 13px; color: var(--text2); text-align: center; }
.score-input {
  width: 100%; padding: 8px 10px; text-align: center;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600;
}
.score-input:focus { outline: none; border-color: var(--accent); }

/* ── Live preview ───────────────────────────────────────────── */
.live-preview {
  position: sticky; bottom: 20px;
  background: rgba(17,17,24,0.95); backdrop-filter: blur(12px);
  border: 1px solid var(--border2); border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-top: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.live-score-val { font-size: 26px; font-weight: 700; transition: color 0.3s; }
.live-score-val.green { color: var(--green); }
.live-score-val.amber { color: var(--amber); }
.live-score-val.red   { color: var(--red);   }

/* ── History ────────────────────────────────────────────────── */
.history-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
}
.history-cell {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.history-cell:hover   { border-color: var(--border2); transform: translateY(-2px); }
.history-cell.green   { border-color: var(--green-mid); background: rgba(22,101,52,0.15); }
.history-cell.amber   { border-color: var(--amber-mid); background: rgba(146,64,14,0.15); }
.history-cell.red     { border-color: var(--red-mid);   background: rgba(153,27,27,0.15); }
.history-month        { font-size: 12px; color: var(--text2); }
.history-score        { font-size: 22px; font-weight: 700; }
.history-score.green  { color: var(--green); }
.history-score.amber  { color: var(--amber); }
.history-score.red    { color: var(--red);   }
.history-pct          { font-size: 11px; color: var(--text2); }

/* ── Member welcome ─────────────────────────────────────────── */
.member-welcome {
  background: linear-gradient(135deg, rgba(124,111,255,0.08) 0%, rgba(124,111,255,0.02) 100%);
  border: 1px solid rgba(124,111,255,0.2);
  border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}

/* ── Month chips ────────────────────────────────────────────── */
.month-chip {
  padding: 5px 14px; border-radius: 100px; font-size: 13px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); transition: all 0.15s; text-decoration: none; display: inline-block;
}
.month-chip:hover  { border-color: var(--border2); color: var(--text); }
.month-chip.active {
  background: rgba(124,111,255,0.15); border-color: rgba(124,111,255,0.4); color: var(--accent2);
}

/* ── Manage rows ────────────────────────────────────────────── */
.chapter-manage-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); gap: 12px; flex-wrap: wrap;
}
.chapter-manage-name { font-weight: 600; font-size: 14px; }
.chapter-manage-pwd  { font-size: 12px; color: var(--text3); margin-top: 3px; }
code {
  background: var(--surface3); padding: 2px 6px;
  border-radius: 4px; font-size: 12px; font-family: monospace;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-icon  { font-size: 40px; margin-bottom: 14px; }
.empty-title { font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.empty-text  { font-size: 14px; }
.empty-text a { color: var(--accent2); text-decoration: underline; }

/* ── Section title ──────────────────────────────────────────── */
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar  { display: none; }
  .main     { padding: 16px; }
  .param-input-row { grid-template-columns: 1fr 48px 90px; }
  .chapters-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
