/* =====================================================
   Dashboard CSS — AHS Survey Admin Dashboard
   Navy / Orange brand — Naresuan University AHS
   Supports light & dark mode via CSS custom props
   ===================================================== */

/* ── DARK MODE (default for dashboard) ── */
:root,
html[data-theme="dark"] {
  --navy:           #2d5281;
  --navy-dark:      #1e3a5f;
  --navy-deeper:    #0f2341;
  --orange:         #fb923c;
  --orange-dark:    #f97316;

  --bg-app:         #0a1628;
  --bg-sidebar:     #0d1527;
  --bg-header:      #0f1f3d;
  --card-bg:        #111c35;
  --card-bg-alt:    #0f1a30;
  --card-border:    #1e3a5f;
  --card-hover:     #1a2d50;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #4a6080;
  --border-color:   #1e3a5f;

  --accent-teal:    #fb923c;   /* orange replaces teal */
  --accent-glow:    rgba(251,146,60,0.25);

  --input-bg:       #0f1a30;
  --input-border:   #1e3a5f;
}

/* ── LIGHT MODE ── */
html[data-theme="light"] {
  --navy:           #1e3a5f;
  --navy-dark:      #0f2341;
  --navy-deeper:    #081830;
  --orange:         #f97316;
  --orange-dark:    #ea580c;

  --bg-app:         #f8fafc;
  --bg-sidebar:     #ffffff;
  --bg-header:      #1e3a5f;
  --card-bg:        #ffffff;
  --card-bg-alt:    #f1f5f9;
  --card-border:    #e2e8f0;
  --card-hover:     #f8fafc;

  --text-primary:   #0f172a;
  --text-secondary: #3d5270;
  --text-muted:     #7a92ad;
  --border-color:   #dde4ed;

  --accent-teal:    #f97316;
  --accent-glow:    rgba(249,115,22,0.2);

  --input-bg:       #ffffff;
  --input-border:   #dde4ed;
}

/* Light mode overrides for Tailwind utilities */
html[data-theme="light"] .hover\:text-white:hover {
  color: var(--orange-dark) !important;
}

/* ---- Login Modal ---- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.3s ease;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 1rem; padding: 2rem; width: 90%; max-width: 400px;
  animation: slideUp 0.4s ease;
}

/* ---- Header ---- */
.dashboard-header {
  background: linear-gradient(135deg, var(--navy-deeper) 0%, var(--navy-dark) 100%);
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, var(--navy), var(--orange), var(--navy-dark)) 1;
  position: sticky; top: 0; z-index: 40;
}

/* ── Light mode header stays navy ── */
html[data-theme="light"] .dashboard-header {
  background: linear-gradient(135deg, #0f2341 0%, #1e3a5f 100%);
  border-image: linear-gradient(90deg, #1e3a5f, var(--orange), #2d5281) 1;
}
html[data-theme="light"] .dashboard-header h1,
html[data-theme="light"] .dashboard-header p,
html[data-theme="light"] .dashboard-header a,
html[data-theme="light"] .dashboard-header span:not(#layoutModeIcon):not(#layoutModeLabel) {
  color: #ffffff !important;
}
/* theme-toggle-btn label — keep WHITE on the dark navy header in both modes */
html[data-theme="light"] .dashboard-header .theme-toggle-btn {
  color: #e2e8f0 !important;
}
html[data-theme="light"] .dashboard-header .theme-toggle-btn .theme-label,
html[data-theme="light"] .dashboard-header .theme-toggle-btn .theme-icon {
  color: #e2e8f0 !important;
}
/* Layout mode button icon and label in light mode */
html[data-theme="light"] #layoutModeIcon,
html[data-theme="light"] #layoutModeIcon svg {
  color: var(--text-secondary) !important;
  fill: var(--text-secondary) !important;
}
html[data-theme="light"] #layoutModeLabel {
  color: var(--text-secondary) !important;
}
html[data-theme="light"] #layoutModeToggle.compact-active #layoutModeIcon,
html[data-theme="light"] #layoutModeToggle.compact-active #layoutModeIcon svg {
  color: var(--orange) !important;
  fill: var(--orange) !important;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 260px; min-height: calc(100vh - 56px);
  background: var(--bg-sidebar); border-right: 1px solid var(--border-color);
  position: sticky; top: 56px; overflow-y: auto;
  transition: transform 0.3s ease, background 0.3s ease;
}
.nav-item {
  color: var(--text-secondary); background: transparent;
}
.nav-item:hover { background: var(--card-bg); color: var(--text-primary); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(30,58,95,0.4), rgba(249,115,22,0.12));
  color: var(--orange);
  border-left: 3px solid var(--orange);
}

/* ---- Chart Cards ---- */
.chart-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 0.75rem; padding: 1.25rem;
  transition: all 0.3s ease;
  animation: fadeInUp 0.5s ease both;
}

.admin-user-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-user-form input,
.admin-user-form select {
  min-width: 0;
  padding: 0.65rem 0.75rem;
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
}

.admin-users-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.admin-users-table th,
.admin-users-table td {
  padding: 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.admin-action {
  padding: 0.45rem 0.65rem;
  margin: 0.15rem;
  color: var(--text-primary);
  background: var(--card-bg-alt);
  border-radius: 0.4rem;
}

.admin-action.primary {
  background: var(--navy-dark);
  color: #f1f5f9;
}

.admin-action.danger {
  color: #fecaca;
  background: rgba(220, 38, 38, 0.35);
}

@media (max-width: 1024px) {
  .admin-user-form {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- Premium Filters ---- */
.filter-section-wrapper {
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.4));
  border-top: 1px solid var(--border-color);
}
.filter-label-premium {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.025em;
}
.filter-input-premium {
  width: 100%;
  padding: 0.65rem 0.875rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.8125rem;
  transition: all 0.2s ease-in-out;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  appearance: none;
}
.filter-input-premium:hover {
  border-color: rgba(20, 184, 166, 0.4);
  background: rgba(30, 41, 59, 0.8);
}
.filter-input-premium:focus {
  outline: none;
  border-color: rgba(20, 184, 166, 0.8);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
  background: var(--card-bg);
}
.filter-group-premium {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 0.75rem;
  padding: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.03);
}
.filter-clear-btn {
  width: 100%;
  padding: 0.75rem;
  background: rgba(51, 65, 85, 0.3);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  cursor: pointer;
}
.filter-clear-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.4);
  color: #f87171;
}

.chart-card:hover {
  border-color: var(--navy);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 0 12px var(--accent-glow);
}
.chart-card:nth-child(1) { animation-delay: 0.05s; }
.chart-card:nth-child(2) { animation-delay: 0.1s; }
.chart-card:nth-child(3) { animation-delay: 0.15s; }
.chart-card:nth-child(4) { animation-delay: 0.2s; }

.chart-title {
  font-size: 0.875rem; font-weight: 600; color: var(--text-primary);
  margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.kpi-tag {
  font-size: 0.625rem; background: rgba(249,115,22,0.18);
  color: var(--orange); padding: 0.125rem 0.5rem;
  border-radius: 9999px; font-weight: 500;
}

.chart-container { position: relative; width: 100%; height: 280px; overflow-y: auto; overflow-x: hidden; }
.chart-container-sm { height: 240px; }
.chart-container-lg { height: 380px; }
.chart-container-tall { height: 400px; }



/* ---- Gauge Overlay ---- */
.gauge-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gauge-overlay-text {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  line-height: 1.2;
  z-index: 5;
}
.gauge-main-score {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}
.gauge-sub-score {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}
.gauge-wrapper-sm .gauge-overlay-text,
.gauge-overlay-sm { bottom: 12px; }
.gauge-score-sm { font-size: 1.25rem; }

/* ---- NPS Card ---- */
.nps-card .nps-bar {
  height: 8px; border-radius: 4px; transition: width 0.6s ease;
}

/* ---- Loading Spinner ---- */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-color); border-top-color: var(--orange);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ---- Feedback List ---- */
.feedback-item {
  background: var(--card-bg-alt); border: 1px solid var(--card-border);
  border-radius: 0.5rem; padding: 0.75rem;
}
.feedback-item .service-tag {
  font-size: 0.625rem; padding: 0.125rem 0.5rem;
  border-radius: 9999px; font-weight: 500;
}
.service-tag.fitness { background: rgba(245,158,11,0.2); color: #fbbf24; }
.service-tag.hydro { background: rgba(6,182,212,0.2); color: #22d3ee; }
.service-tag.pt { background: rgba(30,58,95,0.3); color: #93c5fd; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb { background: var(--navy); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--orange); }

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Layout & Sidebar ---- */
.dashboard-header {
  background: var(--card-bg); border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 40;
}

.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    height: calc(100vh - 56px);
    z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

.sidebar-backdrop {
  position: fixed; inset: 0; top: 56px;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 40; transition: opacity 0.3s ease;
}

@media (max-width: 640px) {
  .chart-container { height: 220px; }
  .chart-container-tall { height: 320px; }
}

/* ---- KPI Overview Section ---- */
[id^="kpi-section-"] {
  scroll-margin-top: 80px;
}

.kpi-score-display {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin: 0.5rem 0;
  line-height: 1;
}
.kpi-progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(30,58,95,0.3);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.75rem;
}
.kpi-progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease, background 0.4s ease;
  background: linear-gradient(90deg, var(--navy), var(--orange));
}

/* ---- Filter date inputs ---- */
.filter-select[type="date"] {
  color-scheme: dark;
}
html[data-theme="light"] .filter-select[type="date"] {
  color-scheme: light;
}

/* ---- Sidebar filter selects ---- */
.filter-select {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}

/* ---- KPI Service Filter Buttons ---- */
.kpi-svc-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(30, 58, 95, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.kpi-svc-btn:hover {
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange);
  border-color: rgba(249, 115, 22, 0.35);
}
.kpi-svc-btn.active {
  background: linear-gradient(135deg, rgba(30,58,95,0.4), rgba(249,115,22,0.2));
  color: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ---- Light mode body ---- */
html[data-theme="light"] body {
  background-color: var(--bg-app);
  color: var(--text-primary);
}

html[data-theme="light"] .chart-title,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3 {
  color: var(--text-primary);
}

html[data-theme="light"] .chart-card {
  box-shadow: 0 2px 12px rgba(30,58,95,0.08);
}

html[data-theme="light"] .nav-item {
  color: var(--text-secondary);
}

html[data-theme="light"] .nav-item:hover {
  background: var(--card-border);
  color: var(--navy-dark);
}

html[data-theme="light"] .nav-item.active {
  background: linear-gradient(135deg, rgba(30,58,95,0.1), rgba(249,115,22,0.08));
  color: var(--navy-dark);
  border-left: 3px solid var(--navy-dark);
}

/* =====================================================================
   LIGHT MODE — DASHBOARD TEXT CONTRAST
   Dashboard HTML uses hardcoded Tailwind: text-gray-200, text-gray-400
   text-gray-500, text-white, etc. Override all to readable dark colors
   ===================================================================== */

/* ── General text on light bg ── */
html[data-theme="light"] .text-gray-200,
html[data-theme="light"] .text-gray-300,
html[data-theme="light"] .text-gray-400,
html[data-theme="light"] .text-gray-500,
html[data-theme="light"] .text-white {
  color: var(--text-secondary) !important;
}

/* ── Except for Header and specific buttons where text should remain white ── */
html[data-theme="light"] .dashboard-header .text-white,
html[data-theme="light"] .dashboard-header .text-gray-400,
html[data-theme="light"] .dashboard-header .text-gray-300,
html[data-theme="light"] button.btn-muted-red,
html[data-theme="light"] button.bg-emerald-600 {
  color: #ffffff !important;
}

html[data-theme="light"] #clearAllFiltersBtn {
  color: #ffffff !important;
  background-color: #3d5270 !important;
}

/* ── Teal accent text → orange in light mode ── */
html[data-theme="light"] .text-teal-300,
html[data-theme="light"] .text-teal-400,
html[data-theme="light"] [class*="text-teal"] {
  color: var(--navy-dark) !important;
}

html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] [class*="text-emerald"] {
  color: #1e5c38 !important;
}

/* ── KPI score numbers ── */
html[data-theme="light"] .kpi-score-display {
  color: var(--navy-dark) !important;
}

/* ── Section title headings ── */
html[data-theme="light"] h1, html[data-theme="light"] h2 {
  color: var(--text-primary) !important;
}
html[data-theme="light"] h3 { color: var(--text-primary) !important; }
html[data-theme="light"] p  { color: var(--text-secondary) !important; }

/* ── Filter sidebar labels & inputs ── */
html[data-theme="light"] label { color: var(--text-secondary) !important; }
html[data-theme="light"] select,
html[data-theme="light"] input[type="date"],
html[data-theme="light"] .filter-select {
  color: var(--navy-dark) !important;
  background-color: #ffffff !important;
  border-color: #dde4ed !important;
}

/* ── Clear specific service filter button ── */
html[data-theme="light"] #clearServiceFilterBtn {
  color: var(--orange-dark) !important;
}
html[data-theme="light"] #serviceFilterStatus {
  background: rgba(249,115,22,0.1) !important;
  border-color: rgba(249,115,22,0.2) !important;
}
html[data-theme="light"] #serviceFilterStatus p {
  color: var(--navy-dark) !important;
}
/* ── Body background (overrides Tailwind bg-[#0f172a]) ── */
html[data-theme="light"] body {
  background-color: var(--bg-app) !important;
}

/* ── Sidebar ── */
html[data-theme="light"] .sidebar {
  background: var(--bg-sidebar) !important;
  border-color: var(--border-color) !important;
}

/* ── Chart cards: crisp on light bg ── */
html[data-theme="light"] .chart-card {
  background: var(--card-bg) !important;
  border-color: var(--card-border) !important;
  box-shadow: 0 2px 16px rgba(30,58,95,0.10), 0 1px 4px rgba(0,0,0,0.05);
}

/* ── Table rows ── */
html[data-theme="light"] .admin-users-table th {
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}
html[data-theme="light"] .admin-users-table td {
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

/* ── Feedback items ── */
html[data-theme="light"] .feedback-item {
  background: var(--card-bg-alt) !important;
  border-color: var(--card-border) !important;
}
html[data-theme="light"] .service-tag.fitness { background: #fef3c7 !important; color: #b45309 !important; }
html[data-theme="light"] .service-tag.hydro { background: #cffafe !important; color: #0e7490 !important; }
html[data-theme="light"] .service-tag.pt { background: #dbeafe !important; color: #1d4ed8 !important; }


/* ── Gauge score number ── */
html[data-theme="light"] .gauge-main-score {
  color: var(--navy-dark) !important;
}
html[data-theme="light"] .gauge-sub-score {
  color: var(--text-secondary) !important;
}

/* ── Accent badge labels (NPS breakdown etc) ── */
html[data-theme="light"] .text-green-400 {
  color: #15803d !important;
}
html[data-theme="light"] .text-red-400 {
  color: #b91c1c !important;
}
html[data-theme="light"] .text-purple-400 {
  color: #6d28d9 !important;
}
html[data-theme="light"] .text-amber-400 {
  color: #92400e !important;
}
html[data-theme="light"] .text-cyan-400 {
  color: #155e75 !important;
}

/* ── kpi-tag badge ── */
html[data-theme="light"] .kpi-tag {
  background: rgba(249,115,22,0.12);
  color: var(--orange-dark) !important;
}

/* ── Scrollbar overrides ── */
html[data-theme="light"] ::-webkit-scrollbar-track {
  background: rgba(30,58,95,0.05);
}
html[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(30,58,95,0.2);
}
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(249,115,22,0.35);
}

/* ── KPI Service Filter Bar (Keep text light on dark background) ── */
html[data-theme="light"] #kpi-filter-bar .text-gray-400 {
  color: #94a3b8 !important; /* light gray for labels */
}
html[data-theme="light"] .kpi-svc-btn {
  color: #f1f5f9 !important; /* light white for unselected buttons */
}
html[data-theme="light"] .kpi-svc-btn.active {
  color: var(--orange-dark) !important;
}

/* ── Custom Button Colors ── */
.btn-muted-red {
  background-color: #9f1239; /* rose-800 */
}
.btn-muted-red:hover {
  background-color: #be123c; /* rose-700 */
}

/* ══════════════════════════════════════════════════
   @media print — Native Browser Print / Save as PDF
   ══════════════════════════════════════════════════ */
@media print {
  /* Force A4 portrait */
  @page {
    size: A4 portrait;
    margin: 12mm 10mm;
  }

  /* Hide everything UI-related */
  header, aside, #export-buttons-container,
  #kpi-filter-bar, #loadingSpinner,
  #sidebarBackdrop, #dataset-admin-users,
  .kpi-svc-btn, #serviceFilterStatus,
  button, nav {
    display: none !important;
  }

  /* Show the print header */
  #pdf-report-header {
    display: block !important;
  }

  /* Reset body & layout */
  html, body {
    background: #ffffff !important;
    color: #1e293b !important;
    font-family: 'Noto Sans Thai', 'Inter', sans-serif !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Make the layout flat (no sidebar flex) */
  body > div, .flex, #app-wrapper {
    display: block !important;
  }

  main {
    background: #ffffff !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  /* Show all datasets */
  .dataset-container {
    display: block !important;
    page-break-before: always;
    break-before: page;
    page-break-inside: auto;
    break-inside: auto;
    margin-bottom: 0 !important;
  }

  /* First section — no page break before */
  #dataset-demographics {
    page-break-before: auto !important;
    break-before: auto !important;
    margin-top: 20px !important;
  }

  /* Section headings */
  .dataset-container h2 {
    color: #0f172a !important;
    font-size: 14pt;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
  }

  /* Chart cards */
  .chart-card {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
    color: #1e293b !important;
  }

  .chart-title {
    color: #334155 !important;
  }

  /* Grid: always 2-col in print */
  .grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* KPI cards */
  .kpi-score-display, .kpi-tag {
    color: #1e293b !important;
  }

  /* Feedback list — hide in print */
  .feedback-list {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Canvas must be visible */
  canvas {
    max-width: 100%;
  }
}

/* ---- Animations & Tab Transitions ---- */
.dataset-container {
  display: none;
}
.dataset-container.active {
  display: block;
  animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInScale {
  0% { opacity: 0; transform: translateY(10px) scale(0.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Skeleton Loader ---- */
.skeleton-loading {
  position: relative;
  overflow: hidden;
  background-color: var(--card-bg-alt);
  border-radius: 0.5rem;
}
.skeleton-loading::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.05) 20%,
    rgba(255, 255, 255, 0.1) 60%,
    rgba(255, 255, 255, 0)
  );
  animation: shimmer 2s infinite;
}
[data-theme="light"] .skeleton-loading::after {
  background-image: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0.02) 20%,
    rgba(0, 0, 0, 0.04) 60%,
    rgba(0, 0, 0, 0)
  );
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Empty State */
.empty-state-card {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  background: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 1rem;
  color: var(--text-secondary);
  animation: fadeInUp 0.5s ease both;
}
.empty-state-card svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}
.empty-state-card.active {
  display: flex;
}

/* ====================================================
   DATE FILTER — 2-line layout
   ==================================================== */
.date-filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.date-filter-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 2.5rem;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.date-filter-row .filter-input-premium {
  flex: 1;
  min-width: 0;
}

/* ====================================================
   KPI SECTION HEADING — larger font
   ==================================================== */
.kpi-section-heading {
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.875rem;
  padding: 0.5rem 0.875rem;
  border-left: 3px solid currentColor;
  background: rgba(255,255,255,0.025);
  border-radius: 0 0.5rem 0.5rem 0;
}
html[data-theme="light"] .kpi-section-heading {
  background: rgba(0,0,0,0.03);
}


/* ====================================================
   LAYOUT MODE TOGGLE — compact / 2-column grid
   ==================================================== */

/* Compact mode: force all grids to 2-col */
body.layout-compact .dataset-container {
  max-width: 100%;
}
body.layout-compact .grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
/* Full-width items still span both cols */
body.layout-compact [class*="col-span-2"],
body.layout-compact [class*="xl:col-span-2"] {
  grid-column: span 2 !important;
}

/* Chart heights in compact mode — keep readable, not tiny */
body.layout-compact .chart-container {
  height: 260px !important;
}
body.layout-compact .chart-container-sm {
  height: 220px !important;
}
body.layout-compact .chart-container-lg {
  height: 300px !important;
}
body.layout-compact .chart-container-tall {
  height: 340px !important;
}

/* Compact mode: tighter padding on cards */
body.layout-compact .chart-card {
  padding: 0.875rem;
}
body.layout-compact .chart-title {
  font-size: 0.8rem;
  margin-bottom: 0.375rem;
}

/* Layout mode active button style */
#layoutModeToggle.compact-active {
  background: rgba(249,115,22,0.15) !important;
  border-color: rgba(249,115,22,0.4) !important;
  color: var(--orange, #fb923c) !important;
}

/* ====================================================
   WAIT TIME DISTRIBUTION TABLE
   ==================================================== */
.wait-dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.wait-dist-table thead tr {
  background: rgba(30, 58, 95, 0.35);
  border-bottom: 2px solid var(--border-color);
}
.wait-dist-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.wait-dist-table th:not(:first-child) {
  text-align: right;
}
.wait-dist-table th:last-child {
  text-align: left;
  padding-right: 1rem;
}
.wait-dist-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s ease;
}
.wait-dist-table tbody tr:hover {
  filter: brightness(1.12);
}
.wait-dist-table td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
  color: var(--text-primary);
}
html[data-theme="light"] .wait-dist-table thead tr {
  background: rgba(30, 58, 95, 0.08);
}
html[data-theme="light"] .wait-dist-table tbody tr {
  border-color: rgba(0,0,0,0.05);
}
html[data-theme="light"] .wait-dist-table td {
  color: var(--text-primary);
}

