/* =====================================================
   NAVBAR - FIXED: Smooth, No Jitter
   ===================================================== */

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gradient-nav);
    padding: 0 20px;
    position: sticky;
    top: 62px;
    z-index: 999;
    min-height: 50px;
    /* overflow:visible is critical — allows dropdown to escape nav bounds */
    overflow: visible;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    overflow: visible;
}

.hamburger-btn {
    display: none;
    color: #fff;
    font-size: 22px;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    /* Prevent layout shift */
    transform: translateZ(0);
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow: visible;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    position: relative;
    /* Smooth transition - use transform instead of width */
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-links li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #fff;
    border-radius: 3px 3px 0 0;
    /* Use transform for smooth animation */
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-links li a:hover::after,
.nav-links li a.active::after {
    transform: translateX(-50%) scaleX(1);
    width: 80%;
}

.nav-links li a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-links li a.active {
    background: rgba(255, 255, 255, 0.18);
}

.nav-links li a i {
    font-size: 13px;
    opacity: 0.9;
}

/* Navbar Flag Emoji */
.nav-links li a .nav-flag {
    font-size: 16px;
    line-height: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .main-nav {
        padding: 0 14px;
        top: 56px;
        min-height: 46px;
    }
    
    .hamburger-btn {
        display: flex;
    }
    
    .nav-links li a {
        padding: 12px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .main-nav {
        padding: 0 10px;
        top: 52px;
        min-height: 44px;
    }
    
    .nav-links li a {
        padding: 10px 12px;
        font-size: 12px;
    }
}
/* ===== Countries Dropdown (All Countries quick link) ===== */
.nav-links li.has-dropdown {
    position: relative;
}

/* Toggle button — matches the style of other nav <a> links exactly */
.nav-links li.has-dropdown > .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 100%;
    min-height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    /* Force white like all other nav links */
    color: #fff;
    font-family: inherit;
    font-size: inherit;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    border-radius: 6px;
    position: relative;
}

/* Underline hover effect — mirrors nav-links li a::after */
.nav-links li.has-dropdown > .dropdown-toggle::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.nav-links li.has-dropdown > .dropdown-toggle:hover::after,
.nav-links li.has-dropdown.open > .dropdown-toggle::after {
    transform: scaleX(1);
}

.nav-links li.has-dropdown > .dropdown-toggle:hover {
    background: rgba(255,255,255,0.12);
}

.nav-links li.has-dropdown.open > .dropdown-toggle {
    background: rgba(255,255,255,0.18);
}

.nav-links li.has-dropdown > .dropdown-toggle .dd-chevron {
    font-size: 9px;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

.nav-links li.has-dropdown.open > .dropdown-toggle .dd-chevron {
    transform: rotate(180deg);
}

/* ---- Dropdown Panel — position:absolute, anchored to the toggle button ---- */
.nav-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);   /* just below the button */
    left: 0;
    min-width: 210px;
    max-width: 270px;
    max-height: 340px;
    overflow-y: auto;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-light, rgba(0,0,0,0.10));
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.20);
    z-index: 99999;
    padding: 6px 0;
    scrollbar-width: thin;
    animation: ddFadeIn 0.15s ease;
}

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

.nav-links li.has-dropdown.open .nav-dropdown-panel {
    display: block;
}

/* Panel header label */
.nav-dropdown-panel .dd-header {
    padding: 8px 14px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-red, #DC143C);
    opacity: 0.8;
}

/* Country links inside panel — must override .nav-links li a { color:#fff } */
.nav-links .nav-dropdown-panel a,
.nav-links .nav-dropdown-panel a .dd-name {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e) !important;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s ease, color 0.12s ease;
    border-radius: 0;
    background: none !important;
}

.nav-links .nav-dropdown-panel a .dd-name {
    display: block;
    padding: 0;
    gap: 0;
    font-size: inherit;
    font-weight: inherit;
}

.nav-links .nav-dropdown-panel a .dd-flag {
    font-size: 15px;
    flex-shrink: 0;
    line-height: 1;
}

.nav-links .nav-dropdown-panel a:hover,
.nav-links .nav-dropdown-panel a:hover .dd-name {
    background: rgba(220,20,60,0.07) !important;
    color: var(--accent-red, #DC143C) !important;
}

.nav-dropdown-panel .dd-divider {
    height: 1px;
    background: var(--border-light, rgba(0,0,0,0.08));
    margin: 5px 10px;
}

/* "View All" footer link */
.nav-links .nav-dropdown-panel .dd-view-all,
.nav-links .nav-dropdown-panel .dd-view-all .dd-name {
    font-weight: 700;
    font-size: 12px;
    color: var(--accent-red, #DC143C) !important;
    justify-content: center;
    letter-spacing: 0.3px;
    padding: 10px 14px;
}

.nav-links .nav-dropdown-panel .dd-view-all:hover {
    background: rgba(220,20,60,0.1) !important;
}

/* Dark mode panel overrides */
body.dark-mode .nav-dropdown-panel {
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

body.dark-mode .nav-dropdown-panel a:hover {
    background: rgba(220,20,60,0.14);
}

/* ===== Mobile: show All Countries dropdown in nav ===== */
@media (max-width: 768px) {
    /* Show only the dropdown toggle on mobile nav (hide all other nav-links) */
    .nav-links {
        display: flex !important;
        overflow: visible !important;
    }
    .nav-links > li {
        display: none;
    }
    /* Only show the All Countries dropdown li on mobile */
    .nav-links > li.has-dropdown {
        display: flex;
    }
    /* Compact button on mobile */
    .nav-links li.has-dropdown > .dropdown-toggle {
        padding: 0 10px;
        font-size: 13px;
        min-height: 48px;
    }
    /* Wider panel on mobile */
    .nav-dropdown-panel {
        min-width: 240px;
        max-width: calc(100vw - 24px);
    }
}
