/* ========== CSS VARIABLES ========== */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #475569;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --background: #E0ECF4;
  --surface: #1E293B;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --border-radius: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Base Styles ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(to right, #eef2f3, #dbe9f4);
  padding: 0;
  min-height: 100vh;
  color: #1e293b;
  overflow-x: hidden;
}

/* ========== HEADER & BOTTOM NAV STYLES REMOVED ========== */
/* Note: Header styles ab /components/header/header.css mein hain */
/* Note: Bottom Nav styles ab /components/bottomnav/bottomnav.css mein hain */
/* Note: Drawer menu styles ab /components/header/header.css mein hain */

/* ========== CONTROLS CONTAINER ========== */
.controls-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  background: #e7eff3;
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.custom-dropdown-wrapper {
  position: relative;
  min-width: 200px;
}

.custom-dropdown {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  background: white;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  font-weight: 500;
  color: #000000;
}

.custom-dropdown:hover,
.custom-dropdown:focus {
  border-color: var(--primary-color);
  outline: none;
}

.custom-dropdown::after {
  content: "▼";
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.custom-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  list-style: none;
}

.custom-dropdown-list li {
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
  color: #000000;
}

.custom-dropdown-list li:last-child {
  border-bottom: none;
}

.custom-dropdown-list li:hover {
  background-color: var(--surface);
  color: var(--primary-color);
}

/* ========== LOADING INDICATOR ========== */
#loadingIndicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--primary-color);
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error {
  color: var(--danger-color);
  font-weight: 500;
}

/* ========== MOBILE STATS MENU ========== */
.stats-mobile-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: none;
}

.stat-section {
  margin-bottom: 2rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #094758;
  margin-bottom: 1rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-color);
}

.section-title i {
  color: var(--primary-color);
}

.stat-mobile-tabs {
  list-style: none;
  display: grid;
  gap: 12px;
}

.stat-mobile-tabs button {
  width: 100%;
  padding: 16px;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
  font-weight: 500;
  color: #000;
}

.stat-mobile-tabs button:hover,
.stat-mobile-tabs button:focus {
  color: var(--primary-color);
  background-color: var(--surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-mobile-tabs button i {
  color: var(--primary-color);
  font-size: 1.1rem;
}

/* ========== DESKTOP STATS LAYOUT ========== */
.stats-layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  padding: 1rem;
  min-height: calc(100vh - 140px);
}

.stats-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #F3F5FA;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  height: fit-content;
  position: sticky;
  top: 80px;
}

.stats-sidebar .section-title {
  font-size: 1.1rem;
  margin: 1.5rem 1rem 1rem;
  padding-bottom: 8px;
}

.stats-sidebar .section-title:first-child {
  margin-top: 1rem;
}

.stat-tabs {
  list-style: none;
  margin-bottom: 1.5rem;
}

.stat-tabs button {
  width: 100%;
  padding: 12px 1rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: #000000;
  border-radius: 0;
}

.stat-tabs button:hover,
.stat-tabs button:focus {
  background-color: var(--surface);
  color: var(--primary-color);
}

.stat-tabs button i {
  font-size: 1rem;
  width: 16px;
}

/* ========== STATS CONTENT ========== */
.stats-content {
  flex: 1;
  background: #F3F5FA;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.stat-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.stat-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.table-container {
  overflow-x: auto;
  padding: 0;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.stat-table th {
  background: var(--surface);
  padding: 16px 12px;
  text-align: left;
  font-weight: 600;
  color: #ffffff;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.stat-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: #000000;
}

.stat-table tr:hover {
  background-color: #acb97a;
}

.stat-table .highlight {
  font-weight: 600;
  color: var(--primary-color);
}

.no-data {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-style: italic;
}

.no-data i {
  margin-right: 8px;
}

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  min-width: 32px;
}

.badge-primary {
  background-color: var(--primary-color);
  color: white;
}

.badge-success {
  background-color: var(--success-color);
  color: white;
}

.badge-warning {
  background-color: var(--warning-color);
  color: white;
}

/* ========== MOBILE STAT RESULT ========== */
.mobile-stat-result {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: none;
  position: relative;
  background: #E5EEF3;
  min-height: 100vh;
  margin-bottom: 80px;
}

.mobile-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.mobile-back-btn:hover {
  background-color: var(--primary-dark);
}

.mobile-stat-result .stat-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #1e293b;
}

.mobile-stat-result .table-container {
  background: white;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  margin-bottom: 80px;
}

/* =================== RESPONSIVE FIX =================== */
/* Desktop: footer sticks to bottom */
@media (min-width: 768px) {
  #footer-container {
    margin-top: auto;
  }
}

/* Mobile: footer sits above bottom nav */
@media (max-width: 767px) {
  #footer-container {
    margin-bottom: 55px;
  }
}

/* ========== RESPONSIVE DESIGN ========== */

/* Mobile (320px - 767px) */
@media (max-width: 767px) {
  body {
    font-size: 14px;
    background: #E2EDF4;
  }

  .controls-container {
    padding: 0.75rem;
  }

  .custom-dropdown-wrapper {
    min-width: 100%;
  }

  .custom-dropdown {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .stats-mobile-main {
    display: block;
    padding: 0.75rem;
    margin-bottom: 10px;
  }

  .stats-layout {
    display: none;
  }

  .mobile-stat-result {
    display: block;
    padding: 1rem;
    margin-bottom: 10px;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .stat-mobile-tabs {
    grid-template-columns: 1fr;
  }

  .stat-mobile-tabs button {
    padding: 14px;
    font-size: 0.9rem;
  }

  .stat-table {
    font-size: 0.85rem;
  }

  .stat-table th,
  .stat-table td {
    padding: 10px 8px;
  }

  .stat-title {
    font-size: 1.2rem;
  }
}

/* Tablet (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .stats-mobile-main {
    display: none;
  }

  .stats-layout {
    display: flex;
    padding: 1rem;
    gap: 1.5rem;
  }

  .stats-sidebar {
    width: 280px;
  }

  .stats-sidebar .section-title {
    font-size: 1rem;
  }

  .stat-tabs button {
    font-size: 0.9rem;
    padding: 10px 0.75rem;
  }

  .stat-table {
    font-size: 0.9rem;
  }

  .controls-container {
    padding: 1rem;
  }

  .custom-dropdown-wrapper {
    min-width: 250px;
  }
}

/* Desktop (1200px+) */
@media (min-width: 1200px) {
  .stats-mobile-main {
    display: none;
  }

  .stats-layout {
    display: flex;
  }

  .controls-container {
    padding: 1.5rem 1rem;
  }

  .stats-layout {
    padding: 1.5rem 1rem;
  }

  .stats-sidebar {
    width: 300px;
  }

  .stat-table th,
  .stat-table td {
    padding: 16px 14px;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .header-logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
  }
}

/* Focus Styles for Accessibility */
button:focus-visible,
a:focus-visible,
.custom-dropdown:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .header,
  .controls-container,
  .stats-sidebar,
  .bottom-nav,
  .mobile-back-btn {
    display: none !important;
  }

  .stats-content {
    border: none;
    box-shadow: none;
  }

  .stat-table {
    border: 1px solid #000;
  }

  .stat-table th,
  .stat-table td {
    border: 1px solid #000;
  }
}
