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

:root {
    --color-primary: #4a90a4;
    --color-primary-dark: #3a7a94;
    --color-text: #333;
    --color-text-light: #666;
    --color-bg: #f5f7fa;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 30px 60px -15px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    transition: background 1.5s ease, color 1s ease;
    overflow-x: hidden;
}

.contenedor {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 2rem;
}

/*  TEMAS */

body.tema-dia {
    background: linear-gradient(135deg, #74b9ff 0%, #a29bfe 50%, #fd79a8 100%);
    color: #2d3436;
}

body.tema-tarde {
    background: linear-gradient(135deg, #fdcb6e 0%, #e17055 50%, #d63031 100%);
    color: #2d3436;
}

body.tema-noche {
    background: linear-gradient(135deg, #0c0c1e 0%, #1a1a3e 50%, #2d2d5a 100%);
    color: #f5f6fa;
    --color-primary: #6c5ce7;
    --color-primary-dark: #5b4cdb;
}

/*  ANIMACIONES DE FONDO */

.estrellas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

body.tema-noche .estrellas {
    opacity: 1;
}

.estrellas::before,
.estrellas::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, #fff, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 370px 50px, #fff, transparent),
        radial-gradient(2px 2px at 450px 180px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 520px 90px, #fff, transparent),
        radial-gradient(2px 2px at 600px 130px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 680px 200px, #fff, transparent),
        radial-gradient(2px 2px at 750px 60px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 100px 250px, #fff, transparent),
        radial-gradient(2px 2px at 200px 300px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 350px 280px, #fff, transparent),
        radial-gradient(2px 2px at 500px 320px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 650px 350px, #fff, transparent);
    background-repeat: repeat;
    background-size: 800px 400px;
    animation: parpadeoEstrellas 4s ease-in-out infinite;
}

.estrellas::after {
    background-position: 50% 50%;
    animation-delay: 2s;
}

@keyframes parpadeoEstrellas {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.nubes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

body.tema-tarde .nubes {
    opacity: 1;
}

.nube {
    position: absolute;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50px;
    filter: blur(3px);
}

.nube::before,
.nube::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.nube-1 {
    width: 150px;
    height: 50px;
    top: 12%;
    left: -180px;
    animation: flotarNube 28s linear infinite;
}

.nube-1::before {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 25px;
}

.nube-1::after {
    width: 45px;
    height: 45px;
    top: -20px;
    left: 75px;
}

.nube-2 {
    width: 120px;
    height: 40px;
    top: 30%;
    left: -140px;
    animation: flotarNube 32s linear infinite;
    animation-delay: 10s;
}

.nube-2::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 20px;
}

.nube-2::after {
    width: 35px;
    height: 35px;
    top: -15px;
    left: 60px;
}

.nube-3 {
    width: 100px;
    height: 35px;
    top: 55%;
    left: -120px;
    animation: flotarNube 38s linear infinite;
    animation-delay: 18s;
}

.nube-3::before {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 15px;
}

.nube-3::after {
    width: 30px;
    height: 30px;
    top: -12px;
    left: 50px;
}

@keyframes flotarNube {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(100vw + 250px)); }
}

.rayos-sol {
    position: fixed;
    top: -40%;
    right: -20%;
    width: 700px;
    height: 700px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
    background: radial-gradient(circle, rgba(255, 236, 179, 0.4) 0%, transparent 70%);
    animation: brilloSol 5s ease-in-out infinite;
}

body.tema-dia .rayos-sol {
    opacity: 1;
}

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

/*  CARD PRINCIPAL */

.clima-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 30px;
    text-align: center;
    position: relative;
    z-index: 10;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 380px;
    max-width: 450px;
}

.clima-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/*  ICONO DEL CLIMA */

.clima-icono {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    position: relative;
}

.icono-clima {
    font-size: 80px;
    animation: flotar 3s ease-in-out infinite;
}

@keyframes flotar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/*  UBICACIÓN */

.ubicacion {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ubicacion-icono {
    font-size: 1.2rem;
}

.pais {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-text-light);
    margin-bottom: 2rem;
}

/*  TEMPERATURA PRINCIPAL */

.temperatura-principal {
    margin-bottom: 2.5rem;
}

.temperatura-valor {
    font-size: 5.5rem;
    font-weight: 200;
    line-height: 1;
    background: linear-gradient(135deg, var(--color-primary), #6c5ce7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    display: inline-block;
}

.temperatura-valor::after {
    content: '°C';
    font-size: 1.8rem;
    position: absolute;
    top: 0.5rem;
    margin-left: 0.3rem;
    -webkit-text-fill-color: var(--color-primary);
}

.condicion {
    font-size: 1.1rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
    text-transform: capitalize;
}

/*  DATOS SECUNDARIOS */

.datos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dato-card {
    background: linear-gradient(135deg, rgba(74, 144, 164, 0.1), rgba(108, 92, 231, 0.1));
    padding: 1.25rem 1rem;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.dato-card:hover {
    transform: translateY(-3px);
    background: linear-gradient(135deg, rgba(74, 144, 164, 0.15), rgba(108, 92, 231, 0.15));
}

body.tema-noche .dato-card {
    background: rgba(255, 255, 255, 0.08);
}

body.tema-noche .dato-card:hover {
    background: rgba(255, 255, 255, 0.12);
}

.dato-icono {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.dato-valor {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--color-text);
}

body.tema-noche .dato-valor {
    color: #f5f6fa;
}

.dato-valor .unidad {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-text-light);
}

body.tema-noche .dato-valor .unidad {
    color: #a0a0a0;
}

.dato-label {
    font-size: 0.75rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.3rem;
}

body.tema-noche .dato-label {
    color: #a0a0a0;
}

/*  BÚSQUEDA */

.busqueda-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.tema-noche .busqueda-container {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.busqueda-wrapper {
    position: relative;
}

.busqueda-input {
    width: 100%;
    padding: 1rem 3.5rem 1rem 1.25rem;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.03);
}

body.tema-noche .busqueda-input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f5f6fa;
}

.busqueda-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(74, 144, 164, 0.15);
}

.busqueda-input::placeholder {
    color: var(--color-text-light);
}

body.tema-noche .busqueda-input::placeholder {
    color: #888;
}

.boton-buscar {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--color-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boton-buscar svg {
    width: 20px;
    height: 20px;
    stroke: white;
    transition: stroke 0.3s ease;
}

.boton-buscar:hover {
    background: var(--color-primary-dark);
    transform: translateY(-50%) scale(1.05);
}

.boton-buscar:hover svg {
    stroke: rgba(255, 255, 255, 0.8);
}

/*  RESULTADOS DE BÚSQUEDA */

.resultados-busqueda {
    margin-top: 0.75rem;
    background: white;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s ease;
}

.resultados-busqueda.mostrar {
    max-height: 300px;
    opacity: 1;
}

.resultado-item {
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.resultado-item:hover {
    background: rgba(74, 144, 164, 0.08);
}

.resultado-icono {
    font-size: 1.2rem;
    color: var(--color-primary);
}

.resultado-info {
    flex: 1;
}

.resultado-nombre {
    font-weight: 500;
    color: var(--color-text);
}

.resultado-detalle {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

body.tema-noche .resultado-item {
    background: rgba(30, 30, 60, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.tema-noche .resultado-nombre {
    color: #f5f6fa;
}

body.tema-noche .resultado-detalle {
    color: #888;
}

body.tema-noche .resultado-item:hover {
    background: rgba(74, 144, 164, 0.15);
}

/*  ERROR */

.mensaje-error {
    color: #e74c3c;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 10px;
    font-size: 0.9rem;
    display: none;
}

.mensaje-error.mostrar {
    display: block;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

body.tema-noche .mensaje-error {
    color: #ff7675;
    background: rgba(255, 118, 117, 0.15);
}

/*  LOADING */

.loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
}

.loading.mostrar {
    display: flex;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(74, 144, 164, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/*  FOOTER */

.footer {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}

body.tema-noche .footer {
    color: rgba(255, 255, 255, 0.4);
}

/*  RESPONSIVE */

@media (max-width: 480px) {
    .contenedor {
        padding: 1rem;
    }
    
    .clima-card {
        padding: 2rem 1.5rem;
        min-width: 100%;
        border-radius: 24px;
    }
    
    .clima-icono {
        width: 100px;
        height: 100px;
    }
    
    .icono-clima {
        font-size: 60px;
    }
    
    .temperatura-valor {
        font-size: 4.5rem;
    }
    
    .datos-grid {
        gap: 1rem;
    }
    
    .dato-card {
        padding: 1rem 0.75rem;
    }
    
    .dato-valor {
        font-size: 1.3rem;
    }
}
