/* ── DTM Quiz – Global Styles ── */
:root {
  --primary:  #009583;
  --dark:     #02311d;
  --light:    #e6f4f2;
  --primary10: rgba(0,149,131,.10);
  --primary18: rgba(0,149,131,.18);
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: #f8fffe; color: #1a1a2e; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

/* ── Layout ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 240px; min-width: 240px; height: 100vh; overflow-y: auto;
  background: #fff; border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
  transition: transform .3s ease;
}
.sidebar-logo {
  padding: 20px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #f0f0f0;
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .logo-text { font-size: 17px; font-weight: 800; color: var(--dark); }

.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase;
             letter-spacing: .8px; color: #9ca3af; padding: 8px 8px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  text-decoration: none; color: #4b5563; font-size: 13.5px; font-weight: 500;
  transition: all .2s ease; cursor: pointer;
}
.nav-item:hover  { background: var(--primary18); color: var(--primary); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active i { color: #fff !important; }
.nav-item i { width: 18px; text-align: center; font-size: 14px; color: #9ca3af; }
.nav-item.active i, .nav-item:hover i { color: inherit; }

/* Main content */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.topbar { padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.content-area { padding: 24px; flex: 1; }

/* ── Cards ── */
.card {
  background: #fff; border-radius: 16px; border: 1px solid #f0f0f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: all .22s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,149,131,.10); }
.card-header { padding: 18px 20px; border-bottom: 1px solid #f5f5f5; display: flex; align-items: center; justify-content: space-between; }
.card-body   { padding: 20px; }

/* ── Stat cards ── */
.stat-card { padding: 20px; border-radius: 16px; border: 1px solid #f0f0f0; background: #fff; }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--dark); margin-top: 12px; }
.stat-card .stat-label { font-size: 12px; color: #6b7280; font-weight: 500; margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none; transition: all .15s ease;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-outline   { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--light); }
.btn-danger    { background: #fee2e2; color: #dc2626; border: none; }
.btn-danger:hover  { background: #fca5a5; }
.btn-ghost     { background: transparent; color: #6b7280; border: 1px solid #e5e7eb; }
.btn-ghost:hover { background: #f9f9f9; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 13px 28px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ── Forms ── */
.form-input {
  width: 100%; padding: 11px 14px; font-size: 14px;
  border: 2px solid #e5e7eb; border-radius: 10px; outline: none;
  transition: border-color .2s; background: #fff; color: #111;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,149,131,.08); }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin-bottom: 6px; }
.form-group { margin-bottom: 16px; }
.form-select {
  width: 100%; padding: 11px 14px; font-size: 14px;
  border: 2px solid #e5e7eb; border-radius: 10px; outline: none;
  background: #fff; cursor: pointer; transition: border-color .2s;
}
.form-select:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Badge ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-primary{ background: var(--light); color: var(--primary); }

/* ── Toast ── */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  background: #fff; border-radius: 14px; padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 360px;
  pointer-events: all; transform: translateX(120%);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  font-size: 14px; border-left: 4px solid var(--primary);
}
.toast.show { transform: translateX(0); }
.toast.error   { border-left-color: #dc2626; }
.toast.warning { border-left-color: #f59e0b; }
.toast.info    { border-left-color: #3b82f6; }
.toast.success { border-left-color: var(--primary); }

/* ── Modal ── */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 50;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  width: 100%; max-width: 520px; padding: 32px;
  position: relative; animation: modal-in .25s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(.95) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #f3f4f6; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b7280; transition: background .15s;
}
.modal-close:hover { background: #e5e7eb; }

/* ── Quiz answer options ── */
.answer-opt {
  cursor: pointer; border: 2px solid #e5e7eb; border-radius: 12px;
  padding: 14px 18px; transition: all .15s;
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 500;
}
.answer-opt:hover:not(.disabled) { border-color: var(--primary); background: #f0fafa; }
.answer-opt.selected  { border-color: var(--primary); background: var(--primary); color: #fff; }
.answer-opt.correct   { border-color: #16a34a !important; background: #16a34a !important; color: #fff !important; }
.answer-opt.wrong     { border-color: #dc2626 !important; background: #dc2626 !important; color: #fff !important; }
.answer-opt.disabled  { cursor: not-allowed; }
.answer-letter {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.answer-opt.selected .answer-letter  { background: rgba(255,255,255,.25); color: #fff; }
.answer-opt.correct  .answer-letter  { background: rgba(255,255,255,.25); color: #fff; }
.answer-opt.wrong    .answer-letter  { background: rgba(255,255,255,.25); color: #fff; }

/* ── Question grid ── */
.q-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.q-grid-btn {
  width: 34px; height: 34px; border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s; border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.q-grid-btn.unanswered { background: #f3f4f6; color: #6b7280; }
.q-grid-btn.answered   { background: var(--primary); color: #fff; }
.q-grid-btn.current    { background: #fff; color: var(--primary); border-color: var(--primary); }
.q-grid-btn.correct-done { background: #16a34a; color: #fff; }
.q-grid-btn.wrong-done   { background: #dc2626; color: #fff; }

/* ── Toggle switch ── */
.toggle { position: relative; width: 42px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; cursor: pointer; inset: 0;
  background: #d1d5db; border-radius: 22px; transition: .3s;
}
.toggle-track::before {
  content: ''; position: absolute;
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .3s;
}
input:checked + .toggle-track { background: var(--primary); }
input:checked + .toggle-track::before { transform: translateX(20px); }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #9ca3af; border-bottom: 1px solid #f0f0f0; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f8f8f8; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fffe; }

/* ── Progress ── */
.progress-bar-wrap { height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .8s ease; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--primary); border-radius: 16px; padding: 40px 24px;
  text-align: center; transition: all .2s ease; cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over { background: var(--light); }

/* ── Alerts (flash messages) ── */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ── Plan cards ── */
.plan-card {
  border: 2px solid #e5e7eb; border-radius: 20px; padding: 28px 24px;
  transition: all .22s ease; cursor: pointer; position: relative; overflow: hidden;
}
.plan-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: 0 12px 32px rgba(0,149,131,.14); }
.plan-card.featured { border-color: var(--primary); background: linear-gradient(135deg, #f0fdfb 0%, #fff 100%); }
.plan-card .popular-badge {
  position: absolute; top: -1px; right: 20px;
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 0 0 10px 10px;
}

/* ── Animations ── */
.fade-in { animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.slide-in { animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }

/* ── Mobile sidebar overlay ── */
.mobile-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
}
.mobile-overlay.open { display: block; }

/* ── Ranking ── */
.rank-1 { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.rank-2 { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }
.rank-3 { background: linear-gradient(135deg, #fef0e0, #fed7aa); }

/* ── Timer ── */
.timer-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.timer-danger { color: #dc2626 !important; }
.timer-warning { color: #f59e0b !important; }

/* ── Shimmer ── */
.shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Admin sidebar ── */
.admin-sidebar { width: 220px; min-width: 220px; background: var(--dark); color: #fff; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; transition: transform .3s ease; }
.admin-menu-btn { display: none; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; border: none; background: transparent; cursor: pointer; font-size: 18px; color: #6b7280; }
.admin-menu-btn:hover { background: #f3f4f6; }
.admin-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.admin-overlay.open { display: block; }

/* ── Quiz take layout ── */
.quiz-layout { display: flex; height: calc(100vh - 56px); }
.quiz-side {
  width: 240px; min-width: 240px; background: #fff; border-left: 1px solid #e5e7eb;
  padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 8px; margin: 2px 8px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.75);
  text-decoration: none; transition: all .2s; cursor: pointer;
}
.admin-nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.admin-nav-item.active { background: var(--primary); color: #fff; }
.admin-nav-item i { width: 16px; text-align: center; }

/* ── Responsive ── */
body { overflow-x: hidden; }
.flex-1 { flex: 1; }

/* Collapse multi-column app grids on tablets */
@media (max-width: 900px) {
  div[style*="grid-template-columns:1fr 340px"],
  div[style*="grid-template-columns:1fr 380px"],
  div[style*="grid-template-columns:1fr 360px"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns:320px 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 45; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .content-area { padding: 16px; }
  .topbar { padding: 0 16px; }

  /* Admin sidebar off-canvas */
  .admin-sidebar { position: fixed; left: 0; top: 0; z-index: 45; transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-menu-btn { display: inline-flex; }

  /* Collapse 2-col grids/forms to single column */
  div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* Horizontal scroll for wide tables */
  .card-body[style*="padding:0"] { overflow-x: auto; }

  /* Quiz take page stacks on mobile */
  .quiz-layout { flex-direction: column; height: auto !important; overflow: visible !important; }
  .quiz-main { padding: 16px !important; }
  .quiz-side {
    width: 100% !important; min-width: 0 !important;
    border-left: none !important; border-top: 1px solid #e5e7eb;
  }
  .quiz-progress { display: none; }
  .quiz-page-body { overflow-y: auto !important; }
}

@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .auth-page { padding: 14px; }
  .hero { padding: 56px 16px; }
  .hero p { font-size: 16px; }
  .landing-nav { flex-wrap: wrap; height: auto !important; padding: 10px 16px !important; gap: 8px !important; }
  .landing-actions { gap: 6px !important; }
  .landing-actions .btn { padding: 6px 10px; font-size: 11px; }
  .topbar-actions .show-md { display: none !important; }
  .data-table { font-size: 12.5px; }
  .data-table th { padding: 8px 10px; }
  .data-table td { padding: 10px 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .modal { padding: 22px 18px; }
  .toast-wrap { top: 12px; right: 12px; left: 12px; }
  .toast { min-width: 0; max-width: 100%; }
}

/* ── Auth pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--light) 0%, #fff 60%); padding: 24px; }
.auth-card { background: #fff; border-radius: 24px; box-shadow: 0 20px 60px rgba(0,149,131,.12); padding: 40px; width: 100%; max-width: 420px; }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }

/* ── Landing page ── */
.hero { background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 100%); color: #fff; padding: 80px 24px; text-align: center; }
.hero h1 { font-size: clamp(28px, 5vw, 56px); font-weight: 900; line-height: 1.1; margin-bottom: 20px; }
.hero p  { font-size: 18px; opacity: .85; max-width: 600px; margin: 0 auto 36px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.feature-card { background: #fff; border-radius: 16px; padding: 24px; border: 1px solid #f0f0f0; transition: all .22s ease; }
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,149,131,.1); }

/* ── Notification dot ── */
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; position: absolute; top: -2px; right: -2px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.notif-dot.pulse { animation: pulse 2s infinite; }

/* ── Score circle ── */
.score-circle {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; background: conic-gradient(var(--primary) var(--pct, 0%), #f3f4f6 0%);
  box-shadow: 0 0 0 8px #fff, 0 0 0 10px var(--light);
}
.score-inner { width: 90px; height: 90px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--light); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 32px; color: var(--primary); }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; }
.page-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid #e5e7eb; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; color: #4b5563; transition: all .15s; }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
