/* ============================================================
   MCQ Admin Panel — Global Stylesheet
   Theme: Clean industrial utility with amber accent
   Font: DM Mono (mono) + Sora (sans)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Sora:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg       : #0f1117;
  --bg2      : #181c26;
  --bg3      : #1e2333;
  --border   : #2a2f42;
  --accent   : #f5a623;
  --accent2  : #e8903b;
  --danger   : #e05454;
  --success  : #4caf7d;
  --info     : #5b9cf6;
  --text     : #e8eaf0;
  --text2    : #9097b0;
  --text3    : #555e7a;
  --radius   : 10px;
  --radius-sm: 6px;
  --shadow   : 0 4px 24px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --sidebar  : 240px;
  --topbar   : 60px;
  --font-mono: 'DM Mono', monospace;
  --font-sans: 'Sora', sans-serif;
  --transition: 0.18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }
ul { list-style: none; }
img { max-width: 100%; }

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-logo h1 {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  line-height: 1.2;
}
.sidebar-logo span {
  font-size: .7rem;
  color: var(--text2);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-label {
  font-size: .65rem;
  font-family: var(--font-mono);
  color: var(--text3);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 14px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text2);
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: var(--accent);
  background: rgba(245,166,35,.07);
  border-left-color: var(--accent);
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* ── Top Bar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  padding: 4px;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-breadcrumb {
  font-size: .75rem;
  color: var(--text3);
  font-family: var(--font-mono);
}
.topbar-breadcrumb span { color: var(--text2); }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Dashboard Stats ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }
.stat-icon { font-size: 26px; margin-bottom: 10px; }
.stat-label { font-size: .72rem; color: var(--text2); font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin: 4px 0;
  font-family: var(--font-mono);
}
.stat-sub { font-size: .72rem; color: var(--text3); }

/* ── Quick Links Grid ───────────────────────────────────────── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.quick-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.quick-card:hover {
  border-color: var(--accent);
  background: rgba(245,166,35,.05);
  transform: translateY(-2px);
}
.quick-card .qc-icon { font-size: 28px; }
.quick-card .qc-label { font-size: .82rem; font-weight: 600; color: var(--text); }
.quick-card .qc-sub { font-size: .7rem; color: var(--text3); }

/* ── Section Header ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.section-sub { font-size: .78rem; color: var(--text2); margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }
.btn-danger {
  background: rgba(224,84,84,.12);
  color: var(--danger);
  border: 1px solid rgba(224,84,84,.2);
}
.btn-danger:hover { background: rgba(224,84,84,.22); }
.btn-info {
  background: rgba(91,156,246,.12);
  color: var(--info);
  border: 1px solid rgba(91,156,246,.2);
}
.btn-info:hover { background: rgba(91,156,246,.22); }
.btn-success {
  background: rgba(76,175,125,.12);
  color: var(--success);
  border: 1px solid rgba(76,175,125,.2);
}
.btn-success:hover { background: rgba(76,175,125,.22); }
.btn-sm { padding: 5px 10px; font-size: .75rem; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Filters Bar ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-select, .search-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .82rem;
  outline: none;
  min-width: 160px;
  transition: border-color var(--transition);
}
.filter-select:focus, .search-input:focus { border-color: var(--accent); }
.filter-select option { background: var(--bg2); }
.search-input { min-width: 200px; }
.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 14px;
  pointer-events: none;
}
.search-wrap .search-input { padding-left: 32px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: var(--bg3);
  font-size: .7rem;
  font-family: var(--font-mono);
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  font-size: .83rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg3); }
.col-actions { width: 1%; white-space: nowrap; }
.action-btns { display: flex; gap: 6px; align-items: center; }

/* ── Tags / Chips ───────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-family: var(--font-mono);
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.chip-accent { background: rgba(245,166,35,.1); color: var(--accent); border-color: rgba(245,166,35,.25); }
.chip-info   { background: rgba(91,156,246,.1); color: var(--info);   border-color: rgba(91,156,246,.25); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 42px; margin-bottom: 14px; }
.empty-state p { font-size: .88rem; }

/* ── Loading spinner ────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 12px;
  color: var(--text3);
  font-size: .85rem;
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform .2s;
  box-shadow: var(--shadow);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: .95rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Form Elements ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .75rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: .04em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .85rem;
  outline: none;
  transition: border-color var(--transition);
  font-family: var(--font-sans);
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control option { background: var(--bg2); }

/* ── Options builder (for questions) ───────────────────────── */
.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.option-row input[type="radio"] { accent-color: var(--accent); flex-shrink: 0; }
.option-row .form-control { flex: 1; }
.option-row .remove-opt {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
  padding: 2px;
  transition: color var(--transition);
}
.option-row .remove-opt:hover { color: var(--danger); }

/* ── Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn .2s ease;
  border-left: 3px solid;
}
@keyframes slideIn { from { transform: translateX(30px); opacity:0; } to { transform: none; opacity:1; } }
.toast-success { background: var(--bg2); border-color: var(--success); color: var(--text); }
.toast-error   { background: var(--bg2); border-color: var(--danger);  color: var(--text); }
.toast-info    { background: var(--bg2); border-color: var(--info);    color: var(--text); }

/* ── Confirm Dialog ─────────────────────────────────────────── */
.confirm-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
}
.confirm-box h4 { font-size: .95rem; margin-bottom: 8px; }
.confirm-box p { font-size: .83rem; color: var(--text2); margin-bottom: 20px; }
.confirm-box .confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Topic detail tabs ──────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: .85rem;
  font-weight: 600;
  padding: 10px 18px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Questions – option display ─────────────────────────────── */
.q-options { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.q-opt {
  font-size: .78rem;
  color: var(--text2);
  padding: 3px 0;
  display: flex;
  gap: 6px;
  align-items: center;
}
.q-opt.correct { color: var(--success); font-weight: 600; }
.q-opt-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.q-opt.correct .q-opt-marker { background: var(--success); color: #000; border-color: var(--success); }
.q-text { font-weight: 500; color: var(--text); font-size: .88rem; }
.q-meta { font-size: .7rem; color: var(--text3); font-family: var(--font-mono); margin-top: 4px; }

/* ── Card rows (for quizlist / content) ─────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color var(--transition);
}
.card-item:hover { border-color: var(--accent); }
.card-emoji { font-size: 22px; flex-shrink: 0; padding-top: 2px; }
.card-info { flex: 1; min-width: 0; }
.card-title { font-size: .88rem; font-weight: 600; color: var(--text); }
.card-desc { font-size: .78rem; color: var(--text2); margin-top: 3px; line-height: 1.4; }
.card-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* ── Back link ──────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text2);
  margin-bottom: 18px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--accent); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .menu-btn { display: block; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-select, .search-input { min-width: unset; width: 100%; }
  .data-table th:nth-child(n+3):not(:last-child),
  .data-table td:nth-child(n+3):not(:last-child) { display: none; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.6rem; }
}

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── Misc ───────────────────────────────────────────────────── */
.text-muted { color: var(--text2); font-size: .8rem; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.bold { font-weight: 700; }
.mono { font-family: var(--font-mono); }
