/* =====================================================================
   Clima La Plata — Estilos
   Paleta: rojo (#e11d2e / #ff3b30), negro (#0a0a0c), gris (#9aa0a6)
   Estilo moderno, responsive, mobile-first.
   ===================================================================== */

:root {
    --bg:            #0a0a0c;
    --bg-elevated:   #111114;
    --topbar-bg:     rgba(10, 10, 12, 0.72);
    --surface:       #16161a;
    --surface-2:     #1c1c22;
    --border:        #26262e;
    --border-soft:   #1f1f26;

    --red:           #e11d2e;
    --red-bright:    #ff3b30;
    --red-soft:      rgba(225, 29, 46, 0.14);

    --text:          #f2f3f5;
    --text-muted:    #9aa0a6;
    --text-dim:      #6c7278;

    --radius-lg:     24px;
    --radius-md:     16px;
    --radius-sm:     12px;

    --shadow:        0 20px 50px -20px rgba(0, 0, 0, 0.8);
    --shadow-red:    0 12px 40px -12px rgba(225, 29, 46, 0.45);

    --font-display:  'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-body:     'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --max-w: 1080px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a { color: var(--red-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Resplandor decorativo de fondo */
.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(600px 400px at 85% -10%, rgba(225, 29, 46, 0.16), transparent 60%),
        radial-gradient(700px 500px at -10% 20%, rgba(225, 29, 46, 0.08), transparent 60%);
}

.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

/* ============================= Topbar ============================= */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
    padding: 8px 0;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--red), #8f0f1c);
    box-shadow: var(--shadow-red);
}

.brand-text {
    font-family: var(--font-display);
    line-height: 1.15;
    margin: 0;
}
.brand-title {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.brand-title strong { color: var(--red-bright); font-weight: 700; }
.brand-sub {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.theme-toggle:hover { border-color: var(--red); transform: translateY(-1px); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 9px;
    border-radius: 999px;
    color: #16a34a;
    background: rgba(22, 163, 74, 0.12);
    border: 1px solid rgba(22, 163, 74, 0.35);
    white-space: nowrap;
}
.source-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.source-badge.modelo {
    color: var(--text-muted);
    background: var(--surface-2);
    border-color: var(--border);
}

/* ============================= Estados ============================= */
.state {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 16px;
}

.spinner {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--red-bright);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-icon {
    font-size: 2.4rem;
    width: 72px; height: 72px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--red-soft);
    color: var(--red-bright);
}
.state h1 { font-family: var(--font-display); color: var(--text); font-size: 1.4rem; }

.btn {
    margin-top: 6px;
    font: 600 0.95rem var(--font-body);
    color: #fff;
    background: linear-gradient(135deg, var(--red), var(--red-bright));
    border: none;
    padding: 11px 26px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-red);
    transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.hidden { display: none !important; }

/* ============================= Hero ============================= */
.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 22px 0 18px;
    padding: 26px 24px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(160deg, rgba(225, 29, 46, 0.12), transparent 45%),
        var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero-location {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.hero-location svg { color: var(--red-bright); }

.hero-temp-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.hero-icon { font-size: 3.4rem; line-height: 1; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5)); }

.hero-temp {
    font-family: var(--font-display);
    font-size: clamp(3.6rem, 12vw, 5.4rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.hero-desc {
    margin-top: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.hero-feels { margin-top: 4px; font-size: 0.9rem; color: var(--text-muted); }

.hero-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: center;
}

.detail {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}
.detail-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================= Paneles ============================= */
.panel {
    margin-bottom: 18px;
    padding: 22px 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.panel-head h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.panel-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--red-bright);
    background: var(--red-soft);
    border: 1px solid rgba(225, 29, 46, 0.3);
    padding: 4px 10px;
    border-radius: 999px;
}

/* ----------------------------- Horario ----------------------------- */
.hourly-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.hourly-scroll::-webkit-scrollbar { height: 6px; }
.hourly-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.hour-card {
    flex: 0 0 auto;
    width: 84px;
    scroll-snap-align: start;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.hour-card:hover { border-color: var(--red); transform: translateY(-3px); }
.hour-card.now {
    background: linear-gradient(160deg, rgba(225, 29, 46, 0.18), var(--surface-2));
    border-color: var(--red);
}

.hour-time { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.hour-emoji { font-size: 1.6rem; line-height: 1; }
.hour-temp { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.hour-rain { font-size: 0.7rem; color: #7db8ff; display: flex; align-items: center; gap: 3px; }
.hour-rain svg { flex: none; }

/* ----------------------------- Diario ----------------------------- */
.daily-list { display: flex; flex-direction: column; gap: 8px; }

.day-row {
    display: grid;
    grid-template-columns: 96px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    transition: border-color 0.15s ease;
}
.day-row:hover { border-color: var(--red); }

.day-name { font-weight: 600; font-size: 0.95rem; }
.day-name.today { color: var(--red-bright); }
.day-date { font-size: 0.75rem; color: var(--text-dim); }

.day-cond { display: flex; align-items: center; gap: 10px; min-width: 0; }
.day-emoji { font-size: 1.5rem; line-height: 1; }
.day-desc { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.day-temps { display: flex; align-items: center; gap: 10px; }
.day-temp { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.day-temp.max { color: var(--text); }
.day-temp.min { color: var(--text-dim); }

/* Barra de rango de temperatura */
.day-range { display: none; }

/* ============================= Footer ============================= */
.footer {
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
    padding: 20px 0;
    background: var(--bg-elevated);
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ============================= Tema claro ============================= */
[data-theme="light"] {
    --bg:          #eef0f4;
    --bg-elevated: #ffffff;
    --surface:     #ffffff;
    --surface-2:   #f4f5f8;
    --border:      #dfe3e9;
    --border-soft: #e9ecf1;
    --text:        #171a20;
    --text-muted:  #525861;
    --text-dim:    #878d96;
    --red-soft:    rgba(225, 29, 46, 0.10);
    --shadow:      0 18px 40px -22px rgba(20, 24, 32, 0.20);
    --shadow-red:  0 12px 32px -14px rgba(225, 29, 46, 0.35);
    --topbar-bg:   rgba(238, 240, 244, 0.82);
}

[data-theme="light"] .bg-glow {
    background:
        radial-gradient(600px 400px at 85% -10%, rgba(225, 29, 46, 0.09), transparent 60%),
        radial-gradient(700px 500px at -10% 20%, rgba(225, 29, 46, 0.05), transparent 60%);
}

[data-theme="light"] .hero {
    background:
        linear-gradient(160deg, rgba(225, 29, 46, 0.07), transparent 45%),
        var(--surface);
}

[data-theme="light"] .hour-card.now {
    background: linear-gradient(160deg, rgba(225, 29, 46, 0.12), var(--surface-2));
}

/* Transición suave al cambiar de tema */
body, .topbar, .hero, .panel, .detail, .day-row, .hour-card, .footer, .theme-toggle {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ============================= Responsive ============================= */
@media (min-width: 640px) {
    .hero { grid-template-columns: 1.2fr 1fr; align-items: center; }
    .hero-details { grid-template-columns: repeat(2, 1fr); }
    .day-row { grid-template-columns: 120px 1fr auto; }
    .container { padding: 0 24px; }
    .panel { padding: 26px 26px; }
}

@media (min-width: 900px) {
    .hero { padding: 34px 38px; }
    .hour-card { width: 96px; }
    .day-row { padding: 14px 20px; }
}

@media (max-width: 640px) {
    /* En pantallas chicas el nombre ocupa más líneas: el botón se
       mantiene arriba a la derecha, alineado con el título. */
    .topbar-inner { align-items: flex-start; }
    .brand { align-items: flex-start; }
    .theme-toggle { margin-top: 2px; }
}

@media (max-width: 420px) {
    .day-row { grid-template-columns: 82px 1fr auto; }
    .day-emoji { font-size: 1.3rem; }
    .hero-icon { font-size: 2.8rem; }
}

/* ============================= Instalar app ============================= */
.install-btn {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    font: 600 0.9rem var(--font-body);
    color: #fff;
    background: linear-gradient(135deg, var(--red), var(--red-bright));
    box-shadow: var(--shadow-red);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}
.install-btn:hover { filter: brightness(1.08); transform: translateY(-2px); }
.install-btn:active { transform: translateY(0); }
.install-btn svg { width: 18px; height: 18px; }
.install-btn[hidden] { display: none !important; }
