:root {
    --navbar-h: 66px;
}

.navbar {
    background: rgba(30, 41, 59, 0.95);
    color: #e2e8f0;
    padding: 0;
    border-bottom: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    overflow: visible;
    height: var(--navbar-h);
    display: block;
    width: 100%;
    z-index: 10010;
}

/* Push page content below the fixed navbar on all pages */
.container,
.header-container {
    padding-top: var(--navbar-h);
    overflow-x: hidden !important;
    /* Evitar desbordamiento horizontal que desalinea el menú móvil */
    overflow-y: visible !important;
    /* Permitir scroll vertical */
}

body {
    overflow-x: hidden !important;
    /* Evitar desbordamiento horizontal en toda la página */
}

/* iPad 11" específico en el navbar.js */
@media (min-width: 1000px) and (max-width: 1300px) and (min-height: 700px) and (max-height: 800px) {
    .navbar {
        height: 46px !important;
        padding: 5px 0 !important;
    }

    .navbar-content {
        height: 46px !important;
        padding: 0 20px !important;
    }

    .navbar-logo {
        height: 24px !important;
    }

    .nav-links {
        gap: 12px !important;
    }

    .navbar .nav-links a {
        padding: 6px 10px 4px !important;
        font-size: var(--font-sm) !important;
    }
}

.navbar-content {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
    padding: 0 40px;
    width: 100%;
    height: 66px;
}

.navbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    width: 100%;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.navbar-brand:hover {
    transform: translateY(-1px);
}

.navbar-brand:hover .navbar-logo {
    transform: scale(1.05);
}

.navbar-logo {
    height: 32px;
    width: auto;
    transition: transform 0.3s ease;
    display: block;
    flex-shrink: 0;
}

/* Navbar Search Box */
.navbar-search-box {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    height: 100%;
}

.navbar-search-input {
    width: 220px;
    padding: 6px 14px;
    font-size: var(--font-sm);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 20px;
    background: rgba(30, 41, 59, 0.95);
    color: #e2e8f0;
    transition: all 0.25s ease;
    font-family: "Inter", sans-serif;
    outline: none;
}

.navbar-search-input::placeholder {
    color: #94a3b8;
}

.navbar-search-input:focus {
    background: rgba(30, 41, 59, 0.95);
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.navbar-search-input:hover:not(:focus) {
    border-color: rgba(71, 85, 105, 0.5);
    background: rgba(30, 41, 59, 0.95);
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-links .search-link {
    order: 6;
}

body .navbar .nav-links a {
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 600;
    font-variation-settings: "wght" 600;
    font-family: "Inter", sans-serif;
    font-size: var(--font-md-sm);
    padding: 15px 20px 9px;
    border-radius: 12px;
    transition:
        color 0.3s ease,
        background-color 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-content: center;
    letter-spacing: normal;
    white-space: nowrap;
    /* Prevent wrapping on font load */
    transform: translateZ(0);
    /* Hardware acceleration to prevent jitter */
}

body .navbar .nav-links a:not(.search-link):hover {
    color: #3b82f6 !important;
    background: transparent;
}

body .navbar .nav-links a.active {
    color: white !important;
    background: transparent;
}

body .navbar .nav-links a.active svg {
    color: white !important;
}

.nav-links .search-link svg {
    width: 20px;
    height: 20px;
    color: #3b82f6;
    transition: color 0.3s ease;
}

.nav-links .search-link:hover svg {
    color: white !important;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-left: 20px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background-color: #e2e8f0;
    border-radius: 9999px;
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
}

.mobile-menu-toggle span + span {
    margin-top: 5px;
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

body.navbar-menu-open {
    overflow: hidden;
}

/* Desktop: constrain navbar content width */
@media (min-width: 1025px) {
    :root {
        --navbar-h: 52px;
    }

    .navbar {
        height: var(--navbar-h);
    }

    .navbar-content {
        padding: 0 20px;
        height: var(--navbar-h);
    }

    .navbar-inner {
        max-width: none;
        width: 100%;
        margin: 0;
        display: flex;
        justify-content: flex-start;
        /* título a la izquierda */
        align-items: center;
    }

    .nav-links {
        gap: 16px;
        margin-left: auto;
        /* empuja los enlaces a la derecha */
    }

    /* Añadir separación extra entre el título y el primer enlace */
    .navbar-inner > a:first-child {
        margin-right: 24px;
    }

    body .navbar .nav-links a {
        padding: 8px 12px 6px;
    }
}

/* iPad específico - Entre 768px y 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --navbar-h: 56px;
    }

    .navbar {
        padding: 8px 0;
        height: var(--navbar-h);
    }

    .navbar-content {
        padding: 0 24px;
        height: var(--navbar-h);
    }

    .navbar-logo {
        height: 28px;
    }

    .nav-links {
        gap: 16px;
    }

    body .navbar .nav-links a {
        padding: 8px 12px 6px;
        font-size: var(--font-sm) !important;
    }
}

@media (max-width: 768px) {
    :root {
        --navbar-h: 56px;
    }

    .navbar {
        height: var(--navbar-h);
        overflow: visible !important;
    }

    .navbar-content {
        padding: 0 16px;
        height: var(--navbar-h);
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        overflow: visible !important;
    }

    /* Ocultar el cuadro de búsqueda en móvil */
    .navbar-search-box {
        display: none;
    }

    /* Asegurar que containers no corten el menú - CORREGIDO para evitar desalineación */
    body,
    html,
    .container,
    .header-container {
        overflow-x: hidden !important;
        /* Evitar desbordamiento horizontal */
    }

    .navbar-inner {
        overflow-x: visible !important;
        /* Solo el navbar-inner necesita visible para el menú */
    }

    .navbar-inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        width: 100%;
    }

    .navbar-logo {
        height: 26px;
    }

    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        margin-left: 0 !important;
    }

    /* Contenedor que agrupa lupa y hamburguesa a la derecha */
    .navbar-right-mobile {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: auto;
    }

    /* Ocultar la lupa original dentro del menú en móvil */
    .nav-links .search-link {
        display: none !important;
    }

    /* Mostrar la lupa clonada en el navbar */
    .navbar-right-mobile .search-link-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
    }

    .navbar-right-mobile .search-link-mobile svg {
        width: 20px;
        height: 20px;
        color: #3b82f6;
    }

    .nav-links {
        display: none;
        position: fixed !important;
        top: 56px !important;
        right: 0 !important;
        left: auto !important;
        width: 140px !important;
        background: rgba(30, 41, 59, 0.95) !important;
        border-radius: 0 !important;
        flex-direction: column !important;
        gap: 0 !important;
        box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35) !important;
        padding: 8px 0 !important;
        opacity: 0;
        pointer-events: none;
        transform: none !important;
        transition: opacity 0.25s ease;
        border: none !important;
        border-left: 1px solid rgba(71, 85, 105, 0.3) !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: none !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
        z-index: 99999 !important;
        /* Z-index muy alto para estar por encima de todo */
    }

    .nav-links.open {
        display: flex !important;
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0) !important;
    }

    body .navbar .nav-links a {
        width: 100% !important;
        padding: 12px 20px !important;
        border-radius: 0 !important;
        justify-content: flex-start !important;
        font-size: var(--font-sm) !important;
        font-weight: 600 !important;
        text-align: left !important;
        margin: 0 !important;
        line-height: 1;
        border: none !important;
        border-top: none !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
        background: transparent !important;
    }
}

/* Dark theme styles for navbar */
.dark-theme .navbar,
.dark-theme .navbar-content,
.dark-theme .navbar-inner {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

.dark-theme .nav-links {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

.dark-theme .nav-links a {
    color: #f1f5f9 !important;
}

.dark-theme .navbar-search-input {
    background: #1e293b;
    color: #f1f5f9;
    border-color: rgba(71, 85, 105, 0.4);
}

.dark-theme .navbar-search-input::placeholder {
    color: #94a3b8;
}

.dark-theme .navbar-search-input:focus {
    background: #1e293b;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.dark-theme .navbar-search-input:hover:not(:focus) {
    border-color: rgba(71, 85, 105, 0.6);
    background: #1e293b;
}
