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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0e27;
    color: #e0e0e0;
    overflow-x: hidden;
}

/* Dashboard Container */
.dashboard-container {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Header */
.dashboard-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #1a1f3a 0%, #2d3561 100%);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.dashboard-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: #a0aec0;
    font-size: 1em;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    flex: 1 1 auto;
}

/* Panels */
.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section Styles */
.filter-section,
.stats-section,
.chart-section,
.map-section,
.time-section {
    background: #1a1f3a;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Section Headers */
h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #ffffff;
    border-bottom: 2px solid #3d4463;
    padding-bottom: 10px;
}

/* Filter Group */
.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    color: #a0aec0;
    font-size: 0.9em;
    font-weight: 500;
}

/* Select Dropdowns */
.filter-select {
    width: 100%;
    padding: 10px 12px;
    background: #2d3561;
    border: 1px solid #3d4463;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:hover {
    border-color: #4a9eff;
    background: #333a6b;
}

.filter-select:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* Small Selects for Month Range */
.month-range {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-select-small {
    flex: 1;
    padding: 8px 10px;
    background: #2d3561;
    border: 1px solid #3d4463;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.9em;
    cursor: pointer;
}

.month-range span {
    color: #a0aec0;
    font-size: 0.9em;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 5px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    padding: 8px;
    background: #2d3561;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.checkbox-group label:hover {
    background: #333a6b;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Reset Button */
.reset-btn {
    width: 100%;
    padding: 12px;
    background: #4a9eff;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.reset-btn:hover {
    background: #3a8eef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

/* Statistics Cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-card {
    background: linear-gradient(135deg, #2d3561 0%, #3d4463 100%);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #3d4463;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.2);
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: #4a9eff;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.85em;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Charts */
.chart {
    min-height: 300px;
    background: #0f1329;
    border-radius: 8px;
    padding: 15px;
}

#time-series-chart {
    min-height: 250px;
}

#hourly-chart,
#weekday-chart {
    min-height: 200px;
}

/* Map */
#crime-map {
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
    background: #0f1329;
}

.map-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    padding: 10px;
    background: #0f1329;
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #a0aec0;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #2d3561;
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    margin-top: 20px;
    color: #a0aec0;
    font-size: 1.1em;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1f3a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #3d4463;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a9eff;
}

/* Author Section */
.author-section {
    margin-top: 24px;
    padding: 20px 0 24px;
    flex-shrink: 0;
    text-align: right;
}

.author-info {
    display: inline-block;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1a1f3a 0%, #252b4a 100%);
    border-radius: 10px;
    border: 1px solid #3d4463;
    max-width: 520px;
}

.author-name {
    display: block;
    font-size: 1.25em;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.author-bio {
    font-size: 0.9em;
    color: #a0aec0;
    line-height: 1.5;
    margin-bottom: 12px;
    max-width: 48ch;
    margin-left: auto;
}

.author-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px 10px;
}

.author-link {
    font-size: 0.9em;
    color: #4a9eff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.author-link:hover {
    color: #6eb3ff;
}

.author-sep {
    color: #3d4463;
    font-size: 0.85em;
    user-select: none;
}

/* Responsive Design */
/* Prevent grid overflow on all viewports */
.main-content {
    min-width: 0;
}

.left-panel,
.right-panel {
    min-width: 0;
}

.filter-section,
.stats-section,
.chart-section,
.map-section,
.time-section {
    min-width: 0;
}

.chart {
    overflow: hidden;
}

/* Large desktop */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: minmax(280px, 350px) 1fr;
    }
}

/* iPad landscape / small laptop */
@media (max-width: 1024px) {
    .dashboard-container {
        padding: 16px;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dashboard-header {
        padding: 16px;
        margin-bottom: 20px;
    }

    .dashboard-header h1 {
        font-size: 2em;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    #crime-map {
        height: 450px;
    }

    .map-legend {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }
}

/* iPad portrait / large phone */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 12px;
    }

    .dashboard-header {
        padding: 14px;
        margin-bottom: 16px;
    }

    .dashboard-header h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .filter-section,
    .stats-section,
    .chart-section,
    .map-section,
    .time-section {
        padding: 16px;
    }

    h3 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }

    .stat-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.6em;
    }

    .stat-label {
        font-size: 0.8em;
    }

    .checkbox-group {
        max-height: 220px;
    }

    #crime-map {
        height: 350px;
    }

    .map-legend {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .chart {
        min-height: 260px;
        padding: 12px;
    }

    #time-series-chart {
        min-height: 220px;
    }

    #hourly-chart,
    #weekday-chart {
        min-height: 180px;
    }

    .month-range {
        flex-wrap: wrap;
    }

    .author-section {
        text-align: center;
        margin-top: 20px;
        padding: 12px 0;
    }

    .author-info {
        width: 100%;
        max-width: 360px;
        text-align: center;
    }

    .author-bio {
        margin-left: 0;
    }

    .author-links {
        justify-content: center;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .dashboard-container {
        padding: 10px;
    }

    .dashboard-header h1 {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .filter-section,
    .stats-section,
    .chart-section,
    .map-section,
    .time-section {
        padding: 12px;
        border-radius: 10px;
    }

    .filter-select,
    .filter-select-small {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .reset-btn {
        padding: 14px;
        font-size: 1em;
    }

    #crime-map {
        height: 300px;
    }

    .chart {
        min-height: 220px;
    }

    #time-series-chart {
        min-height: 200px;
    }

    #hourly-chart,
    #weekday-chart {
        min-height: 160px;
    }

    .author-info {
        padding: 14px 16px;
    }

    .author-name {
        font-size: 1.1em;
    }

    .author-bio {
        font-size: 0.85em;
    }

    .author-link {
        font-size: 0.85em;
    }
}

/* D3 Chart Styling */
.chart text {
    fill: #a0aec0;
    font-size: 12px;
}

.chart .axis path,
.chart .axis line {
    stroke: #3d4463;
}

.chart .bar {
    transition: opacity 0.2s ease;
}

.chart .bar:hover {
    opacity: 0.8;
}

.chart .area {
    fill-opacity: 0.6;
}

.chart .line {
    fill: none;
    stroke-width: 2;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(29, 35, 66, 0.95);
    color: #e0e0e0;
    padding: 12px;
    border-radius: 6px;
    pointer-events: none;
    font-size: 0.9em;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #4a9eff;
    z-index: 1000;
}

.tooltip strong {
    color: #4a9eff;
    display: block;
    margin-bottom: 5px;
}

/* Leaflet Custom Styles */
.leaflet-container {
    background: #0f1329;
}

.leaflet-popup-content-wrapper {
    background: #1a1f3a;
    color: #e0e0e0;
    border-radius: 8px;
}

.leaflet-popup-tip {
    background: #1a1f3a;
}

.leaflet-popup-content strong {
    color: #4a9eff;
}
