/* ============================================================
   LAYOUT & CONTAINER
   ============================================================ */
.sidebar {
  width: 260px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: background 0.25s;
}

.main-content {
  margin-left: 260px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.content-container {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 0 40px;
}

@media (max-width: 900px) {
  .content-container { padding: 0 20px; }
}

/* ============================================================
   SIDEBAR NAV
   ============================================================ */
.sidebar-logo { padding: 28px 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-logo h1 { font-weight: 900; font-size: 22px; color: white; letter-spacing: -0.3px; }
.sidebar-logo h1 span { color: #818cf8; }
.sidebar-logo p { font-size: 11px; color: var(--sidebar-text); margin-top: 4px; letter-spacing: 0.03em; }

.nav-section { padding: 16px 12px; flex: 1; }
.nav-label { font-size: 9px; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: rgba(255,255,255,0.3); padding: 6px 12px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px;
  border-radius: 10px; border: none; background: none;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer; transition: all 0.15s; text-align: left;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active {
  background: rgba(99,102,241,0.14);
  color: #a5b4fc;
  font-weight: 700;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: #818cf8;
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Dark Mode Toggle in sidebar */
.dark-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: none; cursor: pointer; color: rgba(255,255,255,0.6);
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  transition: background 0.15s;
}
.dark-toggle:hover { background: rgba(255,255,255,0.1); color: white; }
.toggle-pill {
  width: 36px; height: 20px; border-radius: 10px; background: #334155;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-pill::after {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform 0.2s;
}
[data-theme="dark"] .toggle-pill { background: var(--indigo); }
[data-theme="dark"] .toggle-pill::after { transform: translateX(16px); }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; z-index: 100;
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255,255,255,0.08);
  align-items: center; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bnav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.5); transition: color 0.15s;
  font-family: 'Inter', sans-serif; padding: 6px 20px;
}
.bnav-btn .bnav-icon { font-size: 19px; }
.bnav-btn .bnav-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.bnav-btn.active { color: #818cf8; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding-bottom: 68px; }
  .bottom-nav { display: flex; }
  .toast { bottom: 72px !important; }
}

/* ============================================================
   TAB PANES
   ============================================================ */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dash-wrap { max-width: 1200px; margin: 0 auto; width: 100%; }

.page-header {
  padding: 40px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}
.page-header h2 { font-weight: 800; font-size: 30px; color: var(--text-primary); }
.page-header p  { color: var(--text-secondary); margin-top: 4px; font-size: 14px; }

/* Stat grid: 4 columns desktop, 2 mobile */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 0 20px;
}

/* Soft/Pastel stat cards — Dashboard */
.stat-card {
  border-radius: 20px;
  padding: 22px 14px;
  border: 1px solid;
  transition: background 0.25s, border-color 0.25s;
  text-align: center;
}
.stat-card.sc-indigo { background: rgba(79,70,229,0.08); border-color: rgba(79,70,229,0.15); }
.stat-card.sc-green  { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.15); }
.stat-card.sc-red    { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.15); }
.stat-card.sc-teal   { background: rgba(13,148,136,0.08); border-color: rgba(13,148,136,0.15); }

[data-theme="dark"] .stat-card.sc-indigo { background: rgba(79,70,229,0.12); border-color: rgba(99,102,241,0.25); }
[data-theme="dark"] .stat-card.sc-green  { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.25); }
[data-theme="dark"] .stat-card.sc-red    { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.25); }
[data-theme="dark"] .stat-card.sc-teal   { background: rgba(13,148,136,0.12); border-color: rgba(13,148,136,0.25); }

.stat-card .sc-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px; }
.stat-card.sc-indigo .sc-label { color: var(--indigo); }
.stat-card.sc-green  .sc-label { color: #047857; }
.stat-card.sc-red    .sc-label { color: #b91c1c; }
.stat-card.sc-teal   .sc-label { color: var(--teal); }

.stat-card .sc-val { font-size: 32px; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1; }
.stat-card.sc-indigo .sc-val { color: var(--indigo); }
.stat-card.sc-green  .sc-val { color: var(--green); }
.stat-card.sc-red    .sc-val { color: var(--red); }
.stat-card.sc-teal   .sc-val { color: var(--teal); }

/* Dashboard "Luyện tập ngay" CTA button */
.dash-cta-wrap {
  padding: 0 0 36px;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.dash-cta-btn {
  width: 100%; padding: 15px 24px;
  background: linear-gradient(135deg, var(--indigo), #6366f1);
  color: white; border: none; border-radius: 16px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 800; font-size: 15px;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(79,70,229,0.3);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.dash-cta-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(79,70,229,0.4); }

/* Charts row: donut smaller, bar wider */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 0 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  transition: background 0.25s, border-color 0.25s;
  min-width: 0; /* Critical for grid shrinking */
  overflow: hidden;
}
.chart-card h3 { font-weight: 700; font-size: 15px; color: var(--text-primary); margin-bottom: 16px; }

/* Progress line chart (hidden by default) */
.line-chart-wrap {
  padding: 0 40px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .page-header { flex-direction: column; padding: 24px 0 0; margin-bottom: 20px; }
  .stat-grid   { grid-template-columns: 1fr 1fr; padding: 0 0 16px; }
  .charts-grid { grid-template-columns: 1fr; padding: 0 0 16px; }
}

/* ============================================================
   MODALS, OVERLAYS & SKELETON
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--surface); border-radius: 24px; width: 100%; max-width: 520px;
  padding: 32px; box-shadow: 0 10px 40px rgba(0,0,0,0.12); position: relative;
}

#app-skeleton {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
