/* -------------------------------------------------- */
/* 1. CSS VARIABLES                                   */
/* -------------------------------------------------- */
:root {
    /* Colors */
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3a0ca3;
    --ev-color: #4cc9f0;
    --conventional-color: #f72585;
    --background: #f8f9fa;
    --card-bg: #ffffff;
    --text: #212529;
    --text-light: #6c757d;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Spacing */
    --space-xs: 0.25rem;  /* 4px */
    --space-sm: 0.5rem;   /* 8px */
    --space-md: 1rem;     /* 16px */
    --space-lg: 1.5rem;   /* 24px */
    --space-xl: 2rem;     /* 32px */
}

/* -------------------------------------------------- */
/* 2. GLOBAL RESET & BASE STYLES                      */
/* -------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    padding: var(--space-md);
}

/* -------------------------------------------------- */
/* 3. LAYOUT COMPONENTS                               */
/* -------------------------------------------------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

/* -------------------------------------------------- */
/* 4. HEADER & BRANDING                               */
/* -------------------------------------------------- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: 10px;
}

.logo-container {
    display: flex;
    align-items: center;
}

.header-content {
    flex: 1;
}

h1 {
    font-size: 2rem;
    margin-bottom: var(--space-xs);
    color: var(--primary);
}

.subtitle {
    color: var(--text-light);
    font-size: 1rem;
}

.logo-text {
    font-size: 38px;
    font-weight: bold;
    letter-spacing: -0.5px;
}

.watt {
    color: #4361ee;
}

.or {
    color: #3a0ca3;
}

.gas {
    color: #f72585;
}

.emoji {
    font-size: 30px;
    margin: 0 var(--space-sm);
}

/* -------------------------------------------------- */
/* 5. REGION SELECTOR                                 */
/* -------------------------------------------------- */
.region-selector {
    display: flex;
    align-items: center;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.region-group {
    display: flex;
    align-items: center;
}

.region-group label {
    margin-right: var(--space-sm);
    font-weight: 500;
}

.region-select {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.9rem;
    cursor: pointer;
}

.flag-icon {
    display: inline-block;
    width: 24px;
    height: 16px;
    vertical-align: middle;
    margin-right: var(--space-sm);
    background-size: cover;
    background-position: center;
}

/* -------------------------------------------------- */
/* 6. VEHICLE COMPARISON SECTION                      */
/* -------------------------------------------------- */
.comparison-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

.vehicle-card {
    position: relative;
    overflow: hidden;
}

.vehicle-card.ev {
    border-top: 5px solid var(--ev-color);
}

.vehicle-card.conventional {
    border-top: 5px solid var(--conventional-color);
}

.vehicle-icon {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    font-size: 1.5rem;
    opacity: 0.7;
}

.vehicle-title {
    font-size: 1.3rem;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

/* -------------------------------------------------- */
/* 7. FORM CONTROLS & INPUTS                          */
/* -------------------------------------------------- */
.input-group {
    margin-bottom: var(--space-sm);
}

.input-group-row {
    display: flex;
    align-items: top;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.input-group-row label {
    font-weight: 500;
    flex: 1;
    min-width: 150px;
}

.input-controls {
    flex: 2;
}

.input-group .input-help {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    vertical-align: baseline;
    margin-top: var(--space-xs);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.7rem;
    font-size: 1rem;
    color: var(--text-light);
    z-index: 1;
}

input[type="number"], 
input[type="text"] {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: var(--space-sm) var(--space-md);
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.3s;
}

input[type="number"]:focus, 
input[type="text"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.input-with-icon input {
    padding-left: var(--space-xl);
}

/* -------------------------------------------------- */
/* 8. SLIDERS                                         */
/* -------------------------------------------------- */
.slider-container {
    width: 100%;
    padding: var(--space-sm) 0;
}

.slider-container > div {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}

/* Slider thumb for different browsers */
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: background .3s;
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: background .3s;
}

/* Vehicle-specific slider styles */
.ev .range-slider::-webkit-slider-thumb {
    background-color: var(--ev-color);
    border: none;
}

.conventional .range-slider::-webkit-slider-thumb {
    background-color: var(--conventional-color);
    border: none;
}

.ev .range-slider::-moz-range-thumb {
    background-color: var(--ev-color);
    border: none;
}

.conventional .range-slider::-moz-range-thumb {
    background-color: var(--conventional-color);
    border: none;
}

.slider-values {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-xs);
    font-size: 0.8rem;
    color: var(--text-light);
}

.slider-value {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    margin-top: var(--space-xs);
    color: var(--text);
}

/* -------------------------------------------------- */
/* 9. RESULTS DISPLAY                                 */
/* -------------------------------------------------- */
.results-card {
    background: linear-gradient(to right, var(--ev-color), var(--conventional-color));
    color: white;
    text-align: center;
    padding-top: var(--space-lg);
}

.results-content {
    background: var(--card-bg);
    border-radius: 8px 8px 0 0;
    padding: var(--space-md);
    margin-top: var(--space-md);
    color: var(--text);
}

.results-title {
    font-size: 1.3rem;
    margin-bottom: var(--space-md);
    color: white;
}

/* Cost comparison components */
.cost-comparison {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.cost-item, .annual-cost-item {
    text-align: center;
    flex: 1;
}

.cost-item.ev {
    color: var(--ev-color);
}

.cost-item.conventional {
    color: var(--conventional-color);
}

.cost-value, .annual-cost-value {
    font-weight: 700;
}

.cost-value {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

.annual-cost-value {
    font-size: 1.2rem;
}

.cost-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Visual cost comparison bar */
.cost-comparison-bar {
    height: 40px;
    background: #f1f3f5;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.cost-bar {
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 20px;
}

.cost-bar.ev {
    background-color: var(--ev-color);
    width: 40%;
    z-index: 2;
}

.cost-bar.conventional {
    background-color: var(--conventional-color);
    width: 70%;
    z-index: 1;
}

.annual-cost {
    display: flex;
    justify-content: space-between;
    background: var(--background);
    padding: var(--space-md);
    border-radius: 8px;
    margin-top: var(--space-md);
}

.annual-mileage {
    margin-top: var(--space-md);
}

/* -------------------------------------------------- */
/* 10. TOOLTIPS                                       */
/* -------------------------------------------------- */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 12px;
    text-align: center;
    cursor: help;
    position: relative;
}

/* Base tooltip styling */
.tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 24px;
    width: 250px;
    padding: var(--space-sm);
    border-radius: 6px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    line-height: 1.4;
    z-index: 100;
    pointer-events: none;
    white-space: normal;
    text-align: left;
}

/* Base arrow styling */
.tooltip-icon:hover::before {
    content: "";
    position: absolute;
    bottom: 20px;
    border-width: 4px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
    z-index: 100;
}

/* Desktop positioning */
@media (min-width: 769px) {
    .tooltip-icon:hover::after {
        left: 0;
    }
    
    .tooltip-icon:hover::before {
        left: 10px;
    }
}

/* Mobile positioning - fixed positioning relative to viewport */
@media (max-width: 768px) {
    .tooltip-icon {
        position: relative;
    }
    
    .tooltip-icon:hover::after {
        left: 50%;
        transform: translateX(-50%);
        
        /* Fallback for devices that don't support transforms */
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        
        /* Ensure iPhone/iOS compatibility */
        max-width: 80vw;
        text-align: center;
    }
    
    .tooltip-icon:hover::before {
        left: 50%;
        transform: translateX(-50%);
        
        /* Fallback for devices that don't support transforms */
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        width: 0;
    }
}

/* Extra small device adjustments */
@media (max-width: 320px) {
    .tooltip-icon:hover::after {
        width: calc(100vw - 20px);
        padding: var(--space-xs);
    }
}

/* -------------------------------------------------- */
/* 11. FOOTER                                         */
/* -------------------------------------------------- */
footer {
    text-align: center;
    margin-top: var(--space-lg);
    padding-bottom: var(--space-sm);
    color: var(--text-light);
    font-size: 0.9rem;
}

.feedback-request {
    margin-top: var(--space-xs);
    font-size: 0.85rem;
}

.email {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-light);
    text-decoration: none;
    position: relative;
    padding-bottom: 1px;
    border-bottom: 1px dotted var(--text-light);
}

.email:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* -------------------------------------------------- */
/* 12. RESPONSIVE LAYOUTS                             */
/* -------------------------------------------------- */
@media (min-width: 768px) {
    .comparison-section {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .region-selector {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .cost-comparison, 
    .annual-cost {
        flex-direction: column;
        gap: var(--space-md);
    }

    .input-group-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .input-controls {
        width: 100%;
    }
}