/* ═══════════════════════════════════════════════════════════
   Study Galaxy Admin — Galaxy Dark Theme
   Font loaded via <link> in index.html
   ═══════════════════════════════════════════════════════════ */

:root {
  --seed: #7C6CFF;
  --seed-light: #9B8FFF;
  --accent: #00E5FF;
  --gold: #FFC857;
  --correct: #2ECC71;
  --wrong: #E74C3C;
  --bg: #0B0918;
  --bg2: #15102E;
  --surface: #1B1638;
  --surface-hi: #241D49;
  --surface-border: rgba(255,255,255,0.06);
  --text: #E8E6F0;
  --text-muted: #9B97B0;
  --text-dim: #6B6780;
  --brand-gradient: linear-gradient(135deg, #8B7BFF, #6C63FF, #4F46E5);
  --space-gradient: linear-gradient(135deg, #0B0918, #15102E, #0E1430);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;
  --sidebar-w: 240px;
  --transition: 0.2s ease;
  --shadow: 0 8px 32px rgba(124,108,255,0.12);
  --shadow-lg: 0 16px 48px rgba(124,108,255,0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure [hidden] always wins over CSS display values */
[hidden] { display: none !important; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Login Page ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--space-gradient);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -120px; right: -100px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(124,108,255,0.3) 0%, transparent 70%);
  border-radius: 50%;
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -140px; left: -100px;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(0,229,255,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.login-card {
  background: rgba(27,22,56,0.85);
  backdrop-filter: blur(24px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.login-logo h1 {
  font-size: 24px; font-weight: 800;
  background: var(--brand-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.3px;
}
.form-hint { display: block; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.form-error {
  color: var(--wrong); font-size: 13px; text-align: center;
  margin-top: 16px; padding: 10px; border-radius: var(--radius-sm);
  background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.2);
}

input, textarea, select {
  width: 100%; padding: 12px 14px;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--seed);
  box-shadow: 0 0 0 3px rgba(124,108,255,0.2);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { min-height: 80px; resize: vertical; }
select { cursor: pointer; }
select option { background: var(--surface); color: var(--text); }

input[type="color"] {
  width: 48px; height: 40px; padding: 4px; cursor: pointer;
  border-radius: var(--radius-sm);
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.localized-group { display: flex; gap: 8px; align-items: flex-start; }
.localized-group input { flex: 1; }
.lang-label {
  flex-shrink: 0; width: 28px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: rgba(0,229,255,0.08); border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); outline: none;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-gradient); color: #fff;
  box-shadow: 0 4px 16px rgba(124,108,255,0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(124,108,255,0.45); transform: translateY(-1px); }

.btn-secondary { background: var(--surface-hi); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--seed); color: #fff; }

.btn-outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--surface-border);
}
.btn-outline:hover:not(:disabled) { border-color: var(--seed); color: var(--seed); }

.btn-danger { background: rgba(231,76,60,0.15); color: var(--wrong); }
.btn-danger:hover:not(:disabled) { background: var(--wrong); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 32px; height: 32px; border-radius: 6px; font-size: 14px; }

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

.sidebar {
  width: var(--sidebar-w); background: var(--bg2);
  border-right: 1px solid var(--surface-border);
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-header {
  padding: 20px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--surface-border);
}
.sidebar-logo { font-size: 28px; }
.sidebar-title {
  font-size: 16px; font-weight: 800;
  background: var(--brand-gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all var(--transition); margin-bottom: 2px;
}
.nav-link:hover { color: var(--text); background: rgba(124,108,255,0.08); }
.nav-link.active { color: #fff; background: rgba(124,108,255,0.18); font-weight: 600; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--surface-border);
  display: flex; align-items: center; justify-content: space-between;
}
.version-badge {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: rgba(0,229,255,0.1); padding: 4px 10px;
  border-radius: 20px;
}

.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  padding: 32px; min-height: 100vh;
  background: var(--space-gradient);
}

.page-container { max-width: 1200px; margin: 0 auto; }

/* ─── Page Header ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.page-header-actions { display: flex; gap: 8px; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: rgba(27,22,56,0.7); backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: rgba(27,22,56,0.7); backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.purple { background: linear-gradient(135deg, rgba(139,123,255,0.3), rgba(79,70,229,0.3)); }
.stat-icon.cyan { background: linear-gradient(135deg, rgba(0,229,255,0.3), rgba(45,156,219,0.3)); }
.stat-icon.gold { background: linear-gradient(135deg, rgba(255,200,87,0.3), rgba(255,157,77,0.3)); }
.stat-icon.green { background: linear-gradient(135deg, rgba(46,204,113,0.3), rgba(39,174,96,0.3)); }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* ─── Data Tables ───────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: rgba(27,22,56,0.5);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius); overflow: hidden;
}
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-dim);
  background: rgba(15,10,40,0.6); border-bottom: 1px solid var(--surface-border);
}
.data-table td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tr:hover td { background: rgba(124,108,255,0.04); }
.data-table tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: 4px; }

/* ─── Filter Bar ────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 20px; padding: 14px 18px;
  background: rgba(27,22,56,0.5); border: 1px solid var(--surface-border);
  border-radius: var(--radius);
}
.filter-bar select, .filter-bar input {
  width: auto; min-width: 160px; padding: 8px 12px; font-size: 13px;
}
.filter-bar input[type="search"] { min-width: 220px; }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px;
  font-size: 11px; font-weight: 700; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-easy { background: rgba(46,204,113,0.15); color: var(--correct); }
.badge-medium { background: rgba(255,200,87,0.15); color: var(--gold); }
.badge-hard { background: rgba(231,76,60,0.15); color: var(--wrong); }
.badge-info { background: rgba(0,229,255,0.12); color: var(--accent); }
.badge-count {
  display: inline-block; padding: 2px 8px;
  font-size: 11px; font-weight: 700; border-radius: 20px;
  background: rgba(124,108,255,0.15); color: var(--seed-light);
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5,3,15,0.75); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg); width: 100%; max-width: 600px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease;
}
.modal-header {
  padding: 20px 24px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--surface-border);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border: none; background: transparent;
  color: var(--text-muted); font-size: 22px; cursor: pointer;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: rgba(231,76,60,0.15); color: var(--wrong); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--surface-border);
}

/* ─── Toasts ────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; min-width: 280px; max-width: 420px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slideInRight 0.3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { background: rgba(46,204,113,0.15); border: 1px solid rgba(46,204,113,0.3); color: var(--correct); }
.toast-error { background: rgba(231,76,60,0.15); border: 1px solid rgba(231,76,60,0.3); color: var(--wrong); }
.toast-info { background: rgba(0,229,255,0.12); border: 1px solid rgba(0,229,255,0.25); color: var(--accent); }

/* ─── Loading ───────────────────────────────────────────── */
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text-muted);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--surface-hi);
  border-top-color: var(--seed); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-dim);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state-text { font-size: 15px; font-weight: 500; }

/* ─── Option Rows (question form) ───────────────────────── */
.option-row {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 8px; padding: 10px 12px;
  background: rgba(15,10,40,0.4); border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
}
.option-row.correct { border-color: rgba(46,204,113,0.3); background: rgba(46,204,113,0.05); }
.option-row input { flex: 1; }
.option-radio { cursor: pointer; accent-color: var(--correct); width: 18px; height: 18px; }
.option-remove { cursor: pointer; background: none; border: none; color: var(--wrong); font-size: 18px; padding: 4px; }

/* ─── Bulk Import ───────────────────────────────────────── */
.import-zone {
  border: 2px dashed var(--surface-hi); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: all var(--transition); margin-bottom: 16px;
}
.import-zone:hover, .import-zone.dragover {
  border-color: var(--seed); background: rgba(124,108,255,0.05);
}
.import-zone-icon { font-size: 36px; margin-bottom: 8px; display: block; }
.import-zone-text { color: var(--text-muted); font-size: 14px; }

.import-preview {
  max-height: 200px; overflow-y: auto; font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg); padding: 12px; border-radius: var(--radius-sm);
  margin-top: 12px; white-space: pre-wrap; color: var(--text-dim);
}

/* ─── Chart Bars ────────────────────────────────────────── */
.bar-chart { margin-top: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-label { width: 100px; font-size: 12px; color: var(--text-muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: rgba(15,10,40,0.6); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; display: flex; align-items: center; padding-left: 8px; font-size: 10px; font-weight: 700; color: #fff; min-width: 30px; }
.bar-fill.purple { background: var(--brand-gradient); }
.bar-fill.green { background: linear-gradient(90deg, #2ECC71, #27AE60); }
.bar-fill.gold { background: linear-gradient(90deg, #FFC857, #FF9D4D); }
.bar-fill.red { background: linear-gradient(90deg, #E74C3C, #C0392B); }

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 20px;
}
.pagination button {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--surface-border); border-radius: 6px;
  cursor: pointer; transition: all var(--transition);
}
.pagination button:hover:not(:disabled) { border-color: var(--seed); color: var(--seed); }
.pagination button.active { background: var(--seed); color: #fff; border-color: var(--seed); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination-info { font-size: 12px; color: var(--text-dim); margin: 0 8px; }

/* ─── Animations ────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-title, .nav-link span:last-child, .sidebar-footer .btn span { display: none; }
  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .nav-link { justify-content: center; padding: 10px; }
  .sidebar-footer { flex-direction: column; gap: 8px; }
  .main-content { margin-left: 60px; padding: 20px; }
  :root { --sidebar-w: 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .filter-bar select, .filter-bar input { width: 100%; min-width: unset; }
}
