/* Base Reset & Fonts */
:root {
    --primary-color: #0f766e;
    --primary-dark: #0f4c5c;
    --accent-color: #f59e0b;
    --text-color: #0f172a;
    --muted-color: #475569;
    --bg-color: #e2e8f0;
    --panel-bg: rgba(255, 255, 255, 0.88);
    --panel-border: rgba(15, 23, 42, 0.08);
    --sidebar-width: 380px;
    --sidebar-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
    --radius-lg: 18px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    height: 100vh;
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 15%, rgba(14, 116, 144, 0.22), transparent 45%),
        radial-gradient(circle at 90% 10%, rgba(245, 158, 11, 0.18), transparent 40%),
        radial-gradient(circle at 80% 85%, rgba(15, 118, 110, 0.18), transparent 45%);
    pointer-events: none;
    z-index: 0;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
    gap: 1.25rem;
    padding: 1.25rem;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    box-shadow: var(--sidebar-shadow);
    padding: 1.5rem 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    z-index: 2;
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    /* Above map */
}

.sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.sidebar-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.02em;
}

.control-group {
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    padding: 1rem;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--muted-color);
}

/* Inputs */
.select-wrapper select,
#time-picker {
    width: 100%;
    padding: 0.85rem 0.9rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.85rem;
    background-color: #ffffff;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.select-wrapper select:focus,
#time-picker:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.2);
}

/* Flatpickr Customization - Larger Panel */
.flatpickr-calendar {
    width: 350px !important;
    padding: 10px;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.flatpickr-innerContainer {
    width: 330px !important;
}

.flatpickr-days {
    width: 300px !important;
}

.dayContainer {
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
}

.flatpickr-day {
    max-width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
}

.time-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-nav-wrapper .input-wrapper {
    flex: 1;
}

.nav-button {
    background-color: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.85rem;
    width: 3.25rem;
    height: 3.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: all 0.2s;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.nav-button:hover:not(:disabled) {
    background-color: #ecfeff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.nav-button:active:not(:disabled) {
    transform: translateY(0);
}

.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8fafc;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#opacity-range {
    flex: 1;
}

#opacity-value {
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
    color: var(--primary-dark);
}

.compare-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.compare-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.compare-select select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Map */
#map {
    flex: 1;
    height: 100%;
    width: 100%;
    background-color: #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: var(--sidebar-shadow);
    overflow: hidden;
    position: relative;
}

.home-button {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    background: #ffffff;
    color: var(--primary-color);
    font-size: 16px;
    cursor: pointer;
    border-radius: 10px;
    box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.home-button:hover {
    background: #ecfeff;
}

.play-wrapper {
    margin-top: 8px;
    text-align: center;
}

.play-button {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 10px 16px rgba(15, 23, 42, 0.18);
}

.play-button:hover {
    background: linear-gradient(135deg, #0f766e, #115e59);
}


.map-legend {
    background: rgba(255, 255, 255, 0.92);
    padding: 10px 12px;
    border-radius: 12px;
    box-shadow: 0 12px 22px rgba(15, 23, 42, 0.18);
    font-size: 12px;
    line-height: 1.2;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    text-align: center;
}

.map-legend img {
    max-width: 120px;
    display: block;
}

/* Auth Gate */
.auth-gate {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 15%, rgba(15, 118, 110, 0.2), transparent 45%),
        radial-gradient(circle at 80% 20%, rgba(245, 158, 11, 0.2), transparent 50%),
        #e2e8f0;
    z-index: 2000;
}

.auth-card {
    width: min(420px, 92vw);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(10px);
}

.auth-card h2 {
    font-size: 1.5rem;
    margin-bottom: 6px;
    color: var(--text-color);
}

.auth-subtitle {
    font-size: 0.95rem;
    color: var(--muted-color);
    margin-bottom: 16px;
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-form label {
    font-weight: 600;
    color: var(--text-color);
}

.auth-form input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-button {
    margin-top: 8px;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

.auth-button:hover {
    background: linear-gradient(135deg, #0f766e, #115e59);
}

.auth-error {
    display: none;
    color: #b91c1c;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

body.auth-locked {
    overflow: hidden;
}

body.auth-locked .app-container {
    display: none;
}

body.auth-locked .auth-gate {
    display: flex;
}


/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    .control-group {
        margin-bottom: 1rem;
    }

    #map {
        height: 100%;
        /* Fill remaining */
    }
}
