/* Modern CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --secondary-color: #4CAF50;
    --background-color: #f5f5f5;
    --text-color: #333;
    --card-background: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --button-hover: #1976D2;
    --button-active: #1565C0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    color: var(--primary-color);
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 10px;
    word-wrap: break-word;
}

h2 {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    margin-bottom: 15px;
}

h3 {
    color: var(--text-color);
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 15px;
    text-align: center;
}

.subtitle {
    color: #666;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

/* Temperature Display Section */
.temperature-display {
    margin-bottom: clamp(20px, 5vh, 40px);
}

.temperature-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: clamp(15px, 4vw, 30px);
    text-align: center;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: transform 0.3s ease;
}

.temperature-card:hover {
    transform: translateY(-5px);
}

.temperature-card i {
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--primary-color);
    margin-bottom: 20px;
}

.temperature {
    font-size: clamp(2rem, 7vw, 3.5rem);
    font-weight: bold;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 20px 0 10px 0;
    line-height: 1.2;
}

.temperature-labels {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: #666;
    margin-bottom: 15px;
}

.last-updated {
    color: #666;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
}

/* Temperature History Section */
.temperature-history {
    background: var(--card-background);
    border-radius: 15px;
    padding: clamp(15px, 4vw, 20px);
    box-shadow: 0 4px 6px var(--shadow-color);
}

.history-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.history-header h2 {
    margin-bottom: 0;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

/* Compare Toggle Switch */
.compare-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    color: var(--text-color);
    background: var(--background-color);
    padding: clamp(4px, 2vw, 6px) clamp(10px, 3vw, 15px);
    border-radius: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 2px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 22px;
}

.slider.round:before {
    border-radius: 50%;
}

.time-range-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.time-range-btn {
    flex: 1;
    min-width: 80px;
    padding: clamp(6px, 2vw, 8px) clamp(10px, 3vw, 16px);
    border: none;
    border-radius: 8px;
    background-color: var(--background-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
}

.time-range-btn:hover {
    background-color: var(--button-hover);
    color: white;
}

.time-range-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

.chart-wrapper {
    background: var(--background-color);
    border-radius: 10px;
    padding: 15px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    margin: 0;
}

.unit-toggle {
    display: flex;
    gap: 4px;
    background: var(--card-background);
    padding: 4px;
    border-radius: 6px;
}

.unit-btn {
    border: none;
    background: transparent;
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.unit-btn:hover {
    background-color: var(--background-color);
}

.unit-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.chart-container {
    position: relative;
    height: clamp(200px, 50vh, 300px);
    width: 100%;
}

/* Weather Forecast Section */
.weather-forecast {
    background: var(--card-background);
    border-radius: 15px;
    padding: clamp(15px, 4vw, 30px);
    margin-top: 40px;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.forecast-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.forecast-card {
    background: var(--background-color);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.forecast-card:hover {
    transform: translateY(-5px);
}

.forecast-date {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--primary-color);
    margin-bottom: 15px;
}

.weather-icon {
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 10px 0;
    color: var(--primary-color);
}

.forecast-temp {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: bold;
    margin: 10px 0;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.forecast-desc {
    font-size: clamp(0.9rem, 2.2vw, 1rem);
    color: var(--text-color);
    opacity: 0.8;
}

.forecast-card .temp-minmax {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: var(--text-color);
    opacity: 0.8;
}

.forecast-card .temp-minmax span {
    padding: 2px 8px;
    border-radius: 4px;
    background-color: var(--card-background);
}

/* Footer */
footer {
    text-align: center;
    margin-top: clamp(20px, 5vh, 40px);
    padding: 20px;
    color: #666;
    font-size: clamp(0.8rem, 2vw, 1rem);
}

/* Responsive Design */
@media (min-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr 1fr;
    }

    .time-range-selector {
        width: auto;
    }

    .time-range-btn {
        flex: 0 1 auto;
    }

    .history-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .header-controls {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        width: 100%;
    }

    .current-temps {
        width: 100%;
    }

    .temp-container {
        width: 100%;
        justify-content: center;
    }

    .temp-item {
        width: 100%;
        max-width: 350px;
        margin: 0 auto 15px auto;
    }

    .temperature-history {
        width: 100%;
    }

    .forecast-container {
        width: 100%;
    }

    .forecast-card {
        width: 100%;
        max-width: 350px;
        margin: 0 auto 15px auto;
    }
}

/* Touch Device Optimizations */
@media (hover: none) {
    .temperature-card {
        transform: none !important;
    }

    .time-range-btn {
        padding: clamp(10px, 3vw, 12px) clamp(15px, 4vw, 20px);
    }
}

/* Small Screen Optimizations */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    .temp-item {
        padding: 12px;
        max-width: 100%;
    }

    .forecast-card {
        max-width: 100%;
    }

    .time-range-btn {
        padding: 8px;
        font-size: 0.75rem;
        width: 100%;
    }

    .chart-container {
        height: 180px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #121212;
        --card-background: #1e1e1e;
        --text-color: #ffffff;
        --shadow-color: rgba(0, 0, 0, 0.3);
    }

    .temperature-labels,
    .last-updated,
    .subtitle,
    footer {
        color: #999;
    }
}

/* Current Temperatures Section */
.current-temps {
    background: var(--card-background);
    border-radius: 15px;
    padding: clamp(20px, 4vw, 30px);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.current-temps h2 {
    margin: 0 0 20px 0;
    color: var(--primary-color);
    font-size: clamp(1.5rem, 3vw, 2rem);
    text-align: center;
}

.temp-container {
    display: flex;
    justify-content: center;
    gap: clamp(20px, 4vw, 40px);
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.temp-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--background-color);
    border-radius: 10px;
    min-width: 200px;
    transition: transform 0.3s ease;
}

.temp-item:hover {
    transform: translateY(-3px);
}

.temp-item i {
    font-size: clamp(2rem, 4vw, 2.5rem);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
}

/* Weather Widget Styles */
.weather-widget .weather-desc-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.temp-item.weather-widget i.weather-icon {
    font-size: 1.2rem;
    width: auto;
    margin: 0;
}

.weather-widget #currentWeatherDesc {
    font-size: 0.9rem;
    text-transform: capitalize;
    color: var(--text-color);
    opacity: 0.9;
}

.temp-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.temp-label {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-color);
    opacity: 0.8;
}

.temp-value {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: bold;
    color: var(--text-color);
    line-height: 1;
}

.temp-minmax {
    display: flex;
    gap: 10px;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 5px;
}

.temp-minmax span {
    flex: 1;
    white-space: nowrap;
}

.weather-widget .temp-minmax {
    justify-content: space-between;
    margin-top: 8px;
}

.last-updated {
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: var(--text-color);
    opacity: 0.7;
}

/* Comfort Badge Styles */
.comfort-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-top: 5px;
    text-align: center;
    transition: all 0.3s ease;
}

.comfort-badge.froid {
    background-color: rgba(33, 150, 243, 0.2);
    color: #1976D2;
}

.comfort-badge.rafraichissante {
    background-color: rgba(0, 188, 212, 0.2);
    color: #0097A7;
}

.comfort-badge.parfaite {
    background-color: rgba(76, 175, 80, 0.2);
    color: #388E3C;
}

.comfort-badge.chaude {
    background-color: rgba(255, 152, 0, 0.2);
    color: #F57C00;
}

/* Trend Icon Styles */
.temp-value-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trend-icon {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.trend-up {
    color: #F44336;
}

.trend-down {
    color: #2196F3;
}

.trend-stable {
    color: #9E9E9E;
}

/* Weather Extras Styles */
.weather-extras {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
    color: var(--text-color);
    opacity: 0.7;
}

.weather-extras span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* UV Index Colors */
.uv-low { color: #4CAF50 !important; }
.uv-moderate { color: #FBC02D !important; }
.uv-high { color: #FF9800 !important; }
.uv-very-high { color: #F44336 !important; }
.uv-extreme { color: #9C27B0 !important; }