/* ===================================================================
   DINEROZA — MAIN NAVIGATION v3
   Desktop: Mega-menu (Apple-grade, text-only)
   Mobile:  5-tab bottom navigation bar
   =================================================================== */

/* ===================================================================
   DESKTOP NAV — Sticky clean top bar
   =================================================================== */

/* Ensure nav containers don't clip dropdown panels */
nav, .nav-wrapper, .nav-wrapper nav, .site-nav {
    overflow: visible !important;
}

/* Sticky wrapper */
.nav-wrapper {
    position: sticky;
    top: 0;
    z-index: 300;
    background: #fff;
    border-bottom: 1px solid rgba(6, 95, 70, 0.08);
    box-shadow: 0 1px 0 rgba(6, 95, 70, 0.04);
}

.site-nav {
    display: flex;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    gap: 0;
}

/* Logo */
.site-nav .logo,
nav .logo {
    font-family: 'DM Sans', -apple-system, sans-serif !important;
    font-weight: 800 !important;
    font-size: 1.35rem !important;
    color: var(--emerald, #065F46) !important;
    text-decoration: none !important;
    letter-spacing: -0.025em !important;
    flex-shrink: 0;
    margin-right: 2rem;
}
.site-nav .logo span,
nav .logo span {
    color: var(--gold, #D97706) !important;
}

/* Nav links list */
.nav-links {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    flex: 1;
    height: 100%;
}

.nav-links > li {
    display: flex;
    align-items: center;
    position: relative;
    height: 100%;
}

/* Nav link anchors — text-only, clean */
.nav-links > li > a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 0.85rem;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
    transition: color 0.14s ease;
    border-bottom: 2px solid transparent;
    position: relative;
    top: 1px; /* compensate for border-bottom */
}

.nav-links > li > a:hover {
    color: var(--emerald, #065F46);
}

.nav-links > li > a.active {
    color: var(--emerald, #065F46);
    border-bottom-color: var(--emerald, #065F46);
    font-weight: 600;
}

/* Guías link — gold accent */
.nav-links > li > a.nav-guias-link {
    color: var(--gold, #D97706);
    font-weight: 600;
}
.nav-links > li > a.nav-guias-link:hover {
    color: #b45309;
}
.nav-links > li > a.nav-guias-link.active {
    border-bottom-color: var(--gold, #D97706);
}

/* Chevron indicator on items with mega panel */
.nav-links > li.has-mega > a::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 5px;
    margin-left: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23374151' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.6;
    transition: transform 0.15s ease, opacity 0.15s ease;
    position: relative;
    top: 0.5px;
    flex-shrink: 0;
}
.nav-links > li.has-mega:hover > a::after,
.nav-links > li.has-mega.mega-open > a::after {
    transform: rotate(180deg);
    opacity: 0.9;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23065F46' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.nav-links > li.has-mega:hover > a,
.nav-links > li.has-mega.mega-open > a {
    color: var(--emerald, #065F46);
}


/* ===================================================================
   MEGA PANEL
   =================================================================== */

.mega-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #ffffff;
    border: 1px solid rgba(6, 95, 70, 0.1);
    border-radius: 14px;
    box-shadow:
        0 16px 56px rgba(6, 95, 70, 0.13),
        0 4px 16px rgba(0, 0, 0, 0.06);
    padding: 1rem;
    min-width: 320px;
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.99);
    transition:
        opacity 0.15s cubic-bezier(0.2, 0, 0.3, 1),
        transform 0.15s cubic-bezier(0.2, 0, 0.3, 1),
        visibility 0.15s;
    pointer-events: none;
}

/* Show on hover (pointer device) */
@media (hover: hover) and (pointer: fine) {
    .nav-links > li.has-mega:hover .mega-panel {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
}

/* Show via JS toggle */
.nav-links > li.has-mega.mega-open .mega-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Panel header — category title + subtitle */
.mega-header {
    padding: 0.5rem 0.25rem 0.75rem;
    border-bottom: 1px solid rgba(6, 95, 70, 0.07);
    margin-bottom: 0.75rem;
}
.mega-header a {
    display: block;
    text-decoration: none;
}
.mega-header a:hover .mega-title {
    color: var(--emerald, #065F46);
}
.mega-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
    transition: color 0.12s;
}
.mega-subtitle {
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 1px;
    font-weight: 400;
}

/* Grid of columns */
.mega-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 2), 1fr);
    gap: 0 1.25rem;
}

/* Column */
.mega-col-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9CA3AF;
    padding: 0 0.375rem 0.375rem;
    margin-top: 0.125rem;
}

/* Link in panel */
.mega-link {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.375rem;
    border-radius: 7px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1F2937;
    text-decoration: none;
    transition: background 0.1s, color 0.1s;
    line-height: 1.35;
    gap: 0.375rem;
}
.mega-link:hover {
    background: rgba(6, 95, 70, 0.05);
    color: var(--emerald, #065F46);
}
.mega-link::before {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--emerald, #065F46);
    flex-shrink: 0;
    opacity: 0.35;
    transition: opacity 0.1s;
}
.mega-link:hover::before {
    opacity: 0.7;
}

/* Wide panel for Guías mega-menu (4 columns) */
.mega-panel.mega-wide {
    min-width: 600px;
    right: 0;
    left: auto;
}
@media (max-width: 1200px) {
    .mega-panel.mega-wide {
        right: auto;
        left: -200px;
    }
}
@media (max-width: 960px) {
    .mega-panel.mega-wide {
        min-width: 380px;
        left: -50px;
    }
    .mega-panel.mega-wide .mega-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Right-align panels near the end of nav */
.nav-links > li:nth-last-child(-n+3).has-mega .mega-panel:not(.mega-wide) {
    left: auto;
    right: 0;
}

/* ===================================================================
   DESKTOP — Sticky raw <nav> (pages that don't use .nav-wrapper)
   =================================================================== */
@media (min-width: 769px) {
    nav:not(.site-nav) {
        position: sticky;
        top: 0;
        z-index: 300;
    }
}


/* ===================================================================
   TABLE SCROLL WRAPPER (utility — keep for all screen sizes)
   =================================================================== */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    margin: 1.5rem 0;
}
.table-scroll table,
.table-scroll > .comparison-table {
    min-width: 540px;
    margin: 0 !important;
}


/* ===================================================================
   MOBILE  (≤ 768px)
   Desktop nav hidden, bottom tab bar shown
   =================================================================== */
@media (max-width: 768px) {

    /* ── Hide desktop nav links ── */
    .nav-links { display: none !important; }

    /* ── Compact sticky top bar (logo only) ── */
    .nav-wrapper {
        position: sticky;
        top: 0;
        z-index: 300;
    }
    .site-nav {
        height: 52px;
        padding: 0 1rem;
        gap: 0;
        max-width: 100%;
    }
    /* Also handle bare nav (exclude .bottom-nav-bar which needs position:fixed) */
    nav:not(.bottom-nav-bar) {
        position: sticky !important;
        top: 0 !important;
        z-index: 300 !important;
        background: #fff !important;
        border-bottom: 1px solid rgba(6, 95, 70, 0.08) !important;
        min-height: 52px !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        display: flex !important;
        align-items: center !important;
    }
    .nav-wrapper nav {
        position: static !important;
        box-shadow: none !important;
        border-bottom: none !important;
        min-height: unset !important;
    }

    /* ── Push content above bottom nav ── */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Touch targets ── */
    .cta-btn, .apply-btn, .btn-primary, .btn-secondary,
    .pill-btn, a[class*="btn"], button[class*="btn"] {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .filter-btn, .pill, .quick-pill, .tab-btn {
        min-height: 40px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    /* ── Tables ── */
    .comparison-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        max-width: 100%;
    }
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* ── Typography ── */
    h1 { font-size: clamp(1.75rem, 7vw, 2.5rem) !important; }
    h2 { font-size: clamp(1.4rem, 5.5vw, 2rem) !important; }

    /* ── No horizontal overflow ── */
    section, .container, .inner {
        max-width: 100%;
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .search-wrap { max-width: 100%; }
    .quick-pills { flex-wrap: wrap; gap: 0.5rem; }
    .quick-pill { font-size: 0.8rem; }
}


/* ===================================================================
   BOTTOM NAV BAR  (mobile only)
   =================================================================== */

.bottom-nav-bar {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav-bar {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        height: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #ffffff !important;
        border-top: 1px solid rgba(6, 95, 70, 0.1);
        border-bottom: none !important;
        box-shadow: 0 -4px 24px rgba(6, 95, 70, 0.08);
        z-index: 500 !important;
        align-items: stretch;
        min-height: auto !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        flex-direction: row !important;
    }

    .bottom-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: #9CA3AF;
        font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        padding: 0.25rem 0.25rem 0;
        border: none;
        background: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.14s ease;
        min-width: 0;
        position: relative;
    }
    .bottom-tab:active {
        transform: scale(0.94);
        transition: transform 0.1s ease, color 0.14s ease;
    }

    .bottom-tab.active {
        color: var(--emerald, #065F46);
    }

    .bottom-tab-icon {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .bottom-tab-label {
        max-width: 56px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        line-height: 1;
    }

    /* Active indicator dot */
    .bottom-tab.active .bottom-tab-icon {
        filter: none;
    }

    /* ── "Más" badge when open ── */
    .bottom-tab-mas.mas-open {
        color: var(--emerald, #065F46);
    }
}


/* ===================================================================
   MÁS OVERLAY (full-screen menu sheet on mobile)
   =================================================================== */

.mas-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 490;
    opacity: 0;
    transition: opacity 0.22s ease;
}
.mas-overlay.visible {
    display: block;
    opacity: 1;
}

.mas-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 82vh;
    background: #fff;
    border-radius: 18px 18px 0 0;
    z-index: 495;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0, 0.1, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.mas-sheet.open {
    transform: translateY(0);
}

/* Sheet handle */
.mas-handle {
    width: 36px;
    height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 10px auto 0;
}

/* Sheet header */
.mas-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem 0.5rem;
}
.mas-sheet-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
}
.mas-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F3F4F6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: #6B7280;
    -webkit-tap-highlight-color: transparent;
}

/* Sheet nav grid */
.mas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem 0.5rem;
    padding: 0.5rem 1rem 1rem;
}

.mas-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    border-radius: 12px;
    background: #F9FAFB;
    text-decoration: none;
    color: #1F2937;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid rgba(6, 95, 70, 0.07);
}
.mas-item:active {
    background: rgba(6, 95, 70, 0.08);
    color: var(--emerald, #065F46);
}
.mas-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(6, 95, 70, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

/* Section header within sheet */
.mas-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9CA3AF;
    padding: 0.75rem 1rem 0.25rem;
    grid-column: 1 / -1;
}

/* Guías full-width link at bottom of sheet */
.mas-guias-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 0.875rem;
    border-radius: 12px;
    background: rgba(217, 119, 6, 0.06);
    border: 1px solid rgba(217, 119, 6, 0.15);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.mas-guias-row:active {
    background: rgba(217, 119, 6, 0.12);
}
.mas-guias-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: #92400E;
}
.mas-guias-arrow {
    color: var(--gold, #D97706);
    font-size: 1.125rem;
    font-weight: 700;
}


/* ===================================================================
   OVERRIDE design-system.css — mobile-nav.css loads after it,
   so same-specificity + !important rules here win.
   =================================================================== */

/* Override design-system.css nav link padding/border-radius/size */
.nav-links > li > a,
.nav-links > a,
.nav-links > .nav-item > a {
    padding: 0 0.85rem !important;
    border-radius: 0 !important;
    font-size: 0.875rem !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
}

/* Override design-system.css gap */
.nav-links {
    gap: 0 !important;
}

/* Override design-system.css active = gold; we want emerald + underline */
.nav-links a.active {
    color: var(--emerald, #065F46) !important;
    font-weight: 600 !important;
    background: transparent !important;
}

/* Design-system hover uses background — we don't want that */
.nav-links a:hover {
    background: transparent !important;
}

/* Override design-system.css sticky header z-index (was 100, needs 300 for mega panels) */
@media (min-width: 769px) {
    .nav-wrapper {
        z-index: 300 !important;
    }
    header {
        z-index: 300 !important;
    }
}


/* ===================================================================
   LEGACY COMPATIBILITY  (old hamburger classes — kept but inert)
   Prevents JS errors on pages that still reference them
   =================================================================== */
.hamburger-btn { display: none !important; }
.mobile-overlay { display: none !important; }
.mobile-drawer { display: none !important; }
