/* ========================================
   RESET & BASE
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fafafa;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background 0.5s ease;
}

main {
    width: 100%;
    max-width: 480px;
    animation: slideIn 1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   ANIMATIONS GLOBALES
   ======================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.7);
    }

    to {
        opacity: 0.85;
        transform: scale(1);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInItem {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* ========================================
   RECHERCHE
   ======================================== */

.search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search {
    display: flex;
    gap: 6px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 6px;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.search:focus-within {
    border-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

#input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 6px 10px;
    transition: all 0.3s ease;
}

button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

button:hover {
    background: #f5f5f5;
}

button:active {
    transform: scale(0.92);
    transition-duration: 0.1s;
}

button img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

button:hover img {
    opacity: 0.9;
}

#locate.locating {
    animation: pulse 1.2s ease-in-out infinite;
}

/* ========================================
   AUTOCOMPLÉTION
   ======================================== */

#autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: scroll;
    max-height: 0;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0);
}

#autocomplete.show {
    max-height: 240px;
    opacity: 1;
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.item {
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 1px solid #f5f5f5;
    animation: slideInItem 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.item:nth-child(1) {
    animation-delay: 0.05s;
}

.item:nth-child(2) {
    animation-delay: 0.08s;
}

.item:nth-child(3) {
    animation-delay: 0.11s;
}

.item:nth-child(4) {
    animation-delay: 0.14s;
}

.item:nth-child(5) {
    animation-delay: 0.17s;
}

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

.item:hover {
    background: #f9f9f9;
}

.item div:first-child {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    transition: color 0.2s ease;
}

.item div:last-child {
    font-size: 12px;
    color: #666;
    transition: color 0.2s ease;
}

/* ========================================
   CARTE MÉTÉO
   ======================================== */

#weather {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    animation: fadeIn 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 490px;
}

.loading,
.error {
    font-size: 14px;
    padding: 40px;
    text-align: center;
    min-height: 490px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading {
    color: #999;
    animation: pulse 1.5s ease-in-out infinite;
}

.error {
    color: #d32f2f;
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Header */
.header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
    animation: slideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.4s ease;
}

.name {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
    transition: color 0.3s ease;
}

.date {
    font-size: 13px;
    color: #666;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s backwards;
    transition: color 0.3s ease;
}

/* Section principale */
.main-weather {
    padding: 20px 24px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.4s ease;
}

.icon {
    width: 80px;
    height: 80px;
    opacity: 0.85;
    animation: scaleIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.2s backwards;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-info {
    display: flex;
    align-items: baseline;
    gap: 12px;
    transition: all 0.4s ease;
}

.temp {
    font-size: 48px;
    font-weight: 300;
    line-height: 1;
    animation: countUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.25s backwards;
    transition: all 0.4s ease;
}

.temp-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.desc {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
    transition: color 0.3s ease;
}

.feels-like {
    font-size: 12px;
    color: #999;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.35s backwards;
    transition: color 0.3s ease;
}

/* ========================================
   GRILLE DÉTAILS
   ======================================== */

.details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #f0f0f0;
    transition: all 0.4s ease;
}

.detail {
    background: white;
    padding: 14px 12px;
    text-align: center;
    animation: popIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail:nth-child(1) {
    animation-delay: 0.4s;
}

.detail:nth-child(2) {
    animation-delay: 0.44s;
}

.detail:nth-child(3) {
    animation-delay: 0.48s;
}

.detail:nth-child(4) {
    animation-delay: 0.52s;
}

.detail:nth-child(5) {
    animation-delay: 0.56s;
}

.detail:nth-child(6) {
    animation-delay: 0.6s;
}

.detail:hover {
    background: #fafafa;
}

.detail-label {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.detail-value {
    font-size: 17px;
    font-weight: 600;
    color: #333;
    transition: color 0.3s ease;
}

.detail-unit {
    font-size: 12px;
    font-weight: 400;
    color: #666;
    transition: color 0.3s ease;
}

/* ========================================
   PRÉVISIONS HORAIRES
   ======================================== */

.hourly {
    padding: 18px 24px;
    background: #fafafa;
    animation: fadeInText 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.65s backwards;
    transition: all 0.4s ease;
}

.hourly-title {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    font-weight: 600;
    transition: color 0.3s ease;
}

.hourly-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.hour-item {
    text-align: center;
    padding: 10px 6px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.hour-item:nth-child(1) {
    animation-delay: 0.7s;
}

.hour-item:nth-child(2) {
    animation-delay: 0.74s;
}

.hour-item:nth-child(3) {
    animation-delay: 0.78s;
}

.hour-item:nth-child(4) {
    animation-delay: 0.82s;
}

.hour-item:hover {
    border-color: #d0d0d0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hour-time {
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.hour-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 6px;
    opacity: 0.8;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.hour-temp {
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    main {
        max-width: 100%;
    }

    #weather {
        min-height: 580px;
    }

    .loading,
    .error {
        min-height: 580px;
    }

    .main-weather {
        grid-template-columns: 1fr;
        gap: 12px;
        text-align: center;
    }

    .icon {
        margin: 0 auto;
        width: 70px;
        height: 70px;
    }

    .main-info {
        justify-content: center;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .temp {
        font-size: 42px;
    }

    .details {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail:nth-child(5) {
        grid-column: 1 / 2;
    }

    .detail:nth-child(6) {
        grid-column: 2 / 3;
    }
}