/* ==========================================
   VARIABLES ET RESET
   ========================================== */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-dark: #1f2937;
    --text-light: #4b5563;
    --white: #ffffff;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

/* ==========================================
   BODY ET BACKGROUNDS DYNAMIQUES
   ========================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    transition: background 1s ease;
    position: relative;
    overflow-x: hidden;
}

footer {
    text-align: center;
    color: white;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.5);
}

/* Backgrounds selon la météo */
body.clear-day {
    background: linear-gradient(135deg, #FDB99B 0%, #FCE77D 50%, #87CEEB 100%);
}

body.clear-night {
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

body.clouds {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 50%, #7f8c8d 100%);
}

body.rain,
body.drizzle {
    background: linear-gradient(135deg, #536976 0%, #292E49 100%);
}

body.thunderstorm {
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
}

body.snow {
    background: linear-gradient(135deg, #E6DADA 0%, #A8CABA 100%);
}

body.mist,
body.fog,
body.haze {
    background: linear-gradient(135deg, #C9D6FF 0%, #E2E2E2 100%);
}

/* ==========================================
   PARTICULES MÉTÉO
   ========================================== */
.weather-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Soleil */
.sun {
    position: fixed;
    top: 80px;
    right: 80px;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, #FDB813 0%, #F59E0B 100%);
    border-radius: 50%;
    box-shadow: 0 0 80px rgba(253, 184, 19, 0.8), 0 0 120px rgba(253, 184, 19, 0.4);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

/* Lune */
.moon {
    position: fixed;
    top: 80px;
    right: 80px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at 30% 30%, #F4F1DE 0%, #E8E4CC 100%);
    border-radius: 50%;
    box-shadow: 0 0 60px rgba(244, 241, 222, 0.7), inset -10px -10px 20px rgba(0, 0, 0, 0.1);
}

/* Étoiles */
.star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
    animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Nuages */
.cloud {
    position: absolute;
    background: radial-gradient(circle at 30% 40%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.4) 45%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 50%;
    animation: drift var(--cloud-duration, 60s) linear infinite;
    opacity: var(--cloud-opacity, 0.65);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    filter: blur(calc(var(--cloud-blur, 0px) + 3px));
    mix-blend-mode: screen;
    overflow: visible;
}

.cloud::after,
.cloud::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle at 40% 60%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.2) 60%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50%;
    filter: blur(6px);
    opacity: 0.8;
}

.cloud::after {
    top: -10%;
    left: 15%;
    transform: scaleX(1.2);
}

.cloud::before {
    bottom: -5%;
    right: 10%;
    transform: scale(0.9);
}

.cloud.fog {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.15) 60%, rgba(255, 255, 255, 0) 100%);
    filter: blur(15px);
    opacity: 0.45;
}

.cloud.fog::after,
.cloud.fog::before {
    opacity: 0.4;
    filter: blur(12px);
}

@keyframes drift {
    from {
        transform: translateX(calc(-150% - var(--cloud-shift, 0px)));
    }
    to {
        transform: translateX(calc(150vw + var(--cloud-shift, 0px)));
    }
}

/* Pluie */
.rain-drop {
    position: absolute;
    width: 2px;
    height: 20px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(174, 194, 224, 0.2));
    animation: fall var(--fall-duration, 0.9s) linear infinite;
    opacity: 0.7;
    border-radius: 2px;
    transform: translate3d(0, -10vh, 0);
}

@keyframes fall {
    to {
        transform: translate3d(var(--drift, 0px), 110vh, 0);
        opacity: 0;
    }
}

/* Neige */
.snow-flake {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: snowfall var(--snow-duration, 7s) linear infinite;
    opacity: 0.9;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    transform: translate3d(0, -10vh, 0);
}

@keyframes snowfall {
    to {
        transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(360deg);
        opacity: 0;
    }
}

/* Flash d'éclair */
.lightning-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 70%);
    opacity: 0;
    animation: flash 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 2;
}

@keyframes flash {
    0% { opacity: 0; }
    10% { opacity: 0.9; }
    100% { opacity: 0; }
}

/* Couches de brume */
.mist-layer {
    position: absolute;
    left: -10%;
    width: 120%;
    height: 45%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    filter: blur(20px);
    opacity: 0.35;
    animation: drift-mist var(--mist-duration, 40s) ease-in-out infinite;
}

.mist-layer:nth-child(odd) {
    top: 10%;
}

.mist-layer:nth-child(even) {
    top: 40%;
}

@keyframes drift-mist {
    0% { transform: translateX(-10%); }
    50% { transform: translateX(10%); }
    100% { transform: translateX(-10%); }
}

/* ==========================================
   CONTAINER ET LAYOUT
   ========================================== */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.main-title {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.5px;
}

/* ==========================================
   CARTES MÉTÉO
   ========================================== */
.weather-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%); /* Pour Safari */
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.18);
    /* Effet de buée avec un dégradé subtil */
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
}

/* Carte météo principale (pas la recherche) */
#weatherDisplay .weather-card {
    z-index: 1;
}

/* ==========================================
   BARRE DE RECHERCHE
   ========================================== */
.search-container {
    position: relative;
    margin-bottom: 2rem;
    z-index: 100;
}

/* S'assurer que le conteneur de recherche passe au-dessus de la carte météo */
.search-container.weather-card {
    z-index: 100 !important;
}

.search-input {
    width: 100%;
    padding: 1rem 140px 1rem 1.5rem;
    font-size: 1.125rem;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%); /* Pour Safari */
    background-image: 
        radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
}

.search-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
}

.search-btn {
    display: none;
}

.search-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.search-btn:active {
    transform: translateY(-50%) scale(0.98);
}

/* Autocomplétion */
.autocomplete-list {
    position: absolute;
    width: 100%;
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(31, 38, 135, 0.3);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
}

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

.autocomplete-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-dark);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}

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

.autocomplete-item:hover {
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    color: var(--primary-color);
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6);
}

/* ==========================================
   AFFICHAGE MÉTÉO PRINCIPAL
   ========================================== */
.weather-display {
    animation: fadeIn 0.6s ease-out;
}

.weather-display.hidden {
    display: none;
}

.weather-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .weather-main {
        grid-template-columns: 1fr;
    }
}

/* Informations principales */
.weather-info-main {
    display: flex;
    flex-direction: column;
}

.city-name {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(255, 255, 255, 0.4);
}

.country-date {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 2rem;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8), 0 2px 6px rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

.weather-current {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.weather-icon {
    width: 140px;
    height: 140px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.weather-temp-info {
    margin-left: 1.5rem;
}

.temperature {
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.9), 0 4px 20px rgba(255, 255, 255, 0.5);
}

.description {
    font-size: 1.5rem;
    color: var(--text-light);
    text-transform: capitalize;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.9), 0 2px 8px rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.feels-like {
    color: var(--text-light);
    font-size: 1.125rem;
    margin-top: 1rem;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8), 0 2px 6px rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

/* Détails météo */
.weather-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 480px) {
    .weather-details {
        grid-template-columns: 1fr;
    }
}

.detail-item {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%); /* Pour Safari */
    padding: 1.25rem;
    border-radius: 16px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.18);
    /* Effet de buée localisé */
    background-image: 
        radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.25) 0%, transparent 60%);
}

.detail-item:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    box-shadow: 0 12px 28px rgba(31, 38, 135, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.35) 0%, transparent 70%);
}

.detail-label {
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(255, 255, 255, 0.5);
}

.detail-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    text-shadow: 0 2px 6px rgba(255, 255, 255, 0.8), 0 3px 10px rgba(255, 255, 255, 0.4);
}

/* Lever/coucher du soleil */
.sun-times {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid rgba(255, 255, 255, 0.25);
    display: flex;
    justify-content: space-around;
}

.sun-time-item {
    text-align: center;
}

.sun-time-label {
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(255, 255, 255, 0.5);
}

.sun-time-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    text-shadow: 0 2px 6px rgba(255, 255, 255, 0.8), 0 3px 10px rgba(255, 255, 255, 0.4);
}

/* ==========================================
   LOADING ET MESSAGES
   ========================================== */
.loading {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    background: #fee2e2;
    border: 2px solid #fecaca;
    color: #991b1b;
    padding: 1rem 1.5rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.error-message.hidden {
    display: none;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   SCROLLBAR PERSONNALISÉE
   ========================================== */
.autocomplete-list::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-list::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.autocomplete-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.autocomplete-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    .main-title {
        font-size: 2rem;
    }
    
    .city-name {
        font-size: 2rem;
    }
    
    .temperature {
        font-size: 3rem;
    }
    
    .weather-icon {
        width: 100px;
        height: 100px;
    }
    
    .sun {
        top: 40px;
        right: 40px;
        width: 80px;
        height: 80px;
    }
    
    .moon {
        top: 40px;
        right: 40px;
        width: 70px;
        height: 70px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .weather-card {
        padding: 1.5rem;
    }
    
    .search-input {
        padding: 0.875rem 120px 0.875rem 1rem;
    }
    
    .search-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
}

