/*
 * ============================================================
 *  NAV UNIVERSAL — Uo Epigenetics
 *  Aplicable a: index.html, medicos.html, aliados.html,
 *               test.html, socios.html, redes_sociales.html
 *  Sin dependencias. CSS puro. Sin CLS.
 * ============================================================
 */

/* ── Variables ── */
:root {
    --nav-bg: #ffffff;
    --nav-shadow: 0 4px 20px rgba(15, 42, 92, 0.08);
    --nav-primary: #0F2A5C;
    --nav-medium: #1E4B8C;
    --nav-accent: #2A6BC5;
    --nav-text: #333333;
    --nav-cta-bg: #2A6BC5;
    --nav-cta-hover: #1E4B8C;
    --nav-overlay-bg: rgba(15, 42, 92, 0.6);
    --nav-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-z-header: 1000;
    --nav-z-mobile: 1010;
    --nav-z-overlay: 1005;
}

/* ── Sticky Header ── */
.uo-header {
    position: sticky;
    top: 0;
    z-index: var(--nav-z-header);
    background: var(--nav-bg);
    box-shadow: var(--nav-shadow);
    transition: box-shadow var(--nav-transition);
    /* Previene CLS: altura fija explícita */
    min-height: 72px;
    display: flex;
    align-items: center;
    width: 100%;
}

.uo-header.scrolled {
    box-shadow: 0 6px 30px rgba(15, 42, 92, 0.14);
}

/* ── Inner container ── */
.uo-logo {
    display: flex;
    align-items: center;
    padding: 10px 0;
}

.uo-logo img {
    height: 50px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.uo-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 16px;
}

/* ── Logo ── */
.uo-logo {
    flex-shrink: 0;
    line-height: 0;
    text-decoration: none;
}

.uo-logo img {
    height: 52px;
    width: auto;
    display: block;
    /* Dimensiones explícitas: previene CLS */
    aspect-ratio: 3 / 1;
}

/* ── Desktop menu ── */
.uo-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.uo-menu li {
    position: relative;
}

.uo-menu a,
.uo-menu button.uo-dropbtn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    min-height: 44px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--nav-text);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    transition: color var(--nav-transition), background var(--nav-transition);
    white-space: nowrap;
}

.uo-menu a:hover,
.uo-menu button.uo-dropbtn:hover,
.uo-menu a.active {
    color: var(--nav-accent);
    background: rgba(42, 107, 197, 0.07);
}

.uo-menu a.active {
    color: var(--nav-primary);
}

/* ── Dropdown (hover + click) ── */
.uo-dropdown {
    position: relative;
}

.uo-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--nav-bg);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 42, 92, 0.14);
    border: 1px solid rgba(42, 107, 197, 0.08);
    list-style: none;
    padding: 8px;
    margin: 0;
    /* Animación sin CLS */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 10;
}

.uo-dropdown-menu.open,
.uo-dropdown:hover .uo-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.uo-dropdown-menu li a {
    display: block;
    padding: 10px 16px;
    min-height: 44px;
    border-radius: 8px;
    color: var(--nav-text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.uo-dropdown-menu li a:hover {
    background: rgba(42, 107, 197, 0.07);
    color: var(--nav-accent);
}

/* ── Chevron icon ── */
.uo-dropbtn .uo-chevron {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.uo-dropdown.open .uo-chevron {
    transform: rotate(180deg);
}

/* ── CTA Button: "Hacer test" ── */
.uo-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    min-height: 44px;
    background: var(--nav-cta-bg);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 50px;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--nav-transition), transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(42, 107, 197, 0.3);
    flex-shrink: 0;
}

.uo-cta-btn:hover,
.uo-cta-btn:focus {
    background: var(--nav-cta-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(42, 107, 197, 0.4);
    color: #ffffff !important;
    outline: 2px solid rgba(42, 107, 197, 0.4);
    outline-offset: 2px;
}

/* ── Hamburger button ── */
.uo-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.5rem;
    color: var(--nav-primary);
}

.uo-hamburger:hover {
    background: rgba(42, 107, 197, 0.07);
    color: var(--nav-accent);
}

.uo-hamburger[aria-expanded="true"] {
    color: var(--nav-accent);
}

/* ── Mobile Overlay ── */
.uo-overlay {
    position: fixed;
    inset: 0;
    background: var(--nav-overlay-bg);
    z-index: var(--nav-z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    backdrop-filter: blur(2px);
}

.uo-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ── Mobile drawer ── */
.uo-mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(88vw, 360px);
    height: 100%;
    background: var(--nav-bg);
    z-index: var(--nav-z-mobile);
    transition: right 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.25);
    border-radius: 24px 0 0 24px;
    overflow: hidden;
}

.uo-mobile-nav.open {
    right: 0;
}

/* Mobile nav header */
.uo-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(42, 107, 197, 0.08);
}

.uo-mobile-logo img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.uo-mobile-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--nav-text);
    transition: background 0.2s, transform 0.2s;
}

.uo-mobile-close:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

/* Mobile nav links */
.uo-mobile-menu {
    list-style: none;
    padding: 16px 16px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.uo-mobile-menu li {
    margin-bottom: 4px;
}

.uo-mobile-menu > li > a,
.uo-mobile-menu > li > button.uo-mobile-dropbtn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    min-height: 52px;
    width: 100%;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--nav-text);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.uo-mobile-menu > li > a .uo-nav-icon,
.uo-mobile-menu > li > button .uo-nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(42, 107, 197, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nav-accent);
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: background 0.2s;
}

.uo-mobile-menu > li > a:hover,
.uo-mobile-menu > li > button:hover {
    background: #f8fafc;
    color: var(--nav-accent);
    transform: translateX(4px);
}

.uo-mobile-menu > li > a:hover .uo-nav-icon,
.uo-mobile-menu > li > button:hover .uo-nav-icon {
    background: rgba(42, 107, 197, 0.15);
}

.uo-mobile-menu > li > a.active {
    background: rgba(42, 107, 197, 0.07);
    color: var(--nav-primary);
}

/* Mobile dropdown sub-items */
.uo-mobile-sub {
    list-style: none;
    padding: 4px 0 4px 46px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.uo-mobile-sub.open {
    max-height: 300px;
    opacity: 1;
}

.uo-mobile-sub li a {
    display: block;
    padding: 10px 16px;
    min-height: 44px;
    border-radius: 8px;
    color: var(--nav-text);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, padding-left 0.2s;
}

.uo-mobile-sub li a:hover {
    background: #f1f5f9;
    color: var(--nav-accent);
    padding-left: 22px;
}

/* Mobile sub chevron */
.uo-mobile-dropbtn {
    justify-content: space-between !important;
}

.uo-mobile-dropbtn .uo-chevron {
    font-size: 0.75rem;
    transition: transform 0.25s;
}

.uo-mobile-dropbtn[aria-expanded="true"] .uo-chevron {
    transform: rotate(180deg);
}

/* Mobile CTA footer */
.uo-mobile-footer {
    padding: 20px 24px 32px;
    border-top: 1px solid rgba(42, 107, 197, 0.08);
    background: #f8fafc;
}

.uo-mobile-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    min-height: 52px;
    background: var(--nav-cta-bg);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.35);
    transition: background 0.2s, transform 0.2s;
}

.uo-mobile-cta:hover {
    background: var(--nav-cta-hover);
    transform: translateY(-2px);
    color: #ffffff !important;
}

.uo-mobile-contact {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uo-mobile-contact a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    font-size: 0.88rem;
    text-decoration: none;
    transition: color 0.2s;
}

.uo-mobile-contact a:hover {
    color: var(--nav-accent);
}

.uo-mobile-contact i {
    width: 16px;
    color: var(--nav-accent);
}

/* ── Responsive: mostrar hamburguesa ── */
@media (max-width: 1024px) {
    .uo-desktop-menu,
    .uo-cta-btn {
        display: none;
    }

    .uo-hamburger {
        display: flex;
    }
}

@media (max-width: 480px) {
    .uo-logo img {
        height: 44px;
    }

    .uo-nav {
        padding: 0 16px;
    }
}
