/* -----------------------------
   header.css
   Estilos del header principal
   ----------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* ==================== TOPBAR ==================== */
.topbar {
    background: var(--dark-gray);
    color: var(--white);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

.topbar .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar .links ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.topbar .links ul.sub-menu {
    gap: 0rem;
}

.topbar .links li {
    position: relative;
}

.topbar .links a {
    color: var(--white);
    text-decoration: none;
    transition: color 0.3s;
    font-weight: 400;
}

.topbar .links a:hover {
    color: var(--accent-gold);
}

/* Submenu en topbar - COLUMNA */
.topbar .has-sub {
    position: relative;
}

.topbar .sub-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--dark-gray);
    min-width: 200px;
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(0);
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

/* Área extendida para mantener hover activo */
.topbar .has-sub::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -10px;
    right: -10px;
    height: 20px;
    background: transparent;
    z-index: 99;
}

.topbar .has-sub:hover .sub-menu,
.topbar .has-sub.open .sub-menu {
    opacity: 1;
    visibility: visible;
}

.topbar .sub-menu li {
    padding: 0;
    width: 100%;
}

.topbar .sub-menu a {
    display: block;
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

.topbar .sub-menu a:hover {
    background: rgba(255,255,255,.1);
}

/* Social icons */
.topbar .socials {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.topbar .socials a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    transition: all 0.3s;
}

.topbar .socials a:hover {
    background: var(--accent-gold);
    transform: translateY(-2px);
}

.topbar .socials img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* ==================== MAINBAR ==================== */
.mainbar {
    background: var(--white);
    border-bottom: 3px solid var(--primary-red);
}

.mainbar .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 80px;
}

/* Logo section */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo a {
    display: block;
    line-height: 0;
}

.logo img {
    height: 60px;
    width: auto;
    transition: transform 0.3s;
}

.logo a:hover img {
    transform: scale(1.05);
}

/* Mobile toggle button */
.mobile-toggle {
    display: none;
    background: var(--primary-red);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.3s;
}

.mobile-toggle:hover {
    background: var(--secondary-red);
}

/* ==================== PRIMARY NAVIGATION ==================== */
.primary-nav {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    align-items: center;
}

.nav-list > li {
    position: relative;
}

.nav-list > li > a {
    display: block;
    padding: 1rem 1.2rem;
    color: var(--dark-gray);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s;
    position: relative;
}

.nav-list > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--primary-red);
    transform: translateX(-50%);
    transition: width 0.3s;
}

.nav-list > li > a:hover {
    color: var(--primary-red);
}

.nav-list > li > a:hover::after {
    width: 80%;
}

/* Dropdown indicator */
.has-sub > a::before {
    /* content: '▾'; */
    margin-left: 0.3rem;
    font-size: 0.75rem;
    display: inline-block;
    transition: transform 0.3s;
}

.has-sub:hover > a::before,
.has-sub.open > a::before {
    transform: rotate(180deg);
}

/* Submenus - COLUMNA */
.sub-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: var(--white);
    min-width: 280px;
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(0);
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    border-top: 3px solid var(--primary-red);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

/* Área extendida para mantener hover en mainbar */
.mainbar .has-sub::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -10px;
    right: -10px;
    height: 15px;
    background: transparent;
    z-index: 99;
}

.has-sub:hover > .sub-menu,
.has-sub.open > .sub-menu {
    opacity: 1;
    visibility: visible;
}

.sub-menu li {
    padding: 0;
    position: relative;
    width: 100%;
}

.sub-menu a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--dark-gray);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all 0.3s;
    text-transform: none;
    letter-spacing: normal;
}

.sub-menu a:hover {
    background: rgba(112, 25, 28, 0.05);
    color: var(--primary-red);
    padding-left: 2rem;
}

/* Nested submenus - COLUMNA */
.sub-menu .has-sub {
    position: relative;
}

.sub-menu .has-sub > a::after {
    content: '›';
    position: absolute;
    right: 1rem;
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.sub-menu .has-sub:hover > a::after,
.sub-menu .has-sub.open > a::after {
    transform: translateX(5px);
}

.sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-left: 0;
}

.sub-menu .has-sub:hover > .sub-menu,
.sub-menu .has-sub.open > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ==================== RESPONSIVE ==================== */

/* Tablets grandes */
@media (max-width: 1200px) {
    .topbar .wrap {
        padding: 0 15px;
    }
    
    .mainbar .wrap {
        padding: 0 15px;
    }
    
    .nav-list {
        gap: 0.3rem;
    }
    
    .nav-list > li > a {
        padding: 1rem 0.9rem;
        font-size: 0.8rem;
    }
}

/* Tablets */
@media (max-width: 1024px) {
    .nav-list > li > a {
        padding: 1rem 0.7rem;
        font-size: 0.75rem;
    }
    
    .sub-menu {
        min-width: 240px;
    }
}

/* Tablets pequeñas */
@media (max-width: 900px) {
    .topbar .links ul {
        gap: 1rem;
        font-size: 0.8rem;
    }
    
    .topbar .socials {
        gap: 0.7rem;
    }

    /* Ocultar iconos de redes sociales en mobile para evitar sobrecarga visual */
    .topbar .socials {
        display: none;
    }
    
    .topbar .socials a {
        width: 28px;
        height: 28px;
    }
    
    .topbar .socials img {
        width: 14px;
        height: 14px;
    }
}

/* Mobile landscape y tablets pequeñas portrait */
@media (max-width: 768px) {
    /* Topbar en mobile: mantener visible y encima del menú */
    .topbar {
        display: block; /* mantener topbar visible en mobile */
        position: relative;
        z-index: 1100; /* por encima del overlay y del panel móvil */
    }
    
    /* Si prefieres mantenerla visible: */
    .topbar .wrap {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0.8rem;
    }
    
    .topbar .links ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
    }

    .mobile-toggle {
        display: block;
    }
    
    .header-left--compact {
        width: 100%;
        justify-content: space-between;
    }

    .mainbar .wrap {
        flex-wrap: wrap;
    }

    /* Menu mobile */
    .primary-nav {
        position: fixed;
        top: var(--header-height, 0px); /* start below header/topbar */
        left: -100%;
        width: 85%;
        max-width: 340px;
        height: 100vh;
        background: var(--white);
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0,0,0,.3);
        z-index: 1001;
    }

    .primary-nav.active {
        left: 0;
    }

    .nav-list {
        flex-direction: column;
        gap: 0;
        width: 100%;
        padding: 1rem 0;
        align-items: stretch;
    }

    .nav-list > li {
        width: 100%;
        border-bottom: 1px solid rgba(0,0,0,.05);
    }

    .nav-list > li > a {
        padding: 1rem 1.5rem;
        text-align: left;
        font-size: 0.9rem;
    }

    .nav-list > li > a::after {
        display: none;
    }

    /* Submenus en mobile - modo acordeón */
    .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-top: none;
        background: rgba(112, 25, 28, 0.03);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 0;
    }

    .has-sub.open > .sub-menu {
        max-height: 2000px;
        padding: 0.5rem 0;
    }

    .sub-menu .sub-menu {
        position: static;
        margin-left: 0;
        background: rgba(112, 25, 28, 0.05);
    }

    .sub-menu a {
        padding: 0.75rem 2rem;
        font-size: 0.85rem;
    }

    .sub-menu a:hover {
        padding-left: 2.5rem;
    }
    
    .sub-menu .sub-menu a {
        padding-left: 3rem;
    }
    
    .sub-menu .sub-menu a:hover {
        padding-left: 3.5rem;
    }

    /* Overlay cuando el menu está abierto */
    body::before {
        content: '';
        position: fixed;
        top: var(--header-height, 0px); /* overlay starts below header */
        left: 0;
        width: 100%;
        height: calc(100% - var(--header-height, 0px));
        background: rgba(0,0,0,.6);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s, visibility 0.4s;
        z-index: 999;
    }

    body.menu-open::before {
        opacity: 1;
        visibility: visible;
    }

    body.menu-open {
        overflow: hidden;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .logo img {
        height: 50px;
    }

    .mainbar .wrap {
        min-height: 70px;
        padding: 0 10px;
    }

    .topbar {
        font-size: 0.75rem;
        padding: 0.4rem 0;
    }

    .topbar .socials a {
        width: 26px;
        height: 26px;
    }
    
    .topbar .socials img {
        width: 12px;
        height: 12px;
    }
    
    .mobile-toggle {
        padding: 0.4rem 0.8rem;
        font-size: 1.3rem;
    }
    
    .primary-nav {
        width: 90%;
        max-width: 300px;
    }
    
    .nav-list > li > a {
        padding: 0.9rem 1.2rem;
        font-size: 0.85rem;
    }
    
    .sub-menu a {
        padding: 0.65rem 1.8rem;
        font-size: 0.8rem;
    }
}

/* Mobile muy pequeño */
@media (max-width: 360px) {
    .logo img {
        height: 45px;
    }
    
    .mainbar .wrap {
        min-height: 65px;
    }
    
    .nav-list > li > a {
        font-size: 0.8rem;
    }
}