/* Statistics Page Styles */
.stats-header {
    text-align: center;
    padding: 4rem 2rem 3rem;
    position: relative;
    overflow: hidden;
}

.stats-header h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stats-header .subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto 2rem;
}

/* Controls Section */
.stats-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 2rem auto;
    max-width: 1200px;
    padding: 0 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.control-group select,
.control-group input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin: 3rem auto;
    max-width: 1400px;
    padding: 0 2rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.chart-card h3 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 1rem;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem auto;
    max-width: 1200px;
    padding: 0 2rem;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.summary-card .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.summary-card .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.summary-card .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Export Button */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 2rem auto;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.3);
}

/* Data Export Section */
.data-export-section {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem auto;
    max-width: 1000px;
    text-align: center;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.data-export-section h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.export-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.export-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.export-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.export-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 1.2rem;
}

.export-status.success {
    color: #10b981;
}

.export-status.error {
    color: #ef4444;
}

.export-status.loading {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .stats-header h1 {
        font-size: 2.5rem;
    }

    .stats-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }

    .chart-card {
        padding: 1.5rem;
    }

    .chart-container {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .stats-header {
        padding: 3rem 1rem 2rem;
    }

    .stats-header h1 {
        font-size: 2rem;
    }

    .stats-controls {
        padding: 0 1rem;
    }

    .charts-grid,
    .summary-cards {
        padding: 0 1rem;
    }

    .summary-card {
        padding: 1rem;
    }

    .summary-card .value {
        font-size: 1.5rem;
    }

    .export-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .data-export-section {
        padding: 1.5rem;
        margin: 1rem;
    }

    .export-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .export-description {
        font-size: 0.8rem;
    }
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    color: var(--text-secondary);
}

.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-controls {
        flex-direction: column;
        align-items: center;
    }

    .stats-header h1 {
        font-size: 2.5rem;
    }
}


/* ============================


/* Improve text contrast slightly for readability */
.summary-card {
  color: #e5e7eb;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .summary-card {
    transition: none;
  }
}


.summary-card:focus-visible,
.spotlight-card:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 4px;
  transform: translateY(-2px);
}

/* Tablets */
@media (max-width: 768px) {
  .summary-cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    padding: 1.5rem;
    gap: 1.25rem;
  }

  .summary-card {
    padding: 1.25rem;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  .summary-card {
    padding: 1rem;
    border-radius: 10px;
  }

}

/* ============================
   THEME SYSTEM
   ============================ */

/* Theme Variables */
:root {
  /* Light Theme (Default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-navbar: rgba(255, 255, 255, 0.95);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-primary: #e5e7eb;
  --primary-color: #3b82f6;
  --secondary-color: #8b5cf6;
  --accent-color: #10b981;
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-navbar: rgba(15, 23, 42, 0.95);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-primary: #334155;
  --primary-color: #60a5fa;
  --secondary-color: #a78bfa;
  --accent-color: #34d399;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #60a5fa 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* Apply theme variables to body */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================
   THEME TOGGLE BUTTON STYLES
   ============================ */
.theme-toggle {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background-color: var(--primary-color);
  color: white;
  transform: rotate(15deg);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.theme-toggle:active {
  transform: scale(0.95) rotate(15deg);
}

/* Theme toggle animations */
.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
  transition: all 0.3s ease;
  position: absolute;
}

[data-theme="light"] .theme-toggle .moon-icon {
  opacity: 1;
  transform: rotate(0deg);
}

[data-theme="light"] .theme-toggle .sun-icon {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .theme-toggle .moon-icon {
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .theme-toggle .sun-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* ============================
   UPDATE EXISTING COMPONENTS WITH THEME VARIABLES
   ============================ */

/* Navbar */
.navbar {
  background-color: var(--bg-navbar);
  border-bottom: 1px solid var(--border-primary);
  backdrop-filter: blur(10px);
}

.nav-links a {
  color: var(--text-primary);
}

.nav-links a:hover {
  color: var(--primary-color);
}

/* Dropdown */
.dropdown-menu {
  background-color: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-lg);
}

.dropdown-menu a {
  color: var(--text-primary);
}

.dropdown-menu a:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Stats Header */
.stats-header h1 {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stats-header .subtitle {
  color: var(--text-secondary);
}

/* Chart Cards */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
}

.chart-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
}

.chart-card h3 {
  color: var(--text-primary);
}

/* Summary Cards */
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
}

.summary-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.summary-card .icon {
  color: var(--primary-color);
}

.summary-card .value {
  color: var(--text-primary);
}

.summary-card .label {
  color: var(--text-secondary);
}

/* Controls */
.control-group label {
  color: var(--text-primary);
}

.control-group select,
.control-group input {
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-primary);
}

.control-group select:focus,
.control-group input:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Data Export Section */
.data-export-section {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
}

.data-export-section h2 {
  color: var(--text-primary);
}

.export-description {
  color: var(--text-secondary);
}

/* Export Button */
.export-btn {
  background: var(--gradient-primary);
  color: white;
}

/* Animated Background Circles */
.circle {
  background: linear-gradient(135deg, var(--primary-color) 0%, rgba(59, 130, 246, 0.1) 100%);
}

/* ============================
   THEME TRANSITIONS
   ============================ */
* {
  transition: background-color 0.3s ease, 
              border-color 0.3s ease, 
              color 0.3s ease,
              box-shadow 0.3s ease;
}

/* Smooth theme switching for specific elements */
body,
.navbar,
.chart-card,
.summary-card,
.control-group select,
.control-group input {
  transition: background-color 0.3s ease, 
              border-color 0.3s ease, 
              color 0.3s ease,
              box-shadow 0.3s ease;
}

/* ============================
   PRINT STYLES
   ============================ */
@media print {
  .theme-toggle {
    display: none;
  }
  
  [data-theme="dark"] {
    --bg-primary: #ffffff;
    --text-primary: #000000;
  }
}