/* ===== VARIABLES Y RESET ===== */
:root {
    --color-bg: #FFFFFF;
    --color-text: #1a1a1a;
    --color-text-muted: #6b7280;
    --color-primary: #1E3A8A; /* Azul oscuro */
    --color-accent: #C9A227; /* Dorado */
    --color-surface: #F5F7FA;
    --color-border: #E5E7EB;
    --radius: 16px;
    --radius-sm: 10px;
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --shadow: 0 4px 12px rgba(0,0,0,0.06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Colores por categoria (pipeline: taurino, religioso, musica,
       gastronomia, infantil, deporte, cultura, protocolo,
       institucional, otros) */
    --cat-taurino: #e74c3c;
    --cat-religioso: #9b59b6;
    --cat-musica: #C9A227;
    --cat-gastronomia: #e67e22;
    --cat-infantil: #2ecc71;
    --cat-deporte: #1abc9c;
    --cat-cultura: #34495e;
    --cat-protocolo: #e84393;
    --cat-institucional: #6c5ce7;
    --cat-otros: #adb5bd;
}

/* FIX: Theme.js activa el modo oscuro con document.body.classList
   ("body.dark"), no con un atributo data-theme. Este selector es
   el que realmente dispara el JS. */
body.dark {
    --color-bg: #0F172A;
    --color-text: #F1F5F9;
    --color-text-muted: #94A3B8;
    --color-surface: #1E293B;
    --color-border: #334155;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    padding-bottom: var(--space-4);
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
}
.skip-link:focus {
    left: 10px;
    top: 10px;
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    z-index: 999;
}

/* ===== HEADER ===== */
.main-header {
    background: var(--color-primary);
    color: white;
    padding: var(--space-2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    max-width: 1000px;
    margin: 0 auto;
    flex-wrap: wrap;
}
.brand { display: flex; gap: var(--space-2); align-items: center; }
.brand-text h1 { font-size: clamp(18px, 4.5vw, 24px); font-weight: 700; }
.brand-text h2 { font-size: clamp(11px, 3vw, 13px); font-weight: 400; opacity: 0.9; }
.brand-text p { font-size: 11px; opacity: 0.8; margin-top: 2px; }

.header-actions { display: flex; gap: var(--space-1); align-items: center; }
.toolbar-group { display: flex; gap: 6px; }
.lang-btn, .icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    padding: 8px 12px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.lang-btn.active { background: white; color: var(--color-primary); }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 15px; }

/* ===== CONTENEDOR GENERAL ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ===== LIVE CARD (acto actual / próximo en una sola tarjeta) ===== */
.live-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow);
}
.live-item { padding: var(--space-2) 0; }
.live-item:empty { display: none; }
.live-item h3 { font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; font-weight: 600; }
.live-item strong { font-size: 22px; color: var(--color-primary); display: block; }
body.dark .live-item strong { color: var(--color-accent); }
.live-item p { font-size: 14px; margin-top: 4px; }

.live-now::before { content: "AHORA"; font-size: 11px; color: var(--color-accent); font-weight: 700; display: block; margin-bottom: 4px; letter-spacing: 0.5px; }
.live-next::before { content: "DESPUÉS"; font-size: 11px; opacity: 0.6; font-weight: 700; display: block; margin-bottom: 4px; letter-spacing: 0.5px; }
.live-divider { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }
.live-timer { font-size: 12px; color: var(--color-text-muted); text-align: right; margin-top: 2px; }

/* ===== STATS BAR (linea horizontal) ===== */
.stats-bar {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    flex-wrap: wrap;
    color: var(--color-text-muted);
}
.stats-bar span { font-weight: 700; color: var(--color-primary); }
body.dark .stats-bar span { color: var(--color-accent); }

/* ===== ACCIONES RÁPIDAS ===== */
.quick-actions {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}
.btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 18px;
    min-height: 44px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    flex: 1;
    min-width: 120px;
    transition: transform 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn.active { background: var(--color-accent); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); }
.btn-ghost { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }

/* El selector de dia va dentro de quick-actions pero ocupa fila
   propia para no apretujarse contra los botones. */
.day-select-wrap { flex: 1 1 100%; }
.day-select-wrap select {
    width: 100%;
    padding: 12px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 14px;
}

/* ===== BUSCADOR Y FILTROS ===== */
.search-section { display: flex; flex-direction: column; gap: var(--space-2); }
#searchInput {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 16px;
    color: var(--color-text);
}
.filters-panel {
    background: var(--color-surface);
    padding: var(--space-3);
    border-radius: var(--radius);
    animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.filter-grid { display: grid; gap: var(--space-2); }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
}
.filter-group select {
    padding: 12px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
}
.filters-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.filters-actions .btn,
.filters-actions .btn-ghost { flex: 1; min-width: 0; }

@media (min-width: 640px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
    .filter-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== TARJETAS DE EVENTO ===== */
#programContainer { display: flex; flex-direction: column; gap: var(--space-2); }

.event-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: var(--space-2);
    box-shadow: var(--shadow);
    border-left: 5px solid var(--cat-otros);
    display: grid;
    grid-template-columns: 66px 1fr auto;
    gap: var(--space-2);
    align-items: start;
    transition: transform 0.15s ease;
}
.event-card:hover { transform: translateY(-2px); }

.event-card.categoria-taurino { border-left-color: var(--cat-taurino); }
.event-card.categoria-religioso { border-left-color: var(--cat-religioso); }
.event-card.categoria-musica { border-left-color: var(--cat-musica); }
.event-card.categoria-gastronomia { border-left-color: var(--cat-gastronomia); }
.event-card.categoria-infantil { border-left-color: var(--cat-infantil); }
.event-card.categoria-deporte { border-left-color: var(--cat-deporte); }
.event-card.categoria-cultura { border-left-color: var(--cat-cultura); }
.event-card.categoria-protocolo { border-left-color: var(--cat-protocolo); }
.event-card.categoria-institucional { border-left-color: var(--cat-institucional); }
.event-card.destacado { outline: 2px solid var(--color-accent); }

.event-time {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 6px 4px;
    text-align: center;
    height: fit-content;
}
.event-time .event-date {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.4px;
}
.event-time .event-hour { font-size: 13px; font-weight: 700; color: var(--color-primary); }
body.dark .event-time .event-hour { color: var(--color-accent); }
.event-time .hora-aprox { display: block; font-size: 9px; font-weight: 400; color: var(--color-text-muted); }

.event-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.event-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.event-icon { font-size: 18px; }

.badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin: 0 4px 6px 0;
    font-weight: 600;
}
.badge.destacado { background: var(--color-accent); color: white; }
.badge.favorito { background: #ffe0e6; color: #c0392b; }
.badge.hoy { background: #dff5e1; color: #1e824c; }

.event-place { margin: 0 0 6px 0; font-size: 13px; color: var(--color-text-muted); }
.event-description { margin: 0 0 10px 0; font-size: 13.5px; line-height: 1.4; }

.event-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
    font-size: 11px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

.event-actions { display: flex; flex-direction: column; gap: 6px; }
.event-actions button {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    font-size: 15px;
}
.event-actions button:hover { background: var(--color-border); }

@media (max-width: 560px) {
    .event-card { grid-template-columns: 1fr; }
    .event-actions { flex-direction: row; }
    .event-time { align-self: flex-start; }
}

/* ===== ESTADO VACÍO ===== */
.empty {
    text-align: center;
    padding: var(--space-4) var(--space-2);
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius);
}
.empty h2 { font-size: 32px; }
.empty h3 { margin: 8px 0 4px; }

/* ===== MODAL ===== */
#eventModal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: flex-end; justify-content: center; z-index: 200;
}
#eventModal.show { display: flex; }
.modal-content {
    background: var(--color-bg);
    width: 100%; max-width: 600px;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: var(--space-3);
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
#modalBody h2 { margin-top: 0; margin-bottom: var(--space-1); }
#modalBody p { font-size: 14px; margin: 6px 0; }
#modalBody hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-2) 0; }
.modal-actions { display: flex; gap: var(--space-1); margin-top: var(--space-2); }
.modal-actions button {
    flex: 1;
    padding: 12px;
    min-height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
#closeModal {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    border: none;
    background: var(--color-surface);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 16px;
}

/* ===== BOTÓN VOLVER ARRIBA ===== */
#scrollTop {
    position: fixed;
    bottom: var(--space-2);
    right: var(--space-2);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: white;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 150;
}
#scrollTop.show { opacity: 1; pointer-events: auto; }

/* ===== TOASTS ===== */
#toastContainer {
    position: fixed;
    bottom: var(--space-2);
    left: 50%;
    transform: translateX(-50%);
    z-index: 250;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.toast {
    background: var(--color-primary);
    color: white;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 1;
    transition: opacity 0.3s ease;
}
.toast.toast-out { opacity: 0; }

/* ===== FOOTER ===== */
.main-footer {
    text-align: center;
    padding: var(--space-4) var(--space-2);
    font-size: 14px;
    background: var(--color-primary);
    color: white;
    margin-top: var(--space-4);
}
.main-footer hr { width: 50%; margin: var(--space-2) auto; border: none; border-top: 1px solid rgba(255,255,255,0.3); }
.main-footer a { color: white; text-decoration: underline; text-decoration-color: var(--color-accent); }
.main-footer a:hover { color: var(--color-accent); }
.main-footer .disclaimer { font-size: 12px; opacity: 0.8; margin-top: var(--space-1); }
.main-footer .copy { font-size: 12px; margin-top: var(--space-1); opacity: 0.9; }
.main-footer .json-meta { font-size: 11px; opacity: 0.7; margin-top: var(--space-1); }
