/* ============================================
   HEADER CORPORATIVO - REDEVENTOS
   ============================================ */

:root {
    --header-bg: #141414;
    --header-border: #2A2A28;
    --header-text: #EDEBE6;
    --header-text-muted: #A9A69F;
    --header-gold: #F2B705;
    --header-gold-hover: #DCA500;
}

.site-header {
    background: rgba(20, 20, 20, 0.94);
    border-bottom: 1px solid var(--header-border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    /* Se oculta al bajar y reaparece al subir para no tapar el contenido
       (la clase .hide la controla header.js segun la direccion de scroll). */
    transition: transform 0.3s ease;
    will-change: transform;
}

.site-header.hide {
    transform: translateY(-100%);
}

/* Sombra sutil solo cuando ya se hizo scroll, para despegar del contenido
   sin recargar visualmente cuando esta arriba del todo. */
.site-header.scrolled {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo img {
    height: 36px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.header-logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--header-text);
    letter-spacing: -0.5px;
}

.header-logo-text span {
    color: var(--header-gold);
}

/* Logo: letra sólida y las tres barras doradas de la "E" como firma */
.logo-wordmark {
    display: inline-flex;
    align-items: center;
    font-family: var(--brand-font, 'Archivo', sans-serif);
    font-size: 19px;
    font-weight: 700;
    font-stretch: 125%;
    letter-spacing: 0.02em;
    line-height: 1;
    color: var(--header-text);
}
.logo-barras {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    width: 0.62em;
    height: 0.72em;
    margin: 0 0.1em;
}
.logo-barras i {
    display: block;
    height: 0.15em;
    background: var(--header-gold);
}
.logo-barras i:nth-child(2) { width: 70%; }

/* Navegación Principal */
.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 0 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.header-nav a {
    color: var(--header-text-muted);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
}

.header-nav a:hover {
    color: var(--header-text);
    background: rgba(255,255,255,0.05);
}

.header-nav a.active {
    color: var(--header-gold);
    background: rgba(242, 183, 5, 0.1);
}

.header-nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--header-gold);
    border-radius: 2px;
}

/* Navegación Derecha */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Notificaciones */
.header-notifications {
    position: relative;
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--header-text-muted);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
}

.header-notifications:hover {
    background: rgba(255,255,255,0.1);
    color: var(--header-text);
}

.header-notifications .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.header-notifications-wrap {
    position: relative;
}

.header-notifications-wrap.active .header-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-notifications-dropdown {
    min-width: 320px;
    max-width: 360px;
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
}

.header-notifications-dropdown .header-notification-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--header-text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
}

.header-notifications-dropdown .header-notification-item:hover {
    background: rgba(255,255,255,0.06);
}

.header-notification-item + .header-notification-item {
    margin-top: 2px;
}

.header-notification-titulo {
    font-size: 13px;
    font-weight: 600;
    color: var(--header-text);
    margin-bottom: 2px;
}

.header-notification-mensaje {
    font-size: 12px;
    line-height: 1.4;
}

.header-notifications-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 12px;
    color: var(--header-text-muted);
    font-size: 13px;
    text-align: center;
}

.header-notifications-empty i {
    font-size: 22px;
}

/* Perfil Usuario */
.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 12px 4px 4px;
    border-radius: 50px;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    position: relative;
}

.header-profile:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
}

.header-profile .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--header-gold);
    flex-shrink: 0;
}

.header-profile .info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.header-profile .info .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--header-text);
}

.header-profile .info .role {
    font-size: 11px;
    color: var(--header-text-muted);
    font-weight: 400;
}

.header-profile .chevron {
    color: var(--header-text-muted);
    font-size: 12px;
    transition: transform 0.2s ease;
}

.header-profile.active .chevron {
    transform: rotate(180deg);
}

/* ============================================
   DROPDOWN MENU
   ============================================ */
.header-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1001;
}

.header-profile.active .header-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--header-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.header-dropdown a:hover {
    background: rgba(255,255,255,0.06);
    color: var(--header-text);
}

.header-dropdown a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.header-dropdown .divider {
    height: 1px;
    background: var(--header-border);
    margin: 6px 0;
}

/* ============================================
   BOTÓN DE CERRAR SESIÓN
   ============================================ */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: #e74c3c;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    text-align: left;
}

.logout-btn i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: #e74c3c;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

.logout-btn:hover i {
    color: #c0392b;
}

.logout-btn:active {
    transform: scale(0.98);
}

/* Botones de autenticación */
.header-auth-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-header-primary {
    padding: 8px 20px;
    background: var(--header-gold);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-header-primary:hover {
    background: var(--header-gold-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(242, 183, 5, 0.3);
}

.btn-header-secondary {
    padding: 8px 16px;
    background: transparent;
    color: var(--header-text-muted);
    border: 1px solid var(--header-border);
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-header-secondary:hover {
    background: rgba(255,255,255,0.05);
    color: var(--header-text);
}

/* Mobile Menu Toggle */
.header-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.05);
    border: none;
    border-radius: 10px;
    color: var(--header-text);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-mobile-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* Tablet y menor (≤1024px): el nav se colapsa en el menú hamburguesa.
   Con muchos ítems (productor/proveedor/admin) el nav horizontal se
   apretaba y cortaba links / tapaba la campana; el desplegable lo evita. */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 16px;
    }

    .header-logo img {
        height: 34px;
        max-width: 180px;
    }

    .header-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 4px;
        padding: 12px 16px 16px;
        background: var(--header-bg);
        border-bottom: 1px solid var(--header-border);
        box-shadow: 0 24px 60px rgba(0,0,0,0.5);
        overflow-x: hidden;
        overflow-y: auto;
        max-height: calc(100vh - 64px);
    }

    .header-nav.open {
        display: flex;
    }

    .header-nav a {
        width: 100%;
        padding: 13px 16px;
        font-size: 15px;
    }

    .header-nav a.active::after {
        display: none;
    }

    .header-nav a.active {
        background: rgba(242, 183, 5, 0.15);
    }

    .header-mobile-toggle {
        display: flex;
    }

    .header-profile .info {
        display: none;
    }

    .header-profile {
        padding: 4px;
    }
}

@media (max-width: 768px) {
    .header-container {
        height: 64px;
    }

    .header-profile .avatar {
        width: 32px;
        height: 32px;
    }

    .header-notifications {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header-container {
        height: 56px;
        padding: 0 12px;
    }

    .header-logo img {
        height: 30px;
        max-width: 150px;
    }

    .header-right {
        gap: 8px;
    }

    .header-auth-buttons .btn-header-secondary {
        display: none;
    }

    .btn-header-primary {
        padding: 6px 14px;
        font-size: 13px;
    }
}
/* Badge del carrito en el menu (icono + texto "Carrito", no un boton
   redondo como el de notificaciones, asi que se posiciona pegado a la
   esquina superior derecha del icono en vez de del link completo). */
nav a[href="/carrito"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
nav a[href="/carrito"] .badge {
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
