/* =========================================
   Admin Panel Styles — Lifting AP Training
   AliLMS.com — IndexedDB Admin Backend
   ========================================= */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22253a;
  --surface3: #2a2e45;
  --border: #2e3250;
  --accent: #f97316;
  --accent2: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== PIN SCREEN ===== */
#pinScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(249,115,22,0.12) 0%, transparent 70%), var(--bg);
}

.pin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}

.pin-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 24px;
  box-shadow: 0 8px 32px rgba(249,115,22,0.3);
}

.pin-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.pin-card p { color: var(--text2); font-size: 14px; margin-bottom: 32px; }

.pin-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 28px;
}

.pin-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.2s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.pin-key {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.pin-key:hover { background: var(--surface3); border-color: var(--accent); transform: scale(1.05); }
.pin-key:active { transform: scale(0.97); }
.pin-key.del { font-size: 16px; color: var(--text2); }
.pin-key.clear { font-size: 13px; color: var(--danger); }

#pinError {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: 16px;
  text-align: center;
}

/* ===== ADMIN APP ===== */
#adminApp { display: none; }

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

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

.admin-brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.admin-brand-text .name { display: block; font-weight: 700; font-size: 15px; }
.admin-brand-text .sub { display: block; font-size: 11px; color: var(--text3); letter-spacing: 0.5px; text-transform: uppercase; }

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

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(249,115,22,0.15); color: var(--accent); }
.nav-item .nav-icon { font-size: 16px; width: 20px; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

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

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--danger);
  font-size: 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  width: 100%;
  font-family: var(--font);
  transition: all 0.15s;
}
.logout-btn:hover { background: rgba(239,68,68,0.15); }

/* Main */
.admin-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}

.topbar-title h2 { font-size: 18px; font-weight: 700; }
.topbar-title p { font-size: 13px; color: var(--text2); }

.topbar-actions { display: flex; gap: 10px; align-items: center; }
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ea580c; transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.admin-content {
  padding: 32px;
  flex: 1;
}

/* Tab Panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}
.stat-box:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-box .sb-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-box .sb-value { font-size: 32px; font-weight: 800; color: var(--accent); }
.stat-box .sb-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Day Progress Cards */
.day-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.day-prog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.day-prog-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.prog-bar { background: var(--surface2); border-radius: 999px; height: 8px; margin-bottom: 8px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f97316, #ea580c); transition: width 0.6s ease; }
.prog-text { font-size: 12px; color: var(--text2); }

/* Section / Quiz Lists */
.section-list { display: flex; flex-direction: column; gap: 10px; }

.section-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.section-item:hover { border-color: var(--accent); }

.section-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.section-header .sec-icon { font-size: 20px; }
.section-header .sec-info { flex: 1; }
.section-header .sec-title { font-size: 14px; font-weight: 600; }
.section-header .sec-sub { font-size: 12px; color: var(--text2); }
.section-header .sec-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.sec-badge.override { background: rgba(249,115,22,0.15); color: var(--accent); border: 1px solid rgba(249,115,22,0.3); }
.sec-badge.default { background: var(--surface2); color: var(--text3); }

.section-body { display: none; padding: 16px 20px; border-top: 1px solid var(--border); }
.section-body.open { display: block; }

/* Block Editor */
.block-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.block-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.block-type-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 2px;
}
.type-text { background: rgba(59,130,246,0.15); color: #60a5fa; }
.type-card { background: rgba(249,115,22,0.15); color: var(--accent); }
.type-info { background: rgba(34,197,94,0.15); color: #4ade80; }
.type-table { background: rgba(168,85,247,0.15); color: #c084fc; }

.block-content { flex: 1; }
.block-preview { font-size: 13px; color: var(--text2); line-height: 1.5; }

.block-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Quiz editor */
.quiz-q-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

.quiz-q-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.quiz-q-item .q-num {
  font-size: 11px;
  color: var(--text3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.quiz-q-item .q-text { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.quiz-q-item .q-options { display: flex; flex-direction: column; gap: 6px; }
.quiz-q-item .q-opt {
  font-size: 13px;
  color: var(--text2);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface2);
  display: flex;
  gap: 8px;
}
.quiz-q-item .q-opt.correct { background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.quiz-q-item .q-actions { margin-top: 12px; display: flex; gap: 8px; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-select option { background: var(--surface2); }

/* Options Editor */
.options-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.option-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.option-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text2);
}
.option-correct { color: var(--success) !important; background: rgba(34,197,94,0.15) !important; }
.option-correct-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text3);
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.option-correct-btn.active { border-color: var(--success); color: var(--success); background: rgba(34,197,94,0.1); }

/* Day Tabs */
.day-tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; width: fit-content; }
.day-tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.day-tab.active { background: var(--accent); color: #fff; }

/* Export */
.export-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.export-info h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.export-info p { font-size: 13px; color: var(--text2); }

/* Settings */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.settings-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-label h4 { font-size: 14px; font-weight: 500; }
.settings-label p { font-size: 12px; color: var(--text2); }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 999;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-left: 3px solid var(--success); }
#toast.error { border-left: 3px solid var(--danger); }
#toast.info { border-left: 3px solid var(--accent2); }

/* Responsive */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Utility */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text2); }
.font-bold { font-weight: 700; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
