:root {
    --bg-dark: #000000;
    --bg-panel: #111827;
    --text-primary: #f8fafc;
    --text-secondary: #475569;
    --accent: #10b981;
    --accent-hover: #059669;
    --sun-color: #eab308;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --font-fam: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-fam);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden; /* Prevent body scroll, layout handles it */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 400px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 15px var(--shadow-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
}

/* Typography & Header */
.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.app-logo-img {
    height: 48px;
    width: auto;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #34d399, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* Forms */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.date-time-group {
    flex-direction: row;
    gap: 1rem;
}

.date-time-group > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input {
    width: 100%;
    background-color: rgba(31, 41, 55, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-family: var(--font-fam);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Autocomplete Suggestions */
.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.suggestions-box.hidden {
    display: none;
}

.suggestion-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background-color 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: rgba(16, 185, 129, 0.1);
}

/* Button */
.primary-btn {
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-family: var(--font-fam);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

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

/* Results Panel */
.results-panel {
    margin-top: 2.5rem;
    animation: fadeIn 0.5s ease-out;
}

.results-panel.hidden {
    display: none;
}

.results-panel h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.result-card {
    background: rgba(31, 41, 55, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

/* Progress Bar */
.exposure-bar-container {
    display: flex;
    height: 12px;
    background: var(--bg-dark);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.exp-bar {
    height: 100%;
    transition: width 0.5s ease-out;
}

.left-bar { background-color: #ef4444; }
.none-bar { background-color: #1f2937; }
.right-bar { background-color: #3b82f6; }

/* Stats List */
.exposure-stats {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.stat {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.stat strong {
    margin-left: auto;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 0.8rem;
    display: inline-block;
}

.sun-left { background-color: #ef4444; }
.sun-right { background-color: #3b82f6; }
.sun-none { background-color: #1f2937; }

.shade-verdict {
    margin-top: 1.5rem;
    text-align: center;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    border: 1px dashed var(--accent);
}

.shade-verdict h3 {
    font-size: 2rem;
    color: #ffffff;
    margin: 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.verdict-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Leaflet Dark mode overrides - target tiles specifically */
.leaflet-tile-pane {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

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

/* Responsive */
/* Responsive Mobile SPA Architecture */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 100vh;
        max-height: none;
        padding: 1.5rem;
        border: none;
        overflow-y: auto;
    }
    .map-container {
        display: none;
    }
    header h1 { font-size: 2rem; }
    .brand { justify-content: center; gap: 0.6rem; }
    .app-logo-img { height: 44px; }
    header p { text-align: center; }

    /* "New Page" Results State */
    body.spa-active .sidebar {
        height: auto;
        order: 2;
        border-top: 2px solid var(--accent);
        padding-top: 1rem;
    }
    body.spa-active header p,
    body.spa-active .control-panel {
        display: none;
    }
    body.spa-active .map-container {
        display: block;
        flex: 1;
        min-height: 45vh;
        order: 1;
    }
}

/* Install Banner Hover UI */
.install-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 450px;
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 9999;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.install-banner.hidden { display: none; }

.install-content { flex: 1; display: flex; align-items: center; gap: 1rem; }
.install-icon { width: 44px; height: 44px; border-radius: 10px; }
.install-text strong { display: block; font-size: 1.1rem; color: var(--text-primary); }
.install-text p { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.2rem; }

.install-btn {
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}
.install-btn:active { transform: scale(0.95); }
.close-install-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem;
}

@keyframes slideUp {
    from { transform: translate(-50%, 150%); }
    to { transform: translate(-50%, 0); }
}

/* Animated Map Elements */
.custom-train-icon .train-container {
    width: 24px;
    height: 40px;
    transition: transform 0.5s ease;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}

.sun-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sun-glow-icon {
    font-size: 32px;
    animation: pulseSun 3s infinite alternate;
}

@keyframes pulseSun {
    0% { filter: drop-shadow(0 0 10px var(--sun-color)) scale(1); }
    100% { filter: drop-shadow(0 0 25px var(--sun-color)) scale(1.2); }
}

.sun-ray {
    stroke-dasharray: 6 12;
    animation: rayDash 3s linear infinite;
}

@keyframes rayDash {
    from { stroke-dashoffset: 18; }
    to { stroke-dashoffset: 0; }
}

/* Simulate track movement */
.leaflet-interactive[stroke-dasharray="5, 10"] {
    animation: trackMove 1s linear infinite;
}

@keyframes trackMove {
    from { stroke-dashoffset: 15; }
    to { stroke-dashoffset: 0; }
}
