/* ============================================
   HEADER.CSS - Header unificado PC + móvil (Definitivo corregido)
   Diario Costa Tropical
   ============================================ */

.header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 99999;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    overflow: visible;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    /* Transición fluida global para que todo el header suba/baje sin tirones */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   FILA 1: TEMAS DEL DÍA (discreto)
   ============================================ */
.header-temas-row {
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    padding: 4px 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.header-temas-row .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-temas-row .temas-del-dia { background: transparent; border-bottom: 0; }
.header-temas-row .temas-del-dia-inner { padding: 0; max-width: none; }

/* ============================================
   FILA 2: UTILIDADES (PC)
   ============================================ */
.header-utility-row {
    background: #fff;
    border-bottom: 1px solid #eaeaea;
    padding: 8px 0;
    font-size: 12px;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.header-utility-row .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-utility-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.header-utility-center {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f4f4f7;
    padding: 3px;
    border-radius: 22px;
    flex-shrink: 0;
}

.header-modo-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 12.5px;
    font-weight: 700;
    color: #666 !important;
    text-decoration: none !important;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    line-height: 1;
    border: none;
    cursor: pointer;
    background: transparent;
    font-family: inherit;
}

.header-modo-link i { font-size: 12px; display: inline-block; line-height: 1; }
.header-modo-link span { display: inline-block; line-height: 1; }

.header-modo-link:hover { color: #111 !important; }
.header-modo-link.activo { background: #111; color: #fff !important; }

/* 90 Radio con color corporativo */
.header-modo-radio {
    color: #007887 !important;
}
.header-modo-radio:hover {
    color: #fff !important;
    background: #007887 !important;
}

.header-utility-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    justify-content: flex-end;
}

.header-utility-right .header-tiempo {
    color: #007887 !important;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    font-size: 12px;
    line-height: 1;
}

.header-utility-right .header-tiempo i { color: #007887; font-size: 13px; }

.header-utility-right .header-admin-link {
    color: #718096 !important;
    font-size: 10px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    font-weight: 600;
    line-height: 1;
}

.header-utility-right .header-admin-link:hover { color: #007887 !important; }

/* ============================================
   FILA MÓVIL: LOGO + LEER/CERCA + HAMBURGUESA
   ============================================ */
.header-mobile-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 2px solid #007887;
    gap: 10px;
}

.header-mobile-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-mobile-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.header-mobile-logo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    text-decoration: none;
}

.logo-img-mobile {
    max-height: 38px;
    width: auto;
    display: block;
}

.header-mobile-modos {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.header-mobile-modos .header-modo-link {
    padding: 6px 12px;
    font-size: 11.5px;
    border-radius: 16px;
    gap: 4px;
    background: #f4f4f7;
    line-height: 1;
}

.header-mobile-modos .header-modo-link.activo {
    background: #111;
    color: #fff !important;
}

.header-mobile-modos .header-modo-link i { font-size: 10px; }

/* ============================================
   FILA 3 PC: LOGO CENTRADO
   ============================================ */
.header-logo-row {
    background: #ffffff;
    padding: 10px 0 8px;
    text-align: center;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    overflow: hidden;
}

.header-logo-row .header-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.header-logo-row .header-logo-link { display: inline-block; line-height: 0; }
.header-logo-row .logo-img-desktop { max-height: 56px; width: auto; display: inline-block; }

/* ============================================
   FILA 4 PC: MENÚ + BUSCADOR
   ============================================ */
.header-main {
    background: #ffffff;
    padding: 0;
    border-bottom: 2px solid #007887;
    border-top: 1px solid #eaeaea;
    width: 100%;
    min-height: 48px;
}

.header-main .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    justify-content: space-between;
}

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

.menu-toggle {
    background: none;
    border: none;
    color: #0d1b2a;
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.menu-toggle:hover {
    color: #007887;
    background: rgba(0, 120, 135, 0.05);
}

.logo-compact {
    display: none;
    align-items: center;
    flex-shrink: 0;
}

.logo-compact img {
    max-height: 30px;
    width: auto;
    display: block;
}

.main-nav { display: flex; align-items: center; min-width: 0; }

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 2px;
    align-items: center;
    margin: 0;
    padding: 0;
}

.main-nav ul li a {
    color: #333;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 14px 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: inline-block;
    white-space: nowrap;
    transition: color 0.25s ease;
}

.main-nav ul li a:hover { color: #007887; }

.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
}

.search-form {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 25px;
    padding: 3px 4px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.search-form:focus-within { border-color: #007887; background: #ffffff; }

.search-form input {
    background: none;
    border: none;
    padding: 5px 10px;
    font-size: 0.78rem;
    outline: none;
    width: 110px;
}

.search-form button {
    background: none;
    border: none;
    color: #666;
    padding: 5px 8px;
    cursor: pointer;
}

.search-form button:hover { color: #007887; }

/* ============================================
   OFFCANVAS
   ============================================ */
body.offcanvas-open { overflow: hidden; }

#offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

#offcanvas-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#offcanvas-menu {
    position: fixed;
    top: 0;
    left: -500px;
    width: 320px;
    max-width: 88vw;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    z-index: 9999999;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 18px 24px;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

#offcanvas-menu.active { left: 0; }

.offcanvas-spacer {
    height: 85px;
    display: block;
}

.offcanvas-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: none;
    background: #f0f4f8;
    color: #0d1b2a;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.offcanvas-close:hover { background: #e2e8f0; transform: rotate(90deg); }

.offcanvas-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: #f0f4f8;
    border-radius: 8px;
    border: 1px solid #e8ecf0;
    min-height: 42px;
    box-sizing: border-box;
    gap: 10px;
}

.offcanvas-fecha {
    color: #4a5568;
    font-size: 12.5px;
    font-weight: 600;
    text-transform: capitalize;
}

.offcanvas-tiempo {
    color: #007887 !important;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.offcanvas-tiempo i { color: #007887; font-size: 14px; }
.offcanvas-tiempo .temp { color: #007887 !important; }

.offcanvas-search { margin-bottom: 18px; }

.offcanvas-search .search-form {
    width: 100%;
    background: #f0f4f8;
    border: 1px solid #e2e8f0;
    border-radius: 25px;
    padding: 4px 8px;
    box-sizing: border-box;
}

.offcanvas-search .search-form:focus-within { border-color: #007887; background: #ffffff; }

.offcanvas-search .search-form input {
    color: #1a202c;
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    background: transparent;
    border: none;
    outline: none;
    box-sizing: border-box;
}

.offcanvas-search .search-form input::placeholder { color: #a0aec0; }

.offcanvas-search .search-form button {
    color: #718096;
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
}

.offcanvas-search .search-form button:hover { color: #007887; }

.offcanvas-section { margin-bottom: 16px; }

.offcanvas-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    font-weight: 800;
    color: #007887;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
}

.offcanvas-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 8px;
}

.offcanvas-section-grid a {
    display: block;
    padding: 7px 8px;
    color: #2d3748;
    text-decoration: none !important;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 5px;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1.3;
}

.offcanvas-section-grid a:hover { background: #f0f7f9; color: #007887; }
.offcanvas-section-grid a.nav-canal { color: #007887 !important; font-weight: 700; }

#offcanvas-menu ul { list-style: none !important; padding-left: 0 !important; margin: 0 !important; }
#offcanvas-menu li { list-style: none !important; }
#offcanvas-menu a { text-decoration: none !important; }

.offcanvas-legal-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 10px;
    padding: 4px 0;
    font-size: 0.72rem;
    margin-top: 4px;
}

.offcanvas-legal-line a {
    color: #718096;
    text-decoration: none !important;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.offcanvas-legal-line a:hover { color: #007887; }
.offcanvas-legal-line .sep { color: #cbd5e0; }

.offcanvas-nosotros-line {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

/* ============================================
   TEMAS DEL DÍA (discreto)
   ============================================ */
.temas-del-dia { background: transparent; width: 100%; }

.temas-del-dia-inner { display: flex; align-items: center; gap: 12px; }

.temas-etiqueta {
    font-size: 0.62rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.temas-etiqueta i { font-size: 0.7rem; color: #bbb; }

.temas-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    padding-bottom: 2px;
    flex: 1;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.temas-scroll::-webkit-scrollbar { display: none; }

.tema-chip {
    display: inline-block;
    padding: 2px 10px;
    background: transparent;
    color: #666;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.tema-chip:hover { background: #fff; color: #007887; border-color: #e6e9ec; }

/* ============================================
   PC (≥992px)
   ============================================ */
@media (min-width: 992px) {
    .desktop-only { display: block !important; }
    .mobile-only { display: none !important; }

    .main-nav { display: flex !important; }
    .header-mobile-row { display: none !important; }

    #offcanvas-menu {
        width: 460px;
        max-width: 92vw;
        padding: 0 26px 30px;
    }
    .offcanvas-section-grid { grid-template-columns: 1fr 1fr; gap: 2px 14px; }
    .offcanvas-spacer { height: 100px; }

    .header.compact .header-temas-row,
    .header.compact .header-utility-row,
    .header.compact .header-logo-row {
        opacity: 0;
        visibility: hidden;
        height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin: 0;
        overflow: hidden;
        border: 0;
        pointer-events: none;
        transition: opacity 0.2s ease, height 0.2s ease, padding 0.2s ease;
    }

    .header.compact .header-main {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .header:not(.compact) .header-temas-row,
    .header:not(.compact) .header-utility-row,
    .header:not(.compact) .header-logo-row {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.2s ease, height 0.2s ease, padding 0.2s ease;
    }

    .header:not(.compact) .main-nav { display: flex !important; }
    .header:not(.compact) .logo-compact { display: none !important; }
    .header.compact .main-nav { display: none !important; }
    .header.compact .logo-compact { display: inline-flex !important; }

    .header.compact .search-form input {
        width: 80px;
        padding: 4px 8px;
        font-size: 0.72rem;
    }
}

@media (max-width: 1200px) and (min-width: 992px) {
    .main-nav ul li a { padding: 14px 6px; font-size: 0.7rem; }
    .search-form input { width: 90px; }
    .header-logo-row .logo-img-desktop { max-height: 50px; }
}

/* ============================================
   MÓVIL (<992px)
   ============================================ */
@media (max-width: 991px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: flex !important; }

    .header-temas-row,
    .header-utility-row,
    .header-logo-row,
    .header-main {
        display: none !important;
    }

    .header-mobile-row {
        display: flex !important;
    }

    .menu-toggle {
        display: inline-flex !important;
        width: 38px;
        height: 38px;
        padding: 4px;
        color: #0d1b2a;
        background: none;
        border: none;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: color 0.2s ease, background 0.2s ease;
    }
    .menu-toggle:hover {
        color: #007887;
        background: rgba(0, 120, 135, 0.05);
    }

    /* Solución definitiva para móviles: desliza todo el header hacia arriba sin dejar espacio blanco */
    .header.mobile-scroll-hidden {
        transform: translateY(-100%);
    }
}

@media (max-width: 480px) {
    #offcanvas-menu {
        width: 290px;
        max-width: 92vw;
        padding: 0 14px 20px;
    }
    .offcanvas-spacer { height: 75px; }
    .offcanvas-info { padding: 9px 12px; gap: 8px; }
    .offcanvas-fecha { font-size: 11.5px; }
    .offcanvas-section-grid a { font-size: 13px; }

    .logo-img-mobile { max-height: 34px; }

    .header-mobile-modos .header-modo-link {
        padding: 5px 10px;
        font-size: 11px;
    }
    .header-mobile-modos .header-modo-link i { font-size: 9px; }
}
