/* DriveCast App Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --sky-100: #e0f2fe;
    --sky-200: #bae6fd;
    --sky-500: #0ea5e9;
    --sky-600: #0284c7;
    --sky-700: #0369a1;
    --storm: #1e293b;
    --storm-light: #334155;
    --cloud: #f1f5f9;
    --asphalt: #0f172a;
    --sunset: #f97316;
    --sunset-light: #fed7aa;
    --rain: #6366f1;
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--storm);
    background: var(--asphalt);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
}

.logo-icon {
    font-size: 1.4rem;
}

.logo-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-toggle {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    padding: 6px 14px;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-toggle:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Search Panel */
.search-panel {
    position: fixed;
    top: 64px;
    left: 16px;
    z-index: 900;
    width: 380px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group {
    position: relative;
}

.input-group input[type="text"] {
    width: 100%;
    padding: 12px 12px 12px 36px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.input-group input[type="text"]:focus {
    border-color: var(--sky-500);
    background: rgba(255,255,255,0.09);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.input-group input::placeholder {
    color: rgba(255,255,255,0.35);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 2;
}

.origin-icon {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.dest-icon {
    background: var(--sunset);
    box-shadow: 0 0 6px rgba(249, 115, 22, 0.4);
}

.time-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-group label {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 42px;
}

.time-group input[type="datetime-local"] {
    flex: 1;
    padding: 8px 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    outline: none;
    color-scheme: dark;
}

.time-group input[type="datetime-local"]:focus {
    border-color: var(--sky-500);
}

.plan-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--sky-500), var(--sky-600));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.01em;
}

.plan-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--sky-600), var(--sky-700));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3);
}

.plan-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Suggestions dropdown */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.suggestions-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 10px 14px;
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
    line-height: 1.4;
}

.suggestion-item:hover {
    background: rgba(14, 165, 233, 0.12);
}

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

/* Map */
#map {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Route Summary */
.route-summary {
    position: fixed;
    top: 64px;
    right: 16px;
    z-index: 900;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.summary-stat {
    text-align: center;
}

.summary-value {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
}

.summary-label {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.summary-divider {
    width: 1px;
    height: 32px;
    background: rgba(255,255,255,0.1);
}

.reset-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 4px;
}

.reset-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Weather Timeline */
.timeline-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 0;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 10px;
}

.timeline-header h3 {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-icon {
    font-size: 1.1rem;
}

.timeline-summary {
    color: rgba(255,255,255,0.45);
    font-size: 0.78rem;
}

.timeline-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.timeline-scroll::-webkit-scrollbar {
    height: 4px;
}

.timeline-scroll::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
}

.timeline-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.weather-card {
    flex-shrink: 0;
    width: 100px;
    padding: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.weather-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-2px);
}

.weather-card.active {
    border-color: var(--sky-500);
    background: rgba(14, 165, 233, 0.1);
}

.weather-card .wx-icon {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 4px;
}

.weather-card .wx-temp {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
}

.weather-card .wx-label {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weather-card .wx-detail {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
    margin-top: 4px;
}

.weather-card .wx-mile {
    font-size: 0.7rem;
    color: var(--sky-500);
    font-weight: 600;
    margin-top: 4px;
}

/* Filter Bar */
.filter-bar {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex;
    gap: 6px;
    padding: 6px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
}

.filter-chip {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.5);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-chip.active {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.3);
    color: var(--sky-500);
}

.filter-chip:hover {
    background: rgba(255,255,255,0.08);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--sky-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

.loading-content p {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.7);
}

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

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

/* Custom Leaflet markers */
.weather-marker {
    background: none;
    border: none;
}

.weather-marker-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Space Grotesk', sans-serif;
}

.wx-marker-icon {
    font-size: 1.4rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.wx-marker-temp {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    background: rgba(15, 23, 42, 0.75);
    padding: 1px 6px;
    border-radius: 6px;
    margin-top: 2px;
}

.stop-marker {
    background: none;
    border: none;
}

.stop-marker-inner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid #fff;
    transition: transform 0.2s;
}

.stop-marker-inner:hover {
    transform: scale(1.2);
}

.stop-marker-inner.fuel { background: #f59e0b; }
.stop-marker-inner.hotel { background: #6366f1; }
.stop-marker-inner.rest_area { background: #0ea5e9; }
.stop-marker-inner.landmark { background: #10b981; }
.stop-marker-inner.food { background: #ef4444; }

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.95) !important;
    color: #fff !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.95) !important;
}

.leaflet-popup-content {
    margin: 12px 14px !important;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 0.85rem !important;
}

.popup-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.popup-detail {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    line-height: 1.5;
}

.popup-detail a {
    color: var(--sky-500);
    text-decoration: none;
}

.popup-detail a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .search-panel {
        left: 8px;
        right: 8px;
        width: auto;
        top: 56px;
    }

    .route-summary {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 170px;
        justify-content: center;
    }

    .filter-bar {
        bottom: 165px;
        left: 8px;
        right: 8px;
        transform: none;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .timeline-panel {
        padding: 10px 0;
    }

    .weather-card {
        width: 85px;
        padding: 8px;
    }

    .weather-card .wx-icon {
        font-size: 1.3rem;
    }

    .weather-card .wx-temp {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .search-panel {
        top: 54px;
        padding: 12px;
    }

    .input-group input[type="text"] {
        padding: 10px 10px 10px 32px;
        font-size: 0.9rem;
    }

    .plan-btn {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* Search panel collapsed state (after route planned) */
.search-panel.collapsed {
    width: auto;
    padding: 10px 14px;
}

.search-panel.collapsed .search-form {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.search-panel.collapsed .input-group {
    flex: 1;
    min-width: 140px;
}

.search-panel.collapsed .time-group {
    display: none;
}

.search-panel.collapsed .plan-btn {
    width: auto;
    padding: 10px 18px;
}

/* Polyline color classes for weather segments */
.leaflet-interactive.weather-clear { stroke: #22c55e; }
.leaflet-interactive.weather-cloudy { stroke: #94a3b8; }
.leaflet-interactive.weather-rain { stroke: #0ea5e9; }
.leaflet-interactive.weather-heavy-rain { stroke: #0369a1; }
.leaflet-interactive.weather-snow { stroke: #7dd3fc; }
.leaflet-interactive.weather-storm { stroke: #ef4444; }
.leaflet-interactive.weather-fog { stroke: #94a3b8; }
