@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #faf7f2;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f0e6;
    --border: #e7e2d9;
    --text-primary: #1f2937;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #e11d48;
    --danger-bg: #ffe4e6;
    --accent-active-text: #0f766e;
    --accent-active-bg: #e6f4f2;
}

/* --- Barra de Navegación Exacta de Catálogo PDF --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--bg-main) !important;
    border-bottom: 2px solid var(--border) !important;
    box-shadow: 0 4px 18px rgba(249, 115, 22, 0.08) !important;
    padding: 0 !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    padding: 0.65rem 1.75rem !important;
    gap: 1.5rem;
}

/* Logo a 60px uniforme */
.brand-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: 1.5rem;
    text-decoration: none !important;
}

.site-logo {
    height: 60px !important;
    max-height: 60px !important;
    width: auto !important;
    object-fit: contain;
    display: block !important;
}

nav {
    display: flex;
    align-items: center;
    flex: 1;
    width: 100%;
}

.main-nav {
    display: flex !important;
    align-items: center !important;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
    width: 100%;
}

/* Enlaces base: negrita 700, sin subrayado */
.main-nav a,
.main-nav a:visited {
    text-decoration: none !important;
}

.main-nav .nav-link {
    color: #1f2937 !important;
    text-decoration: none !important;
    font-size: 0.93rem !important;
    font-weight: 700 !important;
    padding: 0.5rem 0.85rem !important;
    border-radius: 9999px !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    border: none !important;
    background: transparent !important;
    line-height: 1.2 !important;
}

.main-nav .nav-link:hover {
    color: #1d4ed8 !important;
    background: #eee7db !important;
}

/* Pestaña activa (Verde Salvia) */
.main-nav .nav-link.active {
    color: #0f766e !important;
    background: #e6f4f2 !important;
    border: 1px solid #bfe3de !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    box-shadow: none !important;
}

/* Separador y grupo derecho */
.main-nav .nav-admin-group {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    margin-left: auto !important; /* Empuja todo el bloque a la derecha */
    flex-shrink: 0 !important;
}

.nav-divider {
    width: 1.5px;
    height: 24px;
    background-color: var(--border);
    margin: 0 0.4rem;
}

/* Botón 🔒 Admin (Idéntico a .btn-outline de catálogo) */
.btn-nav-admin-login,
.site-header .btn-outline {
    background: #ffffff !important;
    border: 1.5px solid #e7e2d9 !important;
    color: #6b7280 !important;
    padding: 0.45rem 0.85rem !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
}

.btn-nav-admin-login:hover,
.site-header .btn-outline:hover {
    background: #f5f0e6 !important;
    border-color: #2563eb !important;
    color: #2563eb !important;
}

/* Badge Admin (Pastilla lila de catálogo) */
.badge-nav-admin,
.admin-badge {
    background: #ede9fe !important;
    color: #7c3aed !important;
    border: 1.5px solid #ddd6fe !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.7rem !important;
    border-radius: 9999px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
}

/* Botón de acción (+ Subir libro, + Crear Anuncio, etc.) */
.btn-nav-action,
.site-header .btn-primary {
    background: linear-gradient(135deg, #fb923c 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    border: none !important;
    padding: 0.5rem 1.05rem !important;
    border-radius: 9999px !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.4) !important;
    cursor: pointer !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

/* Botón Salir (Pastilla rosa suave) */
.btn-nav-logout,
.site-header .btn-danger-outline {
    background: #ffe4e6 !important;
    border: 1.5px solid #fecdd3 !important;
    color: #e11d48 !important;
    padding: 0.45rem 0.9rem !important;
    border-radius: 9999px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

.btn-nav-logout:hover,
.site-header .btn-danger-outline:hover {
    background: #fecdd3 !important;
    color: #be123c !important;
}

/* --- Corrección definitiva para el menú desplegable "Más +" --- */
.nav-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.nav-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 260px;
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0;
    z-index: 100;
}

@media (max-width: 768px) {
    .nav-dropdown-menu {
        right: auto !important;
        left: 0 !important;
        margin-left: -10px; /* Esto lo desplaza ligeramente hacia la derecha/izquierda según necesites */
    }
}

.nav-dropdown-menu.hidden {
    display: none !important;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease;
}

.nav-dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
}

/* Blindaje tipográfico global para evitar texto blanco en fondos claros */
h1, h2, h3, h4, 
.hero h1, .hero h2, .hero-title, 
.catalog-hero h2, .section-title {
    color: #1f2937 !important;
}
.hero p, .catalog-hero p, .section-subtitle {
    color: #4b5563 !important;
}

/* =========================================================
   SOPORTE RESPONSIVO MÓVIL (<= 1024px) - MENÚ HAMBURGUESA
   ========================================================= */

/* Botón hamburguesa: oculto por defecto en escritorio */
.nav-toggle {
    display: none;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 0.5rem 0.6rem;
    margin-left: auto;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    transition: all 0.25s ease;
    z-index: 60;
}

.nav-toggle:hover {
    background: #f5f0e6;
    border-color: var(--accent);
}

.nav-toggle .bar {
    display: block;
    width: 22px;
    height: 2.5px;
    background-color: var(--text-primary);
    border-radius: 3px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Animación del icono hamburguesa a cruz 'X' */
.nav-toggle.is-active .bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}
.nav-toggle.is-active .bar:nth-child(2) {
    opacity: 0;
}
.nav-toggle.is-active .bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

@media (max-width: 1024px) {
    .site-header {
        position: relative; /* Evita clipping de menús desplegables */
    }

    .header-container {
        padding: 0.5rem 1.25rem !important;
        justify-content: space-between !important;
        position: relative;
    }

    .nav-toggle {
        display: flex !important; /* Visible en pantallas <= 1024px */
    }

    nav {
        flex: initial;
        width: auto;
    }

    /* Menú colapsable vertical */
    .main-nav {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100% !important;
        background-color: #faf7f2 !important;
        border-bottom: 2px solid var(--border) !important;
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08) !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 1rem 1.25rem 1.5rem !important;
        gap: 0.4rem !important;
        z-index: 55;
    }

    /* Estado abierto */
    .main-nav.nav-open {
        display: flex !important;
        animation: slideDown 0.25s ease forwards;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .main-nav li {
        width: 100%;
    }

    .main-nav .nav-link {
        display: block !important;
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        border-radius: 8px !important;
        text-align: left;
    }

    /* Adaptación del grupo Admin / Acciones en móvil */
    .main-nav .nav-admin-group {
        margin-left: 0 !important;
        margin-top: 0.75rem !important;
        padding-top: 0.75rem !important;
        border-top: 1px solid var(--border) !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .nav-divider {
        display: none !important;
    }

    .btn-nav-admin-login,
    .btn-nav-action,
    .btn-nav-logout {
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
    }
}
// Añadir al final de nav.js:
(function() {
    new Image().src = 'admin-estadisticas.php?action=track_beacon&p=' + encodeURIComponent(window.location.pathname);
})();
