/* Urban Transit Analytics Dashboard - Optimized Styles */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 5px;
}

.header p {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Statistics Bar */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 200px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    border-left: 3px solid #667eea;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Controls Panel - Enhanced */
.controls-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

.controls-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
}

.reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: #e5e7eb;
    color: #374151;
    transform: translateY(-1px);
}

.reset-btn:active {
    transform: translateY(0);
}

.filter-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.preset-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.preset-btn:active, .preset-btn.active {
    transform: translateY(0);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-group label svg {
    color: #6b7280;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-group select:hover {
    border-color: #9ca3af;
}

.filter-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.875rem;
    color: #6b7280;
}

#filter-count {
    font-weight: 500;
}

#data-count {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    color: #374151;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid !important;
    grid-template-columns: 2fr 1fr 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 20px !important;
    margin-bottom: 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chart-container {
    background: white !important;
    border-radius: 8px !important;
    padding: 20px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    min-height: 300px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    position: relative !important;
}

.chart-container:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 1px solid #f0f2f5;
    padding-bottom: 8px;
}

.chart-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
}

#map-chart {
    grid-row: 1 / 3;
    min-height: 400px;
}

#bar-chart {
    grid-column: 2;
    grid-row: 1;
}

#line-chart {
    grid-column: 3;
    grid-row: 1;
}

/* Enhanced Tooltip Styles */
/* Animations and Transitions */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

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

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Enhanced Interactivity */
.bar.selected {
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.4));
}

.chart-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Performance Optimizations */
.chart-svg, .map-svg {
    will-change: transform;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    max-width: 250px;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border-width: 4px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* SVG Responsive Styling */
.chart-svg, .map-svg {
    width: 100%;
    height: 250px;
}

.map-svg {
    height: 350px;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    font-size: 0.9rem;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #667eea;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Chart SVG Styles */
.chart-svg {
    width: 100%;
    height: 350px;
}

.map-svg {
    width: 100%;
    height: 400px;
}

/* Interactive Chart Elements */
.bar {
    transition: fill 0.3s ease, opacity 0.3s ease;
}

.bar:hover {
    opacity: 0.8;
    cursor: pointer;
}

.bar.selected {
    stroke: #333;
    stroke-width: 2px;
}

.axis-label {
    font-size: 12px;
    font-weight: 500;
    fill: #666;
}

.grid-line {
    stroke: #e1e5e9;
    stroke-dasharray: 2,2;
}

/* SVG and Data Visualization Styles */
svg {
    background: white;
}

.data-point {
    cursor: pointer;
    transition: all 0.2s ease;
}

.data-point:hover {
    stroke: #333 !important;
    stroke-width: 2px !important;
}

.trend-line {
    stroke-width: 3px;
    fill: none;
    opacity: 0.8;
}

.route-bar {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.route-bar:hover {
    opacity: 1;
}

/* Enhanced Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Responsive Design - Enhanced */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 15px !important;
    }
    
    #map-chart {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
    
    .filters-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px !important;
        max-width: 100% !important;
    }
    
    .header h1 {
        font-size: 1.5rem !important;
    }
    
    .stats-bar {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .filters-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .filter-presets {
        justify-content: center !important;
    }
    
    .controls-header {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    .reset-btn {
        align-self: center !important;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }
    
    .filter-presets {
        flex-direction: column;
    }
    
    .preset-btn {
        width: 100%;
        text-align: center;
    }
}

/* Accessibility and Performance */
@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for keyboard navigation */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .data-point {
        stroke: currentColor;
        stroke-width: 1px;
    }
    
    .trend-line {
        stroke-width: 4px;
    }
    
    .bar {
        stroke: currentColor;
        stroke-width: 1px;
    }
}

/* Print styles */
@media print {
    .controls-panel {
        display: none;
    }
    
    .chart-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .header {
        background: #667eea !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
