/* ── Default theme (White / Light) ── */
:root, [data-theme="white"] {
  --primary: #6C63FF;
  --primary-dark: #5548e0;
  --secondary: #FF6584;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f4f5fb;
  --bg2: #ffffff;
  --bg3: #eef0f8;
  --card: #ffffff;
  --card2: #f0f1f9;
  --border: #dde1f0;
  --text: #1e1e3a;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(108,99,255,0.10);
}

/* ── Dark (deep space) ── */
[data-theme="dark"] {
  --primary: #6C63FF;
  --primary-dark: #5548e0;
  --secondary: #FF6584;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --card: #1e1e3a;
  --card2: #252547;
  --border: #2e2e5e;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ── Ocean (deep teal) ── */
[data-theme="ocean"] {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --secondary: #38bdf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0a1628;
  --bg2: #0f2240;
  --bg3: #0d1e38;
  --card: #132b50;
  --card2: #1a3660;
  --border: #1e4080;
  --text: #e0f2fe;
  --text-muted: #7fb3d3;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* ── Forest (deep green) ── */
[data-theme="forest"] {
  --primary: #22c55e;
  --primary-dark: #16a34a;
  --secondary: #86efac;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0a1a0e;
  --bg2: #0f2515;
  --bg3: #0d2012;
  --card: #132e18;
  --card2: #1a3a1f;
  --border: #1e4526;
  --text: #dcfce7;
  --text-muted: #86a98d;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Layout */
.layout { display: flex; min-height: 100vh; }

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

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.sidebar-logo h1 { font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-logo span { font-size: 11px; color: var(--primary); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.nav-item:hover, .nav-item.active {
  background: var(--card);
  color: var(--text);
}
.nav-item.active { color: var(--primary); border-left: 3px solid var(--primary); }
.nav-item .icon { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--card);
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-phone { font-size: 11px; color: var(--text-muted); }

/* Main content */
.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - 250px);
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title { font-size: 18px; font-weight: 700; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple { background: rgba(108,99,255,0.2); }
.stat-icon.pink { background: rgba(255,101,132,0.2); }
.stat-icon.green { background: rgba(16,185,129,0.2); }
.stat-icon.yellow { background: rgba(245,158,11,0.2); }

.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); color: white; transform: translateY(-1px); }

.btn-secondary {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--card); color: var(--text); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 10px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

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

select.form-control option { background: var(--bg2); }

/* Table */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108,99,255,0.04); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-primary { background: rgba(108,99,255,0.2); color: var(--primary); }
.badge-success { background: rgba(16,185,129,0.2); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.2); color: var(--danger); }

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-info { background: rgba(108,99,255,0.15); border: 1px solid rgba(108,99,255,0.3); color: #a5b4fc; }
.alert-warning { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }

/* Page header */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 28px; font-weight: 800; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg2);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.05);
}
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-zone h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.upload-zone p { color: var(--text-muted); font-size: 14px; }

/* Quiz cards */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.quiz-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}
.quiz-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 8px 32px rgba(108,99,255,0.2);
}

.quiz-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.quiz-card-title { font-size: 15px; font-weight: 700; line-height: 1.3; flex: 1; }
.quiz-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.quiz-card-actions { display: flex; gap: 8px; }

/* Question styles for quiz taking */
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.question-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.question-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 20px;
}

.options-grid { display: flex; flex-direction: column; gap: 10px; }

.option-label {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg2);
}

.option-label:hover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.08);
}

.option-label input[type=radio] { display: none; }
.option-label input[type=radio]:checked ~ * { color: white; }

.option-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(108,99,255,0.2);
}

.option-letter {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--card2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.option-label:has(input:checked) .option-letter {
  background: var(--primary);
  border-color: var(--primary);
}

.option-text { font-size: 14px; line-height: 1.4; }

/* Result styles */
.result-correct .option-label { border-color: var(--success) !important; background: rgba(16,185,129,0.1) !important; }
.result-wrong .option-label { border-color: var(--danger) !important; background: rgba(239,68,68,0.1) !important; }
.result-correct .option-letter { background: var(--success) !important; border-color: var(--success) !important; }

.explanation-box {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(108,99,255,0.1);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Score ring */
.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}

.score-ring {
  position: relative;
  width: 160px; height: 160px;
}

.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 12; }
.score-ring .ring-fg { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1.5s ease; }

.score-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-pct { font-size: 36px; font-weight: 800; }
.score-label { font-size: 12px; color: var(--text-muted); }

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease;
}

/* Auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 20% 50%, rgba(108,99,255,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 50%, rgba(255,101,132,0.1) 0%, transparent 50%),
              var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin: 0 auto 12px;
}

.auth-logo h1 { font-size: 24px; font-weight: 800; }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--text-muted); }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Timer */
.quiz-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.quiz-timer.warning { color: var(--warning); }
.quiz-timer.danger { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  transform: scale(0.9);
  transition: transform 0.3s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; max-width: 100vw; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-grid { grid-template-columns: 1fr; }
}

.hamburger {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
}
@media (max-width: 768px) { .hamburger { display: flex; } }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--primary); color: white; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Misc */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Light-theme (white) specific overrides ── */
[data-theme="white"] .auth-wrap {
  background: radial-gradient(ellipse at 20% 50%, rgba(108,99,255,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 50%, rgba(255,101,132,0.06) 0%, transparent 50%),
              #f4f5fb;
}
[data-theme="white"] .auth-card {
  box-shadow: 0 8px 40px rgba(108,99,255,0.12);
}
[data-theme="white"] .form-control {
  background: #f8f9ff;
  color: #1e1e3a;
}
[data-theme="white"] .option-label {
  background: #f8f9ff;
}
[data-theme="white"] .upload-zone {
  background: #f8f9ff;
}
[data-theme="white"] .sidebar {
  background: #ffffff;
  border-right-color: #e2e6f3;
  box-shadow: 2px 0 12px rgba(108,99,255,0.06);
}
[data-theme="white"] .nav-item:hover,
[data-theme="white"] .nav-item.active {
  background: #f0f1f9;
}
[data-theme="white"] .user-info {
  background: #f0f1f9;
}
[data-theme="white"] .stat-card,
[data-theme="white"] .quiz-card {
  box-shadow: 0 2px 12px rgba(108,99,255,0.08);
}
[data-theme="white"] tr:hover td { background: rgba(108,99,255,0.03); }
