/* style.css - Clean White & Light Blue theme for 'Rasen lohnt net!' */

:root {
    --primary: #0066FF;
    --primary-hover: #0052CC;
    --primary-light: #E6F0FF;
    --secondary: #33B5FF;
    --secondary-light: #F0F8FF;
    --bg-page: #F4F7FA;
    --bg-card: #FFFFFF;
    --border: #D0E1F0;
    --border-hover: #9ECAFC;
    --text-main: #1E293B;
    --text-muted: #64748B;
    
    --green: #10B981;
    --green-light: #ECFDF5;
    --red: #EF4444;
    --red-light: #FEF2F2;
    --amber: #D97706;
    --amber-light: #FEF3C7;
    
    --shadow: 0 4px 20px rgba(160, 175, 192, 0.15);
    --shadow-dropdown: 0 12px 30px rgba(30, 41, 59, 0.18);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.5;
    padding-bottom: 3rem;
}

/* App Containers - Elegant centered 1050px width */
.app-container {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.app-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.75rem 0;
    text-align: center;
    margin-bottom: 2rem;
}

.header-container {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    color: var(--primary);
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: 0.25rem;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.app-header .tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Card General */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background-color: #FAFBFD;
}

.card-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-icon {
    color: var(--primary);
    width: 1.15rem;
    height: 1.15rem;
}

.card-body {
    padding: 1.5rem;
}

.card-body.no-padding {
    padding: 0;
}

/* Route Search Input Row (overflow visible for autocomplete suggestions dropdown) */
.input-card {
    margin-bottom: 1.5rem;
    overflow: visible !important;
    position: relative;
    z-index: 100;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: visible;
}

.input-field-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    overflow: visible;
}

.field-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    width: 1.1rem;
    height: 1.1rem;
    pointer-events: none;
    transition: var(--transition);
}

.input-field-wrapper input {
    width: 100%;
    padding: 0.85rem 2.75rem 0.85rem 2.6rem; /* CRITICAL: prevents text overlap with clear button */
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--bg-card);
    transition: var(--transition);
    outline: none;
}

.input-field-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.input-field-wrapper input:focus + .field-icon {
    color: var(--primary);
}

.search-arrow-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Clear button inside input */
.clear-btn {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
    z-index: 5;
}

.clear-btn:hover {
    background-color: var(--bg-page);
    color: var(--text-main);
}

.clear-btn i {
    width: 0.95rem;
    height: 0.95rem;
}

/* Autocomplete suggestions dropdown overlay */
.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-dropdown);
    z-index: 9999 !important;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

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

.suggestion-item:hover {
    background-color: var(--secondary-light);
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.85rem 1.75rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Responsive Search Row */
@media (max-width: 768px) {
    .search-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .search-arrow-icon {
        transform: rotate(90deg);
        margin: 0.25rem 0;
    }
    
    .btn {
        width: 100%;
    }
}

/* Route Stats Banner */
.route-info-banner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.info-item strong {
    font-size: 1.15rem;
    color: var(--text-main);
    font-weight: 800;
}

.info-divider {
    width: 1px;
    height: 2rem;
    background-color: var(--border);
}

/* Grid Layout Dashboard (Equal Size side-by-side Map and Comparison) */
.dashboard-split {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 50% / 50% split */
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .dashboard-split {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
}

/* Map Card and Comparison Card - Strictly Equal Heights */
.map-wrapper {
    position: relative;
    width: 100%;
    height: 440px; /* Aligned with comparison list height */
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.comparison-list-wrapper {
    width: 100%;
    height: 440px; /* Exactly matches the map wrapper height */
    overflow-y: hidden; /* CRITICAL: removes unnecessary scrollbar */
}

.map-badge {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-page);
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    border: 1px solid var(--border);
}

/* Disabled UI State */
.card.disabled {
    opacity: 0.55;
    pointer-events: none;
    filter: grayscale(10%);
}

/* Speed Comparison List */
.comparison-list {
    display: flex;
    flex-direction: column;
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.72rem 1.5rem; /* Balanced padding to fit all 9 items perfectly within 440px */
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    transition: var(--transition);
}

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

.comparison-item-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.comp-speed {
    font-weight: 700;
    color: var(--text-main);
}

.comp-time {
    color: var(--text-muted);
    font-weight: 500;
}

.comp-cost {
    font-weight: 700;
}

.comparison-item.active {
    background-color: var(--primary-light);
}

.comparison-item.active .comp-speed {
    color: var(--primary);
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* Relocated Controls Panel - Grid layout */
.controls-layout-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr; /* Split into Slider+Metrics / Fuel Inputs */
    gap: 2.5rem;
}

@media (max-width: 800px) {
    .controls-layout-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.slider-and-metrics-area {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Slider Section styling */
.slider-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.slider-speed-val {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
}

.slider-speed-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 0.15rem;
}

.slider-container {
    padding: 0 0.5rem;
    margin-bottom: 1.25rem;
}

/* Custom range input styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 9999px;
    background: var(--border);
    outline: none;
    cursor: pointer;
    margin: 1rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    border: 3.5px solid #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background-color: var(--primary-hover);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0 4px;
    margin-top: -4px;
}

/* Live calculations metrics box */
.live-metrics-output {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: #FAFBFD;
    padding: 1.15rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.live-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.live-metric-val-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.live-metric-row.border-top {
    border-top: 1px solid var(--border);
    padding-top: 0.85rem;
    margin-top: 0.25rem;
}

.metric-label {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.metric-val-large {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-val-highlight {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

/* Time savings alert badge styling */
.time-saving-alert-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    background-color: var(--amber-light);
    color: var(--amber);
    border: 1px solid rgba(217, 119, 6, 0.2);
    animation: fadeIn 0.3s ease-out;
}

/* CSS Tooltip definitions */
.tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    margin-left: 5px;
}

.tooltip-trigger-icon {
    width: 0.95rem;
    height: 0.95rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.tooltip-wrapper .tooltip-popup {
    visibility: hidden;
    width: 260px;
    background-color: #1E293B;
    color: #FFFFFF;
    text-align: center;
    border-radius: 6px;
    padding: 0.85rem;
    position: absolute;
    z-index: 10000;
    bottom: 130%; /* Sit above the trigger */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.25s, visibility 0.25s;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

/* Tooltip popup arrow styling */
.tooltip-wrapper .tooltip-popup::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #1E293B transparent transparent transparent;
}

/* Hover show tooltip */
.tooltip-wrapper:hover .tooltip-popup {
    visibility: visible;
    opacity: 1;
}

.tooltip-wrapper:hover .tooltip-trigger-icon {
    color: var(--primary);
}

/* Fuel inputs area styling */
.fuel-inputs-area {
    border-left: 1px solid var(--border);
    padding-left: 2rem;
}

@media (max-width: 800px) {
    .fuel-inputs-area {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 1.5rem;
    }
}

.fuel-inputs-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.fuel-inputs-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.fuel-header-icon {
    color: var(--primary);
    width: 1.1rem;
    height: 1.1rem;
}

.fuel-controls-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.select-wrapper, .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    width: 1rem;
    height: 1rem;
    pointer-events: none;
}

select, input[type="number"] {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.2rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: var(--bg-card);
    outline: none;
    transition: var(--transition);
}

select:focus, input[type="number"]:focus {
    border-color: var(--primary);
}

.input-unit {
    position: absolute;
    right: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

input[type="number"] {
    padding-right: 2.5rem;
}

/* Map marker styles */
.custom-map-marker {
    position: relative;
}

.marker-pin {
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -24px 0 0 -12px;
    box-shadow: 0 4px 10px rgba(0, 102, 255, 0.25);
}

.marker-pin::after {
    content: '';
    width: 10px;
    height: 10px;
    margin: 7px 0 0 7px;
    background: #FFFFFF;
    position: absolute;
    border-radius: 50%;
}

.marker-pin.start {
    background: var(--primary);
    border: 1px solid rgba(0, 102, 255, 0.2);
}

.marker-pin.dest {
    background: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

/* Footer */
.app-footer {
    border-top: 1px solid var(--border);
    background-color: var(--bg-card);
    padding: 3rem 0;
    color: var(--text-muted);
    margin-top: 3rem;
}

.footer-container {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.footer-info h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.footer-info p {
    font-size: 0.8rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.footer-info p:last-child {
    margin-bottom: 0;
}

.footer-copyright {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    text-align: center;
    font-size: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Color highlighting for time savings based on percentage saved */
.time-deep-red {
    color: #990000 !important;
    font-weight: 700;
}

.time-light-red {
    color: #FF4D4D !important;
    font-weight: 700;
}

.hidden {
    display: none !important;
}
