/* ============================================================
   DESIGN TOKENS — Light & Dark
   ============================================================ */
:root {
  /* Typography Variables */
  --font-main: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sub:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'DM Mono', monospace;

  --navy:          #0f172a; /* Slate 900 */
  --indigo:        #2563eb; /* Royal blue primary */
  --indigo-hover:  #1d4ed8; 
  --indigo-dim:    #eff6ff; /* Soft blue-50 tint */
  --indigo-light:  rgba(37, 99, 235, 0.35); /* Subtle blue border hover token */
  --teal:          #0d9488; /* Accent teal */
  --teal-dim:      #f0fdfa;
  --amber:         #f59e0b;
  --amber-dim:     #fffbeb;
  --green:         #10b981;
  --green-dim:     #ecfdf5;
  --red:           #ef4444;
  --red-dim:       #fef2f2;

  /* Surface */
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --surface-2:     #f1f5f9;
  --border:        #e2e8f0;

  /* Text */
  --text-primary:  #1e293b;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  /* Chart & Analytics Tokens (Single Source of Truth) */
  --chart-acc:           #2563eb; /* % Chính xác - Royal Blue */
  --chart-prog:          #38bdf8; /* % Đã làm - Sky Blue */
  --chart-mastered:      #10b981; /* Thành thạo */
  --chart-learning:      #f59e0b; /* Đang học */
  --chart-weak:          #ef4444; /* Cần ôn */
  --chart-unlearned:     #e2e8f0; /* Chưa học */
  --chart-donut-border:  #ffffff;
  --chart-grid:          rgba(0, 0, 0, 0.06);
  --chart-tooltip-bg:    #ffffff;
  --chart-tooltip-text:  #0f172a;
  --chart-tooltip-border:rgba(0, 0, 0, 0.1);

  /* Sidebar Theme Variables */
  --sidebar-bg:          #1e293b; /* Premium slate sidebar background */
  --sidebar-text:        rgba(240, 246, 255, 0.75); /* Soft light blue/gray text */
  --sidebar-active-bg:   rgba(37, 99, 235, 0.15); /* Blue active pill */
  --sidebar-active-text: #60a5fa; /* Blue active text */
  --sidebar-hover-bg:    rgba(255, 255, 255, 0.04);
  --sidebar-divider:     rgba(240, 255, 255, 0.08);
  --sidebar-border:      rgba(30, 41, 59, 1);
  --sidebar-logo-text:   #f8fafc; /* Clean white-blue logo */
  --sidebar-logo-sub:    rgba(240, 246, 255, 0.5);
  --sidebar-label:       rgba(96, 165, 250, 0.5);
}

[data-theme="dark"] {
  --bg:            #0b1329; /* Slate-blue dark canvas */
  --surface:       #172036; /* Deep slate surface */
  --surface-2:     #232f48; /* Slate card surface */
  --border:        #2d3c5a; /* Smooth subtle border */
  --text-primary:  #f8fafc; /* Slate 50 */
  --text-secondary:#94a3b8; /* Slate 400 */
  --text-muted:    #64748b; /* Slate 500 */
  --indigo:        #38bdf8; /* Vibrant light blue accent in dark mode */
  --indigo-hover:  #60a5fa;
  --indigo-dim:    rgba(56, 189, 248, 0.12); /* Soft transparent tint */
  --indigo-light:  rgba(56, 189, 248, 0.35);
  --teal:          #2dd4bf;
  --teal-dim:      rgba(45, 212, 191, 0.12);
  --amber-dim:     rgba(245, 158, 11, 0.12);
  --green:         #34d399;
  --green-dim:     rgba(52, 211, 153, 0.12);
  --red:           #f87171;
  --red-dim:       rgba(248, 113, 113, 0.12);
  
  /* Chart & Analytics Tokens (Dark Mode) */
  --chart-acc:           #38bdf8; /* % Chính xác - Sky Blue */
  --chart-prog:          #60a5fa; /* % Đã làm - Soft Blue */
  --chart-mastered:      #34d399; /* Thành thạo */
  --chart-learning:      #f59e0b; /* Đang học */
  --chart-review:        #f87171; /* Cần ôn */
  --chart-unlearned:     #334155; /* Chưa học */
  --chart-donut-border:  #172036;
  --chart-grid:          rgba(255, 255, 255, 0.08);
  --chart-tooltip-bg:    #0f172a;
  --chart-tooltip-text:  #f8fafc;
  --chart-tooltip-border:rgba(255, 255, 255, 0.15);

  /* Dark Sidebar Theme Variables */
  --sidebar-bg:          #0b1329;
  --sidebar-text:        rgba(241, 245, 249, 0.75);
  --sidebar-active-bg:   rgba(56, 189, 248, 0.16);
  --sidebar-active-text: #38bdf8;
  --sidebar-hover-bg:    rgba(255, 255, 255, 0.05);
  --sidebar-divider:     rgba(241, 245, 249, 0.08);
  --sidebar-border:      #172036;
  --sidebar-logo-text:   #f8fafc;
  --sidebar-logo-sub:    rgba(241, 245, 249, 0.5);
  --sidebar-label:       rgba(56, 189, 248, 0.6);
}

/* Option letter styling */
.opt-letter {
  width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: var(--indigo); flex-shrink: 0;
  transition: all 0.15s;
}
.option-item:hover .opt-letter { background: var(--indigo); color: white; border-color: var(--indigo); }
.option-item.correct .opt-letter { background: var(--green); color: white; border-color: var(--green); }
.option-item.incorrect .opt-letter { background: var(--red); color: white; border-color: var(--red); }

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

/* GLOBAL SVG DEFAULT RESETS */
svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.setup-svg-icon {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  flex-shrink: 0;
}
.kc-svg-icon {
  width: 24px !important;
  height: 24px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body {
  font-family: var(--font-sub);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s, color 0.25s;
}

/* Typography Utility Classes */
.font-main { font-family: var(--font-main); }
.font-sub  { font-family: var(--font-sub); }
.font-mono { font-family: var(--font-mono); }

/* Desktop gets bigger base font */
@media (min-width: 1024px) { body { font-size: 16px; } }
@media (min-width: 1280px) { body { font-size: 17px; } }

h1, h2, h3, h4, h5 {
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: -0.025em; /* Thu hẹp khoảng cách chữ hiển thị chữ lớn trông gọn, sang trọng và thanh thoát */
  line-height: 1.3;
}

h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 21px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
h4 { font-size: 14px; font-weight: 600; }

/* ============================================================
   ZERO / ONBOARDING STATE (Core fallback)
   ============================================================ */
.dash-empty-wrap {
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.dash-empty-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 28px;
  padding: 36px 28px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 4px 24px -4px rgba(15, 23, 42, 0.04), 0 1px 4px rgba(15, 23, 42, 0.02);
  transition: all 0.25s ease;
}

[data-theme="dark"] .dash-empty-card {
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.3);
}

.dash-empty-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.dash-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 8px 24px -4px rgba(37, 99, 235, 0.2);
}

.dash-empty-badge {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--indigo);
  text-transform: uppercase;
  margin-bottom: 8px;
}

[data-theme="dark"] .dash-empty-badge {
  color: #38bdf8;
}

.dash-empty-title {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.dash-empty-sub {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 22px;
}

.dash-empty-benefit {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 20px;
  text-align: left;
  margin-bottom: 24px;
}

.dash-empty-benefit-title {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.dash-empty-benefit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 9px;
}

.dash-empty-benefit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.dash-empty-benefit-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--indigo);
  flex-shrink: 0;
}

[data-theme="dark"] .dash-empty-benefit-dot {
  background: #38bdf8;
}

.dash-empty-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 22px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: 14px;
  background: var(--indigo);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px -2px rgba(37, 99, 235, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.dash-empty-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -2px rgba(37, 99, 235, 0.4);
}

.dash-empty-cta-btn:active {
  transform: scale(0.98);
}

[data-theme="dark"] .dash-empty-cta-btn {
  background: #2563eb;
}

@media (max-width: 480px) {
  .dash-empty-card {
    padding: 28px 20px;
    border-radius: 24px;
  }
  .dash-empty-title {
    font-size: 19px;
  }
  .dash-empty-sub {
    font-size: 13px;
  }
  .dash-empty-cta-btn {
    padding: 13px 18px;
    font-size: 14px;
  }
}

/* SKELETON SHIMMER & PROGRESS EFFECTS */
.shimmer {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmerAnim 1.5s infinite linear;
}

@keyframes shimmerAnim {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes progressSweep {
  0% { left: -50%; width: 30%; }
  50% { left: 40%; width: 60%; }
  100% { left: 100%; width: 30%; }
}

.skeleton-item {
  height: 16px;
  border-radius: 6px;
  margin-bottom: 10px;
}

/* TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
  background: #1e293b; color: white; border-radius: 12px; font-size: 13px;
  opacity: 0; transform: translateY(16px); transition: all 0.3s; pointer-events: none; z-index: 11000;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 14px; font-family: 'Inter', sans-serif; font-weight: 700; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--indigo); color: white; padding: 14px 28px; font-size: 15px; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1.5px solid var(--border); padding: 11px 22px; }
.btn-danger { background: var(--red); color: white; padding: 12px 22px; font-size: 14.5px; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-outline-indigo { background: transparent; color: var(--indigo); border: 1.5px solid var(--indigo); padding: 11px 22px; }
.btn-outline-indigo:hover { background: rgba(2, 132, 199, 0.08); }
.btn-block { width: 100%; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ACCESSIBILITY HELPER (Screen Reader Only) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* SETTINGS ICON WRAPPER & PALETTES */
.settings-icon-wrap {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-svg-icon {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  display: block !important;
}

.icon-indigo-dim { background: #ebf3ff !important; color: #2563eb !important; }
.icon-purple-dim { background: #f3e8ff !important; color: #9333ea !important; }
.icon-rose-dim   { background: #ffe4e6 !important; color: #e11d48 !important; }
.icon-green-dim  { background: #dcfce7 !important; color: #10b981 !important; }
.icon-slate-dim  { background: #f1f5f9 !important; color: #64748b !important; }

[data-theme="dark"] .icon-indigo-dim { background: rgba(37, 99, 235, 0.22) !important; color: #60a5fa !important; }
[data-theme="dark"] .icon-purple-dim { background: rgba(147, 51, 234, 0.22) !important; color: #c084fc !important; }
[data-theme="dark"] .icon-rose-dim   { background: rgba(225, 29, 72, 0.22) !important; color: #fb7185 !important; }
[data-theme="dark"] .icon-green-dim  { background: rgba(16, 185, 129, 0.22) !important; color: #34d399 !important; }
[data-theme="dark"] .icon-slate-dim  { background: rgba(100, 116, 139, 0.28) !important; color: #94a3b8 !important; }
