/* ==========================================================================
   Header - Mundo Sostenible (1600px Max-Width, 100% Touch Responsive)
   ========================================================================== */

.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: var(--transition);
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 7px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-logo {
    height: 58px;
    width: auto;
    object-fit: contain;
}

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

.nav-link {
    font-weight: 600;
    color: var(--text-muted, #64748b);
    padding: 10px 16px;
    min-height: 48px; /* Táctil */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm, 10px);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
    box-shadow: none;
    transform: none;
}

.nav-link:hover {
    color: var(--text-main, #0f172a);
    background-color: #f1f5f9;
}

.nav-link.active {
    color: #ffffff !important;
    background-color: #0f172a !important;
    font-weight: 600;
}

.nav-link.active i {
    color: var(--primary, #c3d600);
}

/* Badge de contador de leads y reservas pendientes */
.nav-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ef4444;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    margin-left: 6px;
    box-shadow: none;
    animation: pulseBadge 2.5s infinite;
}

/* Aviso numérico en morado si hay reservas en estado Reservado */
.nav-unread-badge.morado,
.nav-unread-badge.purple {
    background-color: #8b5cf6;
    color: #ffffff;
}

@keyframes pulseBadge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Diferenciador visual Header Backend */
.site-header-admin {
    background-color: #ffffff;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.site-header-admin .header-container {
    max-width: 1890px;
}

.header-brand-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-top-badge {
    background: #0f172a;
    color: #38bdf8;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Separador visual de navegación */
.nav-item-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 4px;
}

/* ==========================================================================
   MENÚ BACKEND AGRUPADO Y DESPLEGABLES TÁCTILES (100% Responsive, Zero Glow)
   ========================================================================== */
.site-header-admin .nav-menu {
    gap: 4px;
    align-items: stretch;
}

.nav-dropdown-item {
    position: relative;
    list-style: none;
    display: flex;
    align-items: center;
}

.site-header-admin .nav-link {
    font-size: 0.88rem;
    padding: 8px 12px;
    min-height: 48px;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
}

.nav-dropdown-btn {
    user-select: none;
}

.nav-dropdown-btn * {
    pointer-events: none;
}

.nav-dropdown-chevron {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.nav-dropdown-item.open .nav-dropdown-chevron,
.nav-dropdown-item:hover .nav-dropdown-chevron {
    transform: rotate(180deg);
}

/* Menú flotante desplegable táctil */
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 270px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    z-index: 200;
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

/* Puente invisible generoso para que el cursor navegue sin perder el foco */
.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    height: 14px;
    background: transparent;
}

.nav-dropdown-menu-right {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: 260px;
}

/* Mostrar menú al hacer hover en desktop o con clase .open táctil */
@media (min-width: 993px) {
    .nav-dropdown-item:hover .nav-dropdown-menu,
    .nav-dropdown-item:focus-within .nav-dropdown-menu,
    .nav-dropdown-item.open .nav-dropdown-menu {
        display: flex;
    }
}

/* Enlaces dentro del menú flotante (Mínimo 48px táctil) */
.nav-dropdown-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: 48px;
    border-radius: 8px;
    text-decoration: none;
    color: #1e293b;
    background: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-dropdown-link:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

.nav-dropdown-link.active {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
}

.nav-dropdown-link.active .nav-dropdown-icon {
    background: #0f172a;
    color: #c3d600;
}

.nav-dropdown-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-dropdown-link:hover .nav-dropdown-icon {
    background: #e2e8f0;
    color: #0f172a;
}

.nav-dropdown-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.nav-dropdown-text strong {
    font-size: 0.88rem;
    color: #0f172a;
    font-weight: 600;
    line-height: 1.2;
}

.nav-dropdown-text small {
    font-size: 0.74rem;
    color: #64748b;
    line-height: 1.2;
}

.nav-dropdown-badge {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
    box-sizing: border-box;
}

.nav-dropdown-badge.danger {
    background: #ef4444;
}

.nav-dropdown-badge.success {
    background: #10b981;
}

.nav-dropdown-badge.morado,
.nav-dropdown-badge.purple {
    background: #8b5cf6;
}

.nav-dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 6px;
}

/* Usuario / Sesión en Header */
.nav-link-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nav-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.nav-user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user-header-info {
    padding: 8px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-user-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.nav-user-strong {
    font-size: 0.9rem;
    color: #0f172a;
    font-weight: 700;
}

.nav-dropdown-link-danger {
    color: #ef4444;
}

.nav-dropdown-link-danger .nav-dropdown-icon {
    background: #fef2f2;
    color: #ef4444;
}

.nav-dropdown-link-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.nav-dropdown-link-danger:hover .nav-dropdown-icon {
    background: #fee2e2;
    color: #dc2626;
}

/* Botón Badge de Acceso a Admin / Mi panel desde el Frontend */
.nav-link-admin-badge {
    background-color: #c3d600 !important;
    color: #1a1a1a !important;
    font-weight: 600;
    border: 1px solid #b0c200;
    border-radius: 999px;
    padding: 8px 18px;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.nav-link-admin-badge:hover {
    background-color: #b0c200 !important;
    color: #1a1a1a !important;
    border-color: #9fad00;
    transform: translateY(-1px);
}

/* Botón Destacado / CTA de Acceso a Clientes desde el Frontend (Verde Acento) */
.nav-link-cliente {
    background-color: var(--primary, #c3d600) !important;
    color: #1a1a1a !important;
    font-weight: 700 !important;
    border: 1.5px solid #b0c200 !important;
    border-radius: 999px !important;
    padding: 10px 22px !important;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-link-cliente i {
    font-size: 1.15rem;
    color: #1a1a1a;
    transition: color 0.2s ease;
}

.nav-link-cliente:hover {
    background-color: #0f172a !important;
    color: var(--primary, #c3d600) !important;
    border-color: #0f172a !important;
    transform: translateY(-1px);
}

.nav-link-cliente:hover i {
    color: var(--primary, #c3d600);
}

.nav-link-cliente:active {
    transform: translateY(0);
}

/* Enlace a Ver Web Pública desde el Admin */
.nav-link-external {
    color: var(--text-main);
    background-color: #f1f5f9;
    border-radius: 8px;
}

.nav-link-external:hover {
    background-color: #e2e8f0;
    color: var(--text-main);
}

/* Enlace Cerrar Sesión */
.nav-link-logout {
    color: var(--danger) !important;
}

.nav-link-logout:hover {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
    min-height: 48px;
    min-width: 48px;
    color: var(--text-main);
}

/* Media Queries para Header Móvil / Tablet */
@media (max-width: 992px) {
    .site-header {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .site-header .header-container,
    .site-header-admin .header-container,
    .header-container {
        padding-top: 7px;
        padding-bottom: 7px;
        padding-left: 16px;
        padding-right: 60px !important; /* Espacio para que el logo no choque con el botón */
        position: relative;
    }

    .brand-logo {
        height: 52px;
    }

    .admin-top-badge {
        display: none !important; /* En móvil optimizamos espacio en la barra */
    }

    .mobile-menu-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        position: absolute !important;
        right: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        padding: 0 !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        margin: 0 !important;
        z-index: 105;
    }

    .mobile-menu-btn svg {
        width: 36px !important;
        height: 36px !important;
        stroke-width: 2.6 !important;
        display: block !important;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background: #ffffff;
        border-bottom: 1px solid var(--border-color);
        padding: 16px 20px;
        box-shadow: var(--shadow-md);
        gap: 8px;
    }

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

    .nav-link {
        width: 100%;
        padding: 12px 16px;
        justify-content: flex-start;
    }

    .site-header-admin .nav-link-external {
        justify-content: center;
        text-align: center;
    }

    .nav-item-divider {
        width: 100%;
        height: 1px;
        margin: 6px 0;
    }

    /* Submenús en versión móvil / tablet */
    .nav-dropdown-item {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-dropdown-btn {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .nav-dropdown-menu {
        position: static;
        width: 100%;
        min-width: 100%;
        box-shadow: none;
        border: 1px solid #f1f5f9;
        background: #f8fafc;
        border-radius: 8px;
        margin-top: 4px;
        padding: 6px;
        display: none;
        transform: none !important;
        left: 0 !important;
    }

    .nav-dropdown-item.open .nav-dropdown-menu {
        display: flex;
    }

    .nav-dropdown-link {
        padding: 8px 12px;
        background: #ffffff;
    }

    .nav-link-user {
        width: 100%;
        justify-content: space-between;
    }

    .nav-link-cliente {
        width: 100%;
        justify-content: center !important;
        margin-top: 6px;
    }
}


