/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue-900: #0B2545;
    --blue-700: #1B4F8E;
    --blue-500: #2171C7;
    --blue-400: #3B8FE8;
    --blue-100: #E8F2FF;
    --blue-50:  #F0F6FF;
    --accent:   #F5A623;
    --accent-dk:#D4871A;
    --green:    #22C55E;
    --red:      #EF4444;
    --gray-900: #111827;
    --gray-700: #374151;
    --gray-500: #6B7280;
    --gray-300: #D1D5DB;
    --gray-100: #F3F4F6;
    --white:    #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
    --radius:   12px;
    --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.site-header {
    background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%);
    color: var(--white);
    padding: 28px 0 32px;
    position: relative;
    overflow: hidden;
}

.site-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0; right: 0;
    height: 32px;
    background: var(--gray-100);
    clip-path: ellipse(55% 100% at 50% 100%);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--accent);
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--white);
}

.logo-sub {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.65);
    padding-left: 48px;
}

/* ===== MAIN ===== */
.main-content {
    padding: 36px 0 60px;
}

/* ===== CALC CARD ===== */
.calc-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 32px;
    margin-bottom: 24px;
}

.calc-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--blue-900);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== FORM GRID ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
}

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-icon {
    width: 16px; height: 16px;
    color: var(--blue-500);
    flex-shrink: 0;
}

.autocomplete-wrap { position: relative; }

.field-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.field-input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(33,113,199,.15);
}

.field-input::placeholder { color: var(--gray-500); }

/* Autocomplete dropdown */
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--white);
    border: 1.5px solid var(--blue-100);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    list-style: none;
    z-index: 100;
    overflow: hidden;
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-list:empty { display: none; }

.autocomplete-list li {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--gray-700);
    transition: background .15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.autocomplete-list li::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--blue-400);
    flex-shrink: 0;
}

.autocomplete-list li:hover, .autocomplete-list li.active {
    background: var(--blue-50);
    color: var(--blue-700);
}

/* Swap button */
.swap-btn {
    width: 44px; height: 44px;
    border: 1.5px solid var(--gray-300);
    border-radius: 50%;
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all .2s;
    flex-shrink: 0;
    align-self: end;
    margin-bottom: 0;
}

.swap-btn svg { width: 18px; height: 18px; }

.swap-btn:hover {
    border-color: var(--blue-500);
    color: var(--blue-500);
    transform: rotate(180deg);
}

/* ===== VEHICLE SELECTOR ===== */
.vehicle-section { margin-bottom: 24px; }

.vehicle-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.vehicle-options {
    display: flex;
    gap: 12px;
}

.vehicle-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .2s;
    color: var(--gray-500);
    background: var(--white);
}

.vehicle-option input[type="radio"] { display: none; }

.vehicle-icon svg {
    width: 52px; height: auto;
    color: inherit;
}

.vehicle-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: inherit;
}

.vehicle-option.selected {
    border-color: var(--blue-500);
    background: var(--blue-50);
    color: var(--blue-700);
}

.vehicle-option:hover:not(.selected) {
    border-color: var(--blue-300, #93C5FD);
    color: var(--blue-500);
}

/* ===== CALC BUTTON ===== */
.calc-btn {
    width: 100%;
    padding: 15px 24px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all .2s;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(33,113,199,.35);
}

.calc-btn svg { width: 20px; height: 20px; }

.calc-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(33,113,199,.45);
}

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

/* ===== ERROR BOX ===== */
.error-box {
    margin-top: 16px;
    padding: 12px 16px;
    background: #FEF2F2;
    border: 1.5px solid #FECACA;
    border-radius: var(--radius-sm);
    color: #B91C1C;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-box::before {
    content: '⚠';
    font-size: 1.1rem;
}

/* ===== RESULT CARDS ===== */
.result-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.result-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-top: 3px solid transparent;
    transition: box-shadow .2s;
}

.result-card:hover { box-shadow: var(--shadow-md); }

.card-distance { border-top-color: var(--blue-500); }
.card-time     { border-top-color: var(--accent); }
.card-fuel     { border-top-color: var(--green); }

.card-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg { width: 24px; height: 24px; }

.card-distance .card-icon { background: var(--blue-100); color: var(--blue-700); }
.card-time .card-icon     { background: #FEF3C7; color: #B45309; }
.card-fuel .card-icon     { background: #DCFCE7; color: #166534; }

.card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.card-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1.1;
}

.card-unit {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ===== FUEL CALCULATOR ===== */
.fuel-calc-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 16px;
}

.fuel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--blue-900);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fuel-title svg { width: 18px; height: 18px; color: var(--blue-500); }

.fuel-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.fuel-field { display: flex; flex-direction: column; gap: 6px; }

.fuel-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
}

.fuel-input {
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--gray-900);
    transition: border-color .2s;
    outline: none;
}

.fuel-input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(33,113,199,.12);
}

.fuel-btn {
    padding: 10px 24px;
    background: var(--blue-100);
    color: var(--blue-700);
    border: 1.5px solid var(--blue-400);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}

.fuel-btn:hover {
    background: var(--blue-500);
    color: var(--white);
    border-color: var(--blue-500);
}

/* ===== PRINT BUTTON ===== */
.print-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.print-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--white);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all .2s;
}

.print-btn svg { width: 18px; height: 18px; }

.print-btn:hover {
    border-color: var(--blue-500);
    color: var(--blue-700);
}

/* ===== MAP ===== */
.map-section {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#map {
    width: 100%;
    height: 450px;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,37,69,.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-ring {
    width: 56px; height: 56px;
    border: 4px solid rgba(255,255,255,.2);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.spinner-text {
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* ===== FOOTER ===== */
.site-footer {
    background: var(--blue-900);
    color: rgba(255,255,255,.45);
    padding: 20px 0;
    text-align: center;
    font-size: 0.82rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 680px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .swap-btn {
        width: 36px; height: 36px;
        transform: rotate(90deg);
        align-self: center;
        margin: -4px auto;
    }

    .swap-btn:hover { transform: rotate(270deg); }

    .result-cards {
        grid-template-columns: 1fr;
    }

    .fuel-fields {
        grid-template-columns: 1fr;
    }

    .calc-card { padding: 20px 16px; }

    #map { height: 320px; }
}

/* ===== PRINT STYLES ===== */
@media print {
    .site-header { background: none; color: #000; }
    .site-header::after { display: none; }
    .calc-card, .fuel-calc-card, .print-bar, .loading-overlay { display: none !important; }
    .result-cards { display: grid !important; }
    .result-section { display: block !important; }
    #map { height: 350px; }
    .site-footer { display: none; }
}
