/* ==========================================================================
   MAIN LAYOUT & BACKGROUND
   ========================================================================== */

/* Utility class to hide elements */
.hidden {
    display: none !important;
}

/* Language selector styles */
.lang-item.active {
    background-color: rgba(255, 255, 255, 0.3) !important;
    font-weight: 600;
    border-left: 4px solid white;
}

.gradient-bg {
    background: linear-gradient(135deg, #ff9800, #ffeb3b 33%, #ff69b4 66%, #800080);
    min-height: 100vh;
    color: black;
}

.glass {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body {
    font-family: 'Poppins', sans-serif;
    padding-top: 0 !important;
    text-rendering: optimizeSpeed;
}

/* Performance optimizations */
#map {
    contain: strict;
    will-change: transform;
}

#resultSection {
    contain: layout style;
}

.result-compact-card {
    contain: layout style paint;
}

/* Lazy-load images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded,
img[loading="lazy"][src] {
    opacity: 1;
}

/* ==========================================================================
   TABS & BUTTON STATES
   ========================================================================== */
/* ACCESSIBILITY FIX: WCAG AA compliant contrast (4.5:1 minimum for normal text)
   Active state: dark blue background (#1e40af) with white text
   Inactive state: white background with dark gray text (#1f2937)
   Using visual indicators beyond just color: background change + text weight change */
.unit-tab-button.active,
.calc-tab-button.active,
.route-tab-button.active,
.map-active {
    background-color: #1e40af !important; /* blue-800: 8.59:1 contrast with white */
    color: white !important;
    font-weight: 700 !important; /* Bold for additional visual distinction */
    box-shadow: inset 0 -3px 0 0 #1e3a8a !important; /* Underline effect for non-color indicator */
}

.route-tab-button,
.unit-tab-button,
.calc-tab-button {
    background-color: white;
    color: #1f2937; /* gray-800: 12.63:1 contrast with white bg */
    transition: background-color 0.3s ease, color 0.3s ease, font-weight 0.3s ease, box-shadow 0.3s ease;
    font-weight: 600;
}

.route-tab-button:hover:not(.active),
.unit-tab-button:hover:not(.active),
.calc-tab-button:hover:not(.active) {
    background-color: #f3f4f6;
    color: #111827; /* Slightly darker on hover */
}

.route-tab-button.active,
.unit-tab-button.active,
.calc-tab-button.active {
    background-color: #1e40af !important; /* blue-800 */
    color: white !important;
    font-weight: 700 !important;
    box-shadow: inset 0 -3px 0 0 #1e3a8a !important;
}

/* ACCESSIBILITY FIX: aria-pressed visual indicator
   Ensures buttons with aria-pressed="true" are visually distinct */
.route-tab-button[aria-pressed="true"],
.unit-tab-button[aria-pressed="true"],
.calc-tab-button[aria-pressed="true"] {
    background-color: #1e40af !important;
    color: white !important;
    font-weight: 700 !important;
    box-shadow: inset 0 -3px 0 0 #1e3a8a !important;
}

/* ACCESSIBILITY FIX: Install banner button - darker orange for contrast
   Using orange-900 (#7c2d12) for 7.0:1+ contrast ratio on white background */
#install-banner-btn {
    color: #7c2d12 !important; /* orange-900 */
    font-weight: 700 !important;
}

/* ACCESSIBILITY FIX: Header Install App button contrast */
#header-install-btn {
    background: linear-gradient(135deg, #c2410c, #9a3412) !important; /* orange-700 to orange-800 */
    color: white !important;
    font-weight: 600 !important;
}

/* ==========================================================================
   TOGGLE SLIDER (Petrol / EV stations)
   ========================================================================== */
.slider {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.slider input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider span {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: background-color 0.4s ease;
    border-radius: 34px;
}
.slider span:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background: white;
    transition: transform 0.4s ease;
    border-radius: 50%;
}
input:checked + span {
    background: #FF9800;
}
input:checked + span:before {
    transform: translateX(26px);
}

/* ==========================================================================
   RESULT CARDS - SQUARE CARD LAYOUT (like action buttons)
   ========================================================================== */
.result-square-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255,255,255,0.9);
    min-height: 160px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-square-card:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.result-square-card .result-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.result-square-card .result-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: #1f2937;
    text-align: center;
    line-height: 1.2;
}

@media (min-width: 768px) {
    .result-square-card .result-value {
        font-size: 1.75rem;
    }
}

/* Total Cost Card - Subtle amber styling (same size as other cards) */
.total-cost-card {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.25)) !important;
    border: 2px solid rgba(245, 158, 11, 0.4) !important;
}

.total-cost-card:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(245, 158, 11, 0.3);
}

/* Compact Result Cards - Organized grid layout */
.result-compact-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0.75rem;
    border-radius: 1.25rem;
    box-shadow: 0 6px 15px -3px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255,255,255,0.9);
    min-height: 120px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-compact-card:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.result-label-sm {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.2;
}

.result-value-sm {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1f2937;
    text-align: center;
    line-height: 1.15;
    word-break: break-word;
}

@media (min-width: 768px) {
    .result-compact-card {
        padding: 1.25rem 1rem;
        min-height: 140px;
        gap: 0.5rem;
    }
    .result-label-sm {
        font-size: 0.85rem;
    }
    .result-value-sm {
        font-size: 1.35rem;
    }
}

/* Old result-display-card kept for backward compatibility */
.result-display-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 1.5rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255,255,255,0.9);
}
.result-display-card .icon {
    color: #ff9800;
}
.result-display-card .font-black {
    color: #3182ce;
}

/* ==========================================================================
   OLD RESULT CARD STYLES (kept for backward compatibility if still used somewhere)
   ========================================================================== */
.result-card {
    color: #1f2937;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}
.result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px -5px rgba(0, 0, 0, 0.2);
}
.result-card .material-icons-outlined {
    font-size: 2.5rem;
    color: #f97316;
}
.result-card .result-label {
    font-size: 1rem;
    font-weight: 500;
    color: #4b5563;
    margin-top: 0.25rem;
}
.result-card .result-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.8rem;
    color: #1f2937;
}

/* ==========================================================================
   RESPONSIVE RESULT SECTION
   ========================================================================== */
@media (max-width: 767px) {
    #resultSection {
        display: flex;
        flex-direction: column;
    }
    .result-card {
        width: 100%;
        margin-bottom: 1rem;
    }
}

/* ==========================================================================
   BUTTONS & SELECTS
   ========================================================================== */
.calculate-button,
.currency-selector {
    background-color: #3182ce;
    color: white;
    border-radius: 8px;
}
.calculate-button:hover,
.currency-selector:hover {
    background-color: #2c5282;
}

/* ==========================================================================
   MAP
   ========================================================================== */
#map {
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* ==========================================================================
   FAQ (if you ever use accordion style)
   ========================================================================== */
.faq-section { margin-top: 2rem; }
.faq-item { margin-bottom: 1rem; }
.faq-question { cursor: pointer; transition: color 0.3s ease; }
.faq-question:hover { color: #4a5568; }
.faq-answer { padding-top: 1rem; }
.faq-answer strong { font-weight: 700; color: #4a5568; }

/* ==========================================================================
   OLD LANGUAGE SWITCHER (kept in case any translated page still uses it)
   ========================================================================== */
#language-switcher {
    width: 100%;
    max-width: 420px;
    margin: 60px auto 30px auto;
    padding: 0 20px;
    text-align: right;
}
#languageSelector {
    display: inline-block;
    background: linear-gradient(135deg, #3182ce, #2563eb);
    color: white;
    border: 3px solid white;
    border-radius: 12px;
    padding: 14px 22px;
    font-weight: 700;
    font-size: 16px;
    min-width: 190px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
#languageSelector:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}
#languageSelector option {
    background-color: #1e293b;
    color: white;
    padding: 10px;
}
@media (max-width: 640px) {
    #language-switcher {
        margin: 40px auto 20px auto;
        padding: 0 12px;
    }
    #languageSelector {
        min-width: 170px;
        font-size: 15px;
        padding: 12px 18px;
    }
}

/* ==========================================================================
   BEAUTIFUL ADD STOP & REMOVE BUTTONS – NEW PREMIUM DESIGN
   ========================================================================== */
.stop-point {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
}

.stop-point input {
    flex: 1;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.95);
    font-size: 1rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

@media (max-width: 767px) {
    .stop-point input {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

.stop-point button.remove-stop {
    width: 52px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 6px 20px rgba(239,68,68,0.4);
    flex-shrink: 0;
}

.stop-point button.remove-stop:hover {
    background: #dc2626;
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(239,68,68,0.5);
}

/* Main "Add Stop" button – now stunning */
#initialAddStop,
#addStopBtn {
    width: 100%;
    padding: 1.35rem;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border: 2px dashed #fb923c;
    border-radius: 1rem;
    color: #ea580c;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 6px 25px rgba(0,0,0,0.1);
    cursor: pointer;
    margin-top: 8px;
}

#initialAddStop:hover,
#addStopBtn:hover {
    background: rgba(255,255,255,1);
    border-color: #f97316;
    color: #dc2626;
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(249,115,22,0.35);
}

@supports (backdrop-filter: blur(32px)) or (-webkit-backdrop-filter: blur(32px)) {
    .backdrop-blur-3xl {
        backdrop-filter: blur(32px);
        -webkit-backdrop-filter: blur(32px);
    }
}

/* ==========================================================================
   INTERACTIVE HOVER ZOOM EFFECTS
   ========================================================================== */
/* Zoom effect for key features and interactive elements */
.hover-zoom {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.hover-zoom:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Smooth zoom for feature cards */
.feature-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.feature-card:hover {
    transform: scale(1.08);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

/* Zoom effect for "How It Works" steps */
.step-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.step-card:hover {
    transform: scale(1.06);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
}

/* Zoom effect for benefits/why use cards */
.benefit-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.benefit-card:hover {
    transform: scale(1.07);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.19);
}

/* ==========================================================================
   ACTION BUTTON ZOOM EFFECTS (Map, Directions, Google Maps, Petrol, EV)
   ========================================================================== */
.action-btn-zoom {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    cursor: pointer;
}

.action-btn-zoom:hover {
    transform: scale(1.08);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

/* Toggle card zoom effect for Petrol/EV stations */
.toggle-card-zoom {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.toggle-card-zoom:hover {
    transform: scale(1.06);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   FULL WIDTH MAP CONTAINER
   ========================================================================== */
#mapContainer {
    width: 100% !important;
    max-width: 100% !important;
}

#map {
    min-height: 400px;
}

@media (max-width: 640px) {
    #map {
        min-height: 350px;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVE FIXES
   ========================================================================== */

/* Make h1 and h2 headers responsive on small screens */
@media (max-width: 640px) {
    /* Main page title h1 */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        padding: 0 0.25rem;
    }

    section h2 {
        font-size: 1.75rem !important;
        line-height: 1.2;
        word-wrap: break-word;
        hyphens: auto;
        padding: 0 0.5rem;
    }

    section p {
        font-size: 1rem;
        padding: 0 0.25rem;
    }

    /* Feature cards responsive */
    .feature-card h3,
    .step-card h3,
    .benefit-card h3 {
        font-size: 1.25rem;
    }

    /* FAQ responsive */
    section .text-2xl {
        font-size: 1.25rem;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    h1 {
        font-size: 1.5rem !important;
    }

    section h2 {
        font-size: 1.5rem !important;
    }

    section.glass {
        padding: 1.5rem 1rem;
    }
}

/* Header tap area for scroll-to-top */
@media (max-width: 767px) {
    nav {
        cursor: pointer;
    }

    nav a, nav button, nav select {
        cursor: pointer;
    }
}

/* ==========================================================================
   SEARCH HISTORY PANEL
   ========================================================================== */
.search-history-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    margin-top: 0.75rem;
}

/* Hide desktop history on mobile, show mobile history instead */
@media (max-width: 767px) {
    .search-history-panel.desktop-only {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .search-history-panel.mobile-only {
        display: none !important;
    }
}

.search-history-panel:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* Toggle button */
.search-history-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4b5563;
    transition: color 0.2s ease;
}

.search-history-toggle:hover {
    color: #f97316;
}

.search-history-toggle-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-history-toggle-left .material-icons-outlined {
    font-size: 20px;
    color: #f97316;
}

.search-history-chevron {
    font-size: 20px !important;
    transition: transform 0.25s ease;
}

.search-history-panel.open .search-history-chevron {
    transform: rotate(180deg);
}

/* History list */
.search-history-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.search-history-panel.open .search-history-list {
    max-height: 240px;
    overflow-y: auto;
}

/* Thin scrollbar for history list */
.search-history-list::-webkit-scrollbar {
    width: 4px;
}

.search-history-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.search-history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Individual history item */
.search-history-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.15s ease;
}

.search-history-item:hover {
    background: rgba(249, 115, 22, 0.08);
}

.search-history-item-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.search-history-item-icon.fastest {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.search-history-item-icon.cheapest {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.search-history-item-icon.scenic {
    background: rgba(236, 72, 153, 0.12);
    color: #ec4899;
}

.search-history-item-text {
    flex: 1;
    min-width: 0;
}

.search-history-item-route {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-history-item-meta {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 1px;
}

.search-history-item-arrow {
    flex-shrink: 0;
    font-size: 18px !important;
    color: #d1d5db;
    transition: color 0.15s ease, transform 0.15s ease;
}

.search-history-item:hover .search-history-item-arrow {
    color: #f97316;
    transform: translateX(2px);
}

/* Clear button */
.search-history-clear {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    background: none;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
    transition: color 0.15s ease, background 0.15s ease;
}

.search-history-clear .material-icons-outlined {
    font-size: 16px;
}

.search-history-clear:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .search-history-toggle {
        padding: 0.55rem 0.75rem;
        font-size: 0.8rem;
    }

    .search-history-toggle-left .material-icons-outlined {
        font-size: 18px;
    }

    .search-history-chevron {
        font-size: 18px !important;
    }

    .search-history-item {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .search-history-item-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .search-history-item-route {
        font-size: 0.78rem;
    }

    .search-history-item-meta {
        font-size: 0.65rem;
    }

    .search-history-clear {
        padding: 0.45rem 0.75rem;
        font-size: 0.7rem;
    }
}