/* Kohinoor Academy — admin panel CSS.
   Brand palette mirrors the feedback HTML so the printed report and
   the web UI feel like one product. */

:root {
  --bg:          #f7f8fb;
  --card:        #ffffff;
  --border:      #e5e7eb;
  --text:        #111827;
  --text-muted:  #6b7280;
  --text-soft:   #9ca3af;

  --brand:       #1E40FF;
  --brand-dark:  #0B25C7;
  --brand-soft:  #E6EBFF;
  --accent:      #F97316;
  --accent-soft: #FFEDD5;

  --success:      #10b981;
  --success-soft: #d1fae5;
  --warning:      #f59e0b;
  --warning-soft: #fef3c7;
  --danger:       #ef4444;
  --danger-soft:  #fee2e2;

  --radius:    14px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 14px rgba(16,24,40,.06);

  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

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

.muted { color: var(--text-muted); }

/* ===================== TOP BAR ===================== */

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand-name {
  font-weight: 800; font-size: 15px;
  letter-spacing: -.3px; line-height: 1;
}
.brand-tag {
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--text-muted); text-transform: uppercase;
  margin-top: 2px;
}

.nav {
  display: flex; align-items: center; gap: 4px;
  font-size: 14px;
  flex-wrap: nowrap;            /* never wrap labels onto a second line */
}
.nav > a, .nav-dropdown > span {
  display: inline-block;
  white-space: nowrap;          /* keep each label on one line */
  padding: 8px 14px;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav > a:hover, .nav-dropdown > span:hover {
  background: var(--brand-soft); color: var(--brand);
  text-decoration: none;
}
.nav > a.active, .nav-dropdown.active > span {
  background: var(--brand); color: #fff;
}

/* Small count badge that rides inside a normal nav link (notifications) */
.nav-badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  padding: 0 5px; margin-left: 5px; border-radius: 9px;
  font-size: 11px; font-weight: 700; text-align: center;
  vertical-align: middle; color: #fff;
}
.nav-badge-bell { background: #0ea5e9; }   /* new online results */
.nav-badge-warn { background: #F97316; }   /* pending ID reviews  */
.nav > a.has-badge { color: var(--text); }  /* keep label readable, not muted */

.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  position: absolute; top: 100%; left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 60;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  border-radius: 6px;
}
.nav-dropdown-menu a:hover {
  background: var(--brand-soft); color: var(--brand);
  text-decoration: none;
}
.nav-dropdown-menu a.active {
  background: var(--brand); color: #fff;
}

/* ===================== PAGE ===================== */

.page {
  max-width: 1180px;
  margin: 32px auto 80px;
  padding: 0 24px;
}

/* Hero card on home + placeholder pages */
.hero-card {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 36px;
  margin-bottom: 24px;
  box-shadow: 0 12px 40px rgba(30,64,255,.18);
}
.hero-card h1 { margin: 0 0 8px 0; font-size: 28px; letter-spacing: -.5px; }
.hero-card p { margin: 0; color: rgba(255,255,255,.85); font-size: 14.5px; }
.hero-card .muted { color: rgba(255,255,255,.85); }

/* ===================== CARDS GRID ===================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.card-link {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-soft);
  text-decoration: none;
}
.card-link h3 {
  margin: 6px 0 4px 0; font-size: 16px; font-weight: 700;
}
.card-link p { margin: 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.card-icon { font-size: 28px; line-height: 1; }

/* ===================== INFO BANNER ===================== */

.info-banner {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 24px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
}
.info-banner strong { color: var(--accent); }

/* ===================== TABLES ===================== */

.table {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate; border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.table th {
  background: #fafbfd;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--brand-soft); }

/* ===================== BUTTONS ===================== */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--brand-soft); border-color: var(--brand);
             color: var(--brand); text-decoration: none; }
.btn-primary {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); color: #fff;
                     border-color: var(--brand-dark); }
.btn-accent {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-accent:hover { background: #ea6707; color: #fff;
                    border-color: #ea6707; }
.btn-danger {
  background: #fff; color: var(--danger); border-color: var(--danger-soft);
}
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-disabled, .btn[disabled] {
  background: #f3f4f6; color: var(--text-soft); cursor: not-allowed;
  border-color: var(--border);
}

/* ===================== SECTIONS ===================== */

.section { margin-top: 32px; }
.section-h {
  font-size: 14px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 0 0 14px 0;
}

/* Tags / pills */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}
.tag-brand   { background: var(--brand-soft);   color: var(--brand); }
.tag-accent  { background: var(--accent-soft);  color: var(--accent); }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warning { background: var(--warning-soft); color: var(--warning); }
.tag-danger  { background: var(--danger-soft);  color: var(--danger); }
.tag-info    { background: var(--brand-soft);   color: var(--brand); }
.tag-neutral { background: #f3f4f6;             color: var(--text-muted); }

/* Inline filter form (e.g. /audit) */
.filter-form {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: end;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.filter-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-muted); font-weight: 600;
}
.filter-form select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  min-width: 160px;
}

.empty-state {
  padding: 32px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.section-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.section-actions .section-h { margin: 0; }

.filter-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.filter-link {
  padding: 5px 12px;
  border-radius: 99px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  text-decoration: none;
  font-weight: 600;
}
.filter-link:hover { color: var(--brand); border-color: var(--brand-soft); }
.filter-link.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.row-actions {
  display: flex; gap: 6px; align-items: center;
  white-space: nowrap;
}
.row-actions .btn { padding: 5px 11px; font-size: 12.5px; }
.row-actions form { margin: 0; }

/* ===================== UPLOAD CARD ===================== */

.upload-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row label {
  display: flex; flex-direction: column;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  gap: 6px;
}
.form-row input[type="text"],
.form-row select,
.form-row input[type="file"] {
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.form-row input[type="file"] {
  padding: 7px 8px;
  font-size: 13.5px;
}
.form-row input:focus, .form-row select:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}
.file-label { grid-column: span 2; }
.upload-actions {
  display: flex; align-items: center; gap: 14px;
  margin-top: 8px;
}
.btn-large { padding: 11px 22px; font-size: 14px; }

/* HTMX spinner */
.htmx-indicator { display: none; color: var(--text-muted); }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.btn { opacity: .6; pointer-events: none; }

/* ===================== UPLOAD RESULT ===================== */

.upload-result {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.upload-result.success {
  background: var(--success-soft);
  border-color: var(--success);
}
.upload-result.error {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.upload-status {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}
.status-icon {
  font-size: 22px; font-weight: 700; line-height: 1;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.upload-result.success .status-icon { background: var(--success); }
.upload-result.error .status-icon { background: var(--danger); }

.error-list {
  margin: 12px 0 0 0; padding-left: 0;
  list-style: none;
  font-size: 13px;
}
.error-list li {
  padding: 6px 0;
  border-top: 1px solid rgba(0,0,0,.06);
  color: var(--text);
}
.error-list li:first-child { border-top: none; }
.error-loc {
  display: inline-block;
  background: #fff;
  padding: 1px 7px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11.5px;
  margin-right: 6px;
}

.warnings {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,.5);
  border-radius: 8px;
  font-size: 13px;
}
.warnings ul { margin: 6px 0 0 18px; padding: 0; }

/* ===================== FOOTER ===================== */

.page-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.7;
}
.page-footer a { color: var(--brand); }

/* ===================== DASHBOARD (Phase 5.9) ===================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 22px 0 18px;
}
.kpi-card {
  position: relative;
  display: block;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
}
a.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 64, 255, .08);
}
.kpi-icon {
  font-size: 22px;
  position: absolute; top: 12px; right: 14px;
  opacity: .85;
}
.kpi-value {
  font-size: 34px; font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 12.5px; font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}
.kpi-card.kpi-brand   { border-left: 4px solid var(--brand); }
.kpi-card.kpi-accent  { border-left: 4px solid var(--accent); }
.kpi-card.kpi-success { border-left: 4px solid var(--success); }
.kpi-card.kpi-warning { border-left: 4px solid var(--warning); }

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dashboard-half { margin: 0; }

.dashboard-table { font-size: 13.5px; }
.dashboard-table td, .dashboard-table th { padding: 8px 10px; }
.text-right { text-align: right; }
.small      { font-size: 11.5px; }

.p-pct-excellent { color: var(--success); }
.p-pct-good      { color: var(--brand); }
.p-pct-fair      { color: var(--warning); }
.p-pct-weak      { color: var(--danger); }

.leaderboard {
  display: flex; flex-direction: column;
  gap: 4px;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  background: #fafbfd;
  border: 1px solid var(--border);
}
.lb-rank { font-weight: 700; text-align: center; font-size: 16px; }
.lb-name strong { display: block; font-size: 14px; }
.lb-pct  { font-weight: 800; font-size: 18px; }

/* Teacher leaderboard card (Phase 5.11) */
.lb-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}
.lb-card.lb-empty { opacity: .65; }
.lb-card-head {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
}
.lb-rank-big {
  font-size: 32px;
  text-align: center;
  font-weight: 800;
  line-height: 1;
}
.lb-card-info strong { font-size: 15px; }
.lb-card-pct {
  text-align: right;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
}
.lb-card-top {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.lb-top-students { display: flex; flex-direction: column; gap: 4px; }
.lb-top-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 4px 6px;
  border-radius: 6px;
}
.lb-top-row:nth-child(odd) { background: #fafbfd; }
.lb-top-row > span:last-child { font-weight: 700; }

/* ===================== UPLOAD + VERIFY (Phase 5.12) ===================== */

.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafbfd;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.upload-zone-label strong { font-size: 16px; }
.upload-zone-label .muted { display: block; margin-top: 4px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* Verify cards */
.verify-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}
.verify-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.verify-card-head > div:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
.verify-card-body {
  background: #fafbfd;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.verify-info-row {
  display: flex; gap: 12px; align-items: center;
  padding: 4px 0;
  font-size: 14px;
}
.verify-info-row > .muted.small:first-child { min-width: 130px; }
.verify-form { display: flex; flex-direction: column; gap: 10px; }
.verify-label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-muted); font-weight: 600;
}
.verify-label input[type=text] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.verify-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.radio-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  user-select: none;
}
.radio-pill input { margin: 0; }
.radio-pill-success:has(input:checked) {
  background: var(--success-soft); color: var(--success);
  border-color: var(--success);
}
.radio-pill-danger:has(input:checked) {
  background: var(--danger-soft); color: var(--danger);
  border-color: var(--danger);
}

/* Audio file card (Phase 5.13) */
.audio-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}
.audio-card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.audio-card audio {
  border-radius: 6px;
}

/* Trend + CEFR bars (Phase 5.14) */
.trend-bar {
  height: 8px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  min-width: 140px;
}
.trend-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .2s;
}
.fill-excellent { background: var(--success); }
.fill-good      { background: var(--brand); }
.fill-fair      { background: var(--warning); }
.fill-weak      { background: var(--danger); }

.cefr-bars { display: flex; flex-direction: column; gap: 8px; }
.cefr-row {
  display: grid;
  grid-template-columns: 36px 1fr 90px;
  align-items: center;
  gap: 12px;
}
.cefr-label {
  font-weight: 800;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 6px;
  padding: 4px 8px;
  text-align: center;
  font-size: 13px;
}
.cefr-bar {
  height: 16px;
  background: #f3f4f6;
  border-radius: 6px;
  overflow: hidden;
}
.cefr-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-radius: 6px;
  transition: width .2s;
}
.cefr-count { text-align: right; font-size: 13.5px; }

/* ===================== RESPONSIVE ===================== */

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .nav { gap: 0; font-size: 13px; overflow-x: auto; }
  .nav > a, .nav-dropdown > span { padding: 6px 10px; }
  .brand-name { font-size: 14px; }
  .page { padding: 0 14px; margin-top: 20px; }
  .hero-card { padding: 24px 22px; }
  .hero-card h1 { font-size: 22px; }

  /* Dashboard collapses on phone */
  .kpi-grid       { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row  { grid-template-columns: 1fr; }
  .kpi-value      { font-size: 28px; }
}
