/* ============================================================
   LAYOUT & CONTAINER
   ============================================================ */
.sidebar {
  width: 260px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, border-right 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 var(--sidebar-divider); }
.sidebar-logo h1 { font-weight: 700; font-size: 20px; color: var(--sidebar-logo-text); letter-spacing: -0.02em; }
.sidebar-logo h1 span { color: var(--indigo); }
.sidebar-logo p { font-size: 11px; color: var(--sidebar-logo-sub); margin-top: 4px; letter-spacing: 0.03em; }

.nav-section { padding: 16px 12px; flex: 1; }
.nav-label { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sidebar-label); 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: var(--sidebar-hover-bg); color: var(--sidebar-active-text); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--indigo);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { 
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; 
  height: 22px; 
  flex-shrink: 0; 
}
.nav-svg-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* Sidebar Account Block */
.sidebar-account {
  padding: 0 24px 20px;
}
.sidebar-account-label {
  font-size: 10px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
[data-theme="dark"] .sidebar-account-label {
  color: rgba(148, 163, 184, 0.5);
}
.sidebar-session {
  font-size: 13px;
  font-weight: 700;
  color: var(--amber);
}
.sidebar-email {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .sidebar-email {
  color: rgba(148, 163, 184, 0.7);
}

/* 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: var(--sidebar-hover-bg);
  border: 1px solid var(--sidebar-border); cursor: pointer; color: var(--sidebar-text);
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.dark-toggle:hover { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.dark-toggle-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.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 (Mobile & Tablet)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
  justify-content: space-around;
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(15, 23, 42, 0.94);
  border-top: 1px solid var(--sidebar-border);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

.bnav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Be Vietnam Pro', sans-serif;
  padding: 4px 14px;
  border-radius: 14px;
  flex: 1;
  max-width: 110px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bnav-btn:active {
  transform: scale(0.92);
}

/* Active indicator — top pill bar */
.bnav-btn.active::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--indigo);
  border-radius: 0 0 4px 4px;
}

[data-theme="dark"] .bnav-btn.active::before {
  background: #38bdf8;
}

.bnav-btn .bnav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 20px;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  color: var(--text-secondary);
}

.bnav-svg-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.2s ease;
}

.bnav-btn .bnav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  line-height: 1.1;
  white-space: nowrap;
}

/* Active State */
.bnav-btn.active {
  color: var(--indigo);
}

.bnav-btn.active .bnav-icon-wrap {
  background: var(--indigo-dim);
  color: var(--indigo);
  box-shadow: 0 2px 8px -1px rgba(37, 99, 235, 0.22);
}

[data-theme="dark"] .bnav-btn.active .bnav-icon-wrap {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  box-shadow: 0 2px 10px -1px rgba(56, 189, 248, 0.3);
}

.bnav-btn.active .bnav-svg-icon {
  stroke-width: 2.5;
  transform: scale(1.05);
}

.bnav-btn.active .bnav-label {
  color: var(--indigo);
  font-weight: 800;
}

[data-theme="dark"] .bnav-btn.active .bnav-label {
  color: #38bdf8;
}

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

/* ============================================================
   TAB PANES & WELCOME CARD
   ============================================================ */
.tab-pane { display: none; }
.tab-pane.active {
  display: block;
  animation: tabFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-card {
  max-width: 600px;
  margin: 80px auto;
  padding: 40px;
  text-align: center;
  background: var(--surface);
  border-radius: 32px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}
.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
  line-height: 1;
}
.welcome-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 14px;
  color: var(--text-primary);
  font-family: 'Be Vietnam Pro', sans-serif;
}
.welcome-desc {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
  font-size: 15px;
}
.welcome-actions {
  display: grid;
  gap: 12px;
}

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

.page-header {
  padding: 24px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}
.page-header h2 { font-weight: 700; font-size: 24px; letter-spacing: -0.025em; 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 16px;
}

/* Soft/Pastel stat cards — Dashboard */
.stat-card {
  border-radius: 20px;
  padding: 20px 14px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px -2px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
  transition: all 0.25s ease;
  text-align: center;
}
[data-theme="dark"] .stat-card {
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.25);
}
.stat-card.sc-indigo { background: var(--indigo-dim); border-color: rgba(37, 99, 235, 0.18); }
.stat-card.sc-green  { background: var(--green-dim);  border-color: rgba(16, 185, 129, 0.18); }
.stat-card.sc-red    { background: var(--red-dim);    border-color: rgba(239, 68, 68, 0.18); }
.stat-card.sc-teal   { background: var(--teal-dim);   border-color: rgba(13, 148, 136, 0.18); }

.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: var(--green); }
.stat-card.sc-red    .sc-label { color: var(--red); }
.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 32px;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.dash-cta-btn {
  width: 100%; padding: 15px 24px;
  background: linear-gradient(135deg, var(--indigo), #0ea5e9);
  color: white; border: none; border-radius: 16px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.35);
  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 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 2px 10px -2px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
  transition: all 0.25s ease;
  min-width: 0; /* Critical for grid shrinking */
  overflow: hidden;
}
[data-theme="dark"] .chart-card {
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.25);
}
.chart-card h3 { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--text-primary); margin-bottom: 4px; }

/* ============================================================
   ZERO / ONBOARDING STATE
   ============================================================ */
.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;
  }
}

/* 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; }
}

@media (max-width: 480px) {
  .stat-grid {
    gap: 10px;
    padding: 0 0 12px;
  }
  .stat-card {
    padding: 16px 10px;
    border-radius: 16px;
  }
  .stat-card .sc-val {
    font-size: 26px;
  }
  .stat-card .sc-label {
    font-size: 10px;
    letter-spacing: 0.05em;
  }
}

/* ============================================================
   SHARED UTILITIES & SKELETON
   ============================================================ */
.mt-20 { margin-top: 20px; }
.bg-indigo { background: var(--indigo); }
.bg-red { background: var(--red); border-color: var(--red); }

/* Dashboard Skeleton Loader Classes */
.sk-title { width: 180px; height: 28px; border-radius: 6px; margin-bottom: 8px; }
.sk-sub { width: 280px; height: 16px; border-radius: 6px; }
.sk-stat-card { background: var(--surface); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.sk-stat-label { width: 70%; height: 12px; margin-bottom: 10px; border-radius: 4px; }
.sk-stat-val { width: 40%; height: 28px; border-radius: 6px; }
.sk-chart-card { padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.sk-chart-title { width: 140px; height: 20px; border-radius: 4px; margin-bottom: 8px; }
.sk-chart-sub { width: 200px; height: 12px; border-radius: 4px; margin-bottom: 24px; }
.sk-chart-donut { width: 150px; height: 150px; border-radius: 50%; margin: 20px auto; }
.sk-chart-bar { width: 100%; height: 150px; border-radius: 8px; margin: 20px auto; }

/* Dashboard Main Components */
.dash-greeting { color: var(--indigo); font-weight: 700; font-size: 23px; letter-spacing: -0.02em; }
.dash-sub { color: var(--text-secondary); margin-top: 4px; font-size: 14px; }

.emergency-reload {
  margin: 0 0 20px;
  padding: 20px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid var(--red);
  border-radius: 16px;
  text-align: center;
}
.emergency-reload-title { font-size: 14px; color: var(--red); margin-bottom: 12px; font-weight: 600; }
.emergency-reload-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.emergency-reload-btn { background: var(--red) !important; border-color: var(--red) !important; }

.chart-canvas-wrap {
  height: 220px;
  position: relative;
}

.recent-history-link-wrap {
  text-align: center;
  padding: 20px 0 24px;
}

.btn-recent-history {
  border-radius: 99px;
  padding: 8px 20px;
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.04);
}
.btn-recent-history:hover {
  border-color: var(--indigo-light);
  transform: translateY(-1px);
}

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