/* css/routes.css - Shared styles for Route Planners */

:root {
    --route-primary: #0f172a;
    --route-accent: #2563eb;
    --route-accent-soft: rgba(37, 99, 235, 0.08);
    --route-bg: #fff;
    --route-bg-alt: #f8fafc;
    --route-border: #e2e8f0;
    --route-ink-muted: #64748b;
    --route-radius-lg: 16px;
    --route-radius-md: 12px;
    --route-shadow-xl: 0 10px 40px rgba(0, 0, 0, 0.08);
    --route-shadow-lg: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* EV Theme Override */
.ev-page {
    --route-accent: #8b5cf6;
    --route-accent-soft: rgba(139, 92, 246, 0.08);
}

.route-planner-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 24px;
}

/* --- HEADER --- */
.route-header {
    background: linear-gradient(135deg, var(--route-primary) 0%, #1e293b 100%);
    color: white;
    padding: 60px 24px;
    border-radius: var(--route-radius-lg);
    margin-bottom: 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ev-page .route-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
}

.route-header h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
}

.route-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

/* --- FORM CARD --- */
.route-form-card {
    background: white;
    border-radius: var(--route-radius-lg);
    padding: 40px;
    box-shadow: var(--route-shadow-xl);
    margin-bottom: 32px;
    border: 1px solid var(--route-border);
    margin-top: -60px;
    position: relative;
    z-index: 10;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--route-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group label i {
    color: var(--route-accent);
}

.form-group input,
.form-group select {
    padding: 14px 18px;
    border: 2px solid var(--route-border);
    border-radius: var(--route-radius-md);
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--route-bg-alt);
    font-weight: 600;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--route-accent);
    background: white;
    box-shadow: 0 0 0 4px var(--route-accent-soft);
}

/* Autocomplete */
.autocomplete-container {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--route-border);
    border-radius: var(--route-radius-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: var(--route-shadow-xl);
}

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

.autocomplete-item {
    padding: 14px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--route-bg-alt);
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--route-bg-alt);
}

.autocomplete-item-main {
    font-weight: 700;
    color: var(--route-primary);
    margin-bottom: 4px;
}

.autocomplete-item-detail {
    font-size: 12px;
    color: var(--route-ink-muted);
}

/* Buttons */
.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--route-bg-alt);
    border: 1px solid var(--route-border);
    font-weight: 700;
    color: var(--route-primary);
    font-size: 0.85rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid var(--route-border);
    background: white;
    font-weight: 700;
    color: var(--route-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--route-border);
    background: #fff;
}

.toggle input[type="checkbox"] {
    width: 40px;
    height: 20px;
    appearance: none;
    background: #e2e8f0;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
}

.toggle input[type="checkbox"]:checked {
    background: var(--route-accent);
}

.toggle input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

.ribbon {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 0 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 5;
}

.ribbon.price {
    background: #10b981;
    color: white;
}

.ribbon.detour {
    background: #3b82f6;
    color: white;
}

.sort-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    margin-bottom: 16px;
}

.sort-btn {
    flex: 1;
    padding: 12px;
    background: white;
    border: 1px solid var(--route-border);
    border-radius: var(--route-radius-md);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--route-ink-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sort-btn.active {
    background: var(--route-primary);
    color: white;
    border-color: var(--route-primary);
}

.stats-bar {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 15px;
    border-radius: 14px;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

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

.stat-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 800;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #0c4a6e;
}

/* Section Title with KM */
.section-title {
    margin: 20px 0 12px;
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title .km {
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 800;
    color: var(--route-primary);
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-primary {
    flex: 1;
    min-width: 220px;
    padding: 16px 30px;
    background: var(--route-accent);
    color: white;
    border: none;
    border-radius: var(--route-radius-md);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.ev-page .btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}

.ev-page .btn-primary:hover {
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    padding: 15px 30px;
    background: white;
    color: var(--route-accent);
    border: 2px solid var(--route-accent);
    border-radius: var(--route-radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-secondary:hover {
    background: var(--route-accent);
    color: white;
}

/* --- RESULTS LAYOUT --- */
.results-container {
    display: none;
    gap: 24px;
}

.results-container.active {
    display: grid;
    grid-template-columns: 1fr 420px;
}

.map-container {
    background: white;
    border-radius: var(--route-radius-lg);
    overflow: hidden;
    box-shadow: var(--route-shadow-xl);
    height: 720px;
    position: relative;
    border: 1px solid var(--route-border);
}

#routeMap {
    width: 100%;
    height: 100%;
}


/* --- ROUTE INFO OVERLAY ON MAP --- */
.route-info-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    z-index: 999;
    min-width: 200px;
    border: 1px solid #e2e8f0;
}

.route-info-overlay .close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: .9rem;
    padding: 4px;
    line-height: 1;
    transition: color .2s;
}

.route-info-overlay .close-btn:hover {
    color: #0f172a;
}

.route-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 800;
    color: #0f172a;
    font-size: .85rem;
}

.route-stat:last-child {
    margin-bottom: 0;
}

.route-stat i {
    color: #667eea;
    width: 16px;
    font-size: .9rem;
}


.stations-sidebar {
    background: white;
    border-radius: var(--route-radius-lg);
    padding: 24px;
    box-shadow: var(--route-shadow-xl);
    height: 720px;
    overflow: hidden;
    border: 1px solid var(--route-border);
    display: flex;
    flex-direction: column;
}

.stations-scroll {
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}

/* Station Cards - Improved Design */
.station-card {
    background: white;
    border: 2px solid var(--route-border);
    border-radius: 16px;
    padding: 0;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.station-card:hover {
    border-color: var(--route-accent);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.station-card.selected {
    border-color: var(--route-accent);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.03) 0%, rgba(37, 99, 235, 0.08) 100%);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.2);
}

.station-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.station-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--route-primary);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.station-brand {
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.station-price {
    background: var(--route-accent);
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 900;
    font-size: 1.15rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.station-details {
    padding: 0 20px 12px;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
    line-height: 1.5;
}

.station-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 16px;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

.meta-item i {
    color: var(--route-accent);
    font-size: 0.85rem;
}

.station-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-top: 1px solid #f1f5f9;
}

.action-btn {
    padding: 14px 16px;
    background: white;
    border: none;
    border-right: 1px solid #f1f5f9;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--route-accent);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.action-btn:last-child {
    border-right: none;
}

.action-btn:hover {
    background: var(--route-accent-soft);
}

.action-btn i {
    font-size: 1rem;
}

/* Sidebar Header */
.sidebar-top {
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--route-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend {
    background: #f8fafc;
    padding: 12px;
    border-radius: 10px;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
}

.legend-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.legend-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

.legend-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ev-page .station-power {
    background: #10b981;
}

.ev-page .station-power.fast {
    background: #f59e0b;
}

.ev-page .station-power.rapid {
    background: #8b5cf6;
}

.ev-page .station-power.ultra {
    background: #ef4444;
}

/* --- RESPONSIVE --- */
@media (max-width: 1100px) {
    .results-container.active {
        grid-template-columns: 1fr;
    }

    .stations-sidebar {
        height: 600px;
    }

    .map-container {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .route-planner-container {
        padding: 20px 16px;
    }

    .route-header {
        padding: 40px 20px;
    }

    .route-header h1 {
        font-size: 1.8rem;
    }

    .route-form-card {
        padding: 24px;
        margin-top: -40px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .map-container {
        height: 400px;
    }

    .stations-sidebar {
        height: 500px;
    }

    /* Improved mobile cards */
    .station-card {
        margin-bottom: 12px;
    }

    .station-header {
        padding: 16px 16px 12px;
    }

    .station-name {
        font-size: 0.95rem;
    }

    .station-brand {
        font-size: 0.75rem;
    }

    .station-price {
        padding: 6px 10px;
        font-size: 1rem;
    }

    .station-details {
        padding: 0 16px 10px;
        font-size: 0.85rem;
    }

    .station-meta {
        padding: 0 16px 12px;
        gap: 8px;
    }

    .meta-item {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .action-btn {
        padding: 12px;
        font-size: 0.8rem;
    }

    .stats-grid {
        gap: 8px;
    }

    .stat-value {
        font-size: 1rem;
    }
}

/* Mini Tools */
.mini-tools {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 16px;
}

/* Spinner & Error */
.loading-spinner {
    text-align: center;
    padding: 40px;
    display: none;
}

.loading-spinner.active {
    display: block;
}

.spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--route-accent);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    background: #fee2e2;
    border: 2px solid #ef4444;
    color: #991b1b;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    font-weight: 700;
}

.error-message.active {
    display: block;
}