/* ===========================================
   RESPONSIVE NAVBAR STYLES
   Fixed for mobile visibility issues
   =========================================== */

/* CSS Variables */
:root {
    --navbar-primary: #003366;
    --navbar-primary-dark: #002244;
    --navbar-accent: #ff7e00;
    --navbar-light: #ffffff;
    --navbar-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --navbar-transition: all 0.3s ease;
}

/* ===========================================
   CORE NAVBAR
   =========================================== */

.navbar {
    background-color: var(--navbar-primary);
    padding: 0.75rem 0;
    box-shadow: var(--navbar-shadow);
    transition: var(--navbar-transition);
    z-index: 1050;
}

.navbar.scrolled {
    padding: 0.5rem 0;
    background-color: rgba(0, 51, 102, 0.98);
}

/* ===========================================
   NAVBAR BRAND
   =========================================== */

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.navbar-brand:hover {
    color: #fff !important;
}

.navbar-brand img {
    max-width: 45px !important;
    max-height: 45px !important;
    object-fit: contain !important;
}

/* ===========================================
   HAMBURGER TOGGLE BUTTON
   =========================================== */

.navbar-toggler {
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-toggler:hover,
.navbar-toggler:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: none;
    outline: none;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ===========================================
   DESKTOP NAV LINKS
   =========================================== */

@media (min-width: 992px) {
    .nav-link {
        color: rgba(255, 255, 255, 0.9) !important;
        font-weight: 500;
        font-size: 0.95rem;
        padding: 0.5rem 0.85rem !important;
        border-radius: 6px;
        transition: var(--navbar-transition);
    }

    .nav-link:hover {
        color: #fff !important;
        background-color: rgba(255, 255, 255, 0.1);
    }

    .nav-link.active {
        color: var(--navbar-accent) !important;
    }

    /* Desktop underline effect */
    .nav-link::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        width: 0;
        height: 2px;
        background-color: var(--navbar-accent);
        transition: width 0.3s ease, left 0.3s ease;
    }

    .nav-link:hover::after,
    .nav-link.active::after {
        width: 70%;
        left: 15%;
    }

    .nav-link.dropdown-toggle::after {
        width: 0 !important;
        background: transparent !important;
    }
}

/* ===========================================
   DESKTOP DROPDOWN
   =========================================== */

@media (min-width: 992px) {
    .dropdown-menu {
        background-color: #fff;
        border: none;
        border-radius: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        padding: 0.5rem 0;
        margin-top: 0.5rem;
        min-width: 14rem;
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        display: block;
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    .dropdown:hover > .dropdown-menu {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .dropdown-item {
        color: var(--navbar-primary);
        font-weight: 500;
        padding: 0.6rem 1.25rem;
        transition: all 0.2s ease;
    }

    .dropdown-item:hover {
        background-color: rgba(0, 51, 102, 0.08);
        color: var(--navbar-accent);
    }

    /* Submenu */
    .dropdown-submenu {
        position: relative;
    }

    .dropdown-submenu > .dropdown-menu {
        top: 0;
        left: 100%;
        margin-left: 2px;
        margin-top: -0.5rem;
    }

    .dropdown-submenu:hover > .dropdown-menu {
        display: block;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

/* ===========================================
   MOBILE OFFCANVAS - CRITICAL FIX
   =========================================== */

/* Offcanvas container styling - MOBILE ONLY */
@media (max-width: 991.98px) {
    .offcanvas.navbar-offcanvas,
    .navbar-offcanvas.offcanvas {
        background: linear-gradient(180deg, var(--navbar-primary) 0%, var(--navbar-primary-dark) 100%) !important;
        color: #fff !important;
        border-left: 3px solid var(--navbar-accent) !important;
        max-width: 320px;
        width: 85vw !important;
        height: 100vh !important;
        min-height: 100vh !important;
        top: 0 !important;
        bottom: 0 !important;
        position: fixed !important;
    }

    .offcanvas.navbar-offcanvas.show,
    .navbar-offcanvas.offcanvas.show,
    .offcanvas.navbar-offcanvas.showing,
    .navbar-offcanvas.offcanvas.showing {
        height: 100vh !important;
        min-height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
}

/* Desktop - reset offcanvas to normal inline navigation */
@media (min-width: 992px) {
    .offcanvas.navbar-offcanvas,
    .navbar-offcanvas.offcanvas,
    .offcanvas-lg.navbar-offcanvas {
        position: static !important;
        height: auto !important;
        min-height: auto !important;
        width: auto !important;
        max-width: none !important;
        background: transparent !important;
        border: none !important;
        display: flex !important;
        flex-direction: row !important;
        visibility: visible !important;
        transform: none !important;
        flex-grow: 1 !important;
        justify-content: flex-end !important;
    }
    
    .offcanvas.navbar-offcanvas .offcanvas-body,
    .navbar-offcanvas .offcanvas-body {
        padding: 0 !important;
        overflow: visible !important;
        flex-grow: 0 !important;
        display: flex !important;
        justify-content: flex-end !important;
    }
    
    .navbar-nav.ms-lg-auto {
        margin-left: auto !important;
    }
}

/* Offcanvas header - MOBILE ONLY */
@media (max-width: 991.98px) {
    .offcanvas.navbar-offcanvas .offcanvas-header,
    .navbar-offcanvas .offcanvas-header {
        background: rgba(0, 0, 0, 0.2) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
        padding: 1rem 1.25rem !important;
    }

    .offcanvas.navbar-offcanvas .offcanvas-title,
    .navbar-offcanvas .offcanvas-title {
        color: #fff !important;
        font-weight: 600;
        font-size: 1.1rem;
    }

    .offcanvas.navbar-offcanvas .btn-close-white,
    .navbar-offcanvas .btn-close-white {
        filter: brightness(1) !important;
        opacity: 1 !important;
    }

    /* Offcanvas body - MOBILE ONLY */
    .offcanvas.navbar-offcanvas .offcanvas-body,
    .navbar-offcanvas .offcanvas-body {
        padding: 1rem !important;
        background: transparent !important;
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        min-height: 0 !important;
    }
}

/* ===========================================
   MOBILE NAV LINKS - CRITICAL VISIBILITY FIX
   =========================================== */

/* Mobile nav links must be visible */
@media (max-width: 991.98px) {
    .navbar-offcanvas .navbar-nav {
        width: 100% !important;
    }

    .navbar-offcanvas .nav-item {
        width: 100% !important;
        margin-bottom: 0.25rem !important;
    }

    /* CRITICAL: Force white text color on mobile nav links */
    .navbar-offcanvas .nav-link,
    .offcanvas .nav-link,
    .offcanvas-body .nav-link,
    #touristNav .nav-link,
    #responsiveNav .nav-link {
        color: #ffffff !important;
        background-color: rgba(255, 255, 255, 0.08) !important;
        padding: 0.9rem 1rem !important;
        border-radius: 10px !important;
        font-weight: 500 !important;
        font-size: 1rem !important;
        display: block !important;
        width: 100% !important;
        text-decoration: none !important;
    }

    .navbar-offcanvas .nav-link:hover,
    .offcanvas .nav-link:hover,
    .offcanvas-body .nav-link:hover,
    #touristNav .nav-link:hover,
    #responsiveNav .nav-link:hover {
        color: #ffffff !important;
        background-color: rgba(255, 255, 255, 0.18) !important;
    }

    .navbar-offcanvas .nav-link.active,
    .offcanvas .nav-link.active,
    .offcanvas-body .nav-link.active,
    #touristNav .nav-link.active,
    #responsiveNav .nav-link.active {
        color: var(--navbar-accent) !important;
        border-left: 3px solid var(--navbar-accent) !important;
    }

    /* Remove desktop underline on mobile */
    .navbar-offcanvas .nav-link::after,
    .offcanvas .nav-link::after {
        display: none !important;
    }
}

/* ===========================================
   MOBILE ACCORDION TOGGLES
   =========================================== */

.mobile-nav-toggle,
.mobile-district-btn {
    width: 100% !important;
    border: none !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border-radius: 10px !important;
    padding: 0.9rem 1rem !important;
    margin-bottom: 0.25rem !important;
    text-align: left !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
}

.mobile-nav-toggle:hover,
.mobile-nav-toggle:focus,
.mobile-district-btn:hover,
.mobile-district-btn:focus {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
    outline: none !important;
}

.mobile-nav-toggle:not(.collapsed),
.mobile-district-btn:not(.collapsed) {
    background-color: rgba(255, 126, 0, 0.2) !important;
    border-left: 3px solid var(--navbar-accent) !important;
}

/* District list container */
.mobile-district-list {
    background: rgba(0, 0, 0, 0.15) !important;
    border-radius: 10px !important;
    padding: 0.75rem !important;
    margin-top: 0.5rem !important;
}

/* District collapse content */
.mobile-district-btn + .collapse {
    border-left: 2px solid rgba(255, 255, 255, 0.2) !important;
    margin-left: 0.5rem !important;
    padding-left: 0.75rem !important;
    margin-bottom: 0.5rem !important;
}

/* Municipality links */
.mobile-municipality-link {
    display: block !important;
    padding: 0.65rem 0.85rem !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
    border-radius: 8px !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
}

.mobile-municipality-link:hover {
    color: var(--navbar-accent) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    transform: translateX(4px);
}

/* ===========================================
   COLLAPSE ARROW
   =========================================== */

.collapse-arrow {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 0.9rem !important;
    color: #fff !important;
    transition: transform 0.3s ease, border-color 0.3s ease !important;
    flex-shrink: 0 !important;
}

.collapse-arrow::before {
    content: '›' !important;
}

.mobile-nav-toggle[aria-expanded="true"] .collapse-arrow,
.mobile-district-btn[aria-expanded="true"] .collapse-arrow {
    transform: rotate(90deg) !important;
    border-color: var(--navbar-accent) !important;
    background-color: rgba(255, 126, 0, 0.3) !important;
}

/* ===========================================
   DESKTOP RESET - OFFCANVAS AS NORMAL NAV
   =========================================== */

@media (min-width: 992px) {
    .navbar-offcanvas,
    .offcanvas.navbar-offcanvas {
        background: transparent !important;
        border: none !important;
        width: auto !important;
        max-width: none !important;
        box-shadow: none !important;
    }

    .navbar-offcanvas .offcanvas-body,
    .offcanvas.navbar-offcanvas .offcanvas-body {
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
    }

    .navbar-offcanvas .nav-link,
    .offcanvas.navbar-offcanvas .nav-link {
        background: transparent !important;
        margin-bottom: 0 !important;
        border-radius: 6px !important;
        padding: 0.5rem 0.85rem !important;
        border-left: none !important;
    }

    .navbar-offcanvas .offcanvas-header,
    .offcanvas.navbar-offcanvas .offcanvas-header,
    .navbar-offcanvas .mobile-nav-toggle,
    .navbar-offcanvas .mobile-district-list,
    .offcanvas.navbar-offcanvas .mobile-nav-toggle,
    .offcanvas.navbar-offcanvas .mobile-district-list {
        display: none !important;
    }
}

/* ===========================================
   SMALL DEVICE ADJUSTMENTS
   =========================================== */

@media (max-width: 575.98px) {
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 1rem;
        gap: 0.4rem;
    }

    .navbar-brand img {
        max-width: 38px !important;
        max-height: 38px !important;
    }

    .offcanvas.navbar-offcanvas,
    .navbar-offcanvas.offcanvas {
        width: 100vw !important;
        max-width: 100vw !important;
        border-left: none !important;
        border-top: 3px solid var(--navbar-accent) !important;
    }
}

@media (max-width: 400px) {
    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar-brand img {
        max-width: 32px !important;
        max-height: 32px !important;
    }

    .navbar-toggler {
        padding: 0.4rem 0.6rem;
    }
}

/* ===========================================
   ENSURE DROPDOWN VISIBILITY FIX
   (Override any conflicting styles)
   =========================================== */

/* Force dropdown menu items visible on desktop */
@media (min-width: 992px) {
    .dropdown-menu {
        background-color: #fff !important;
    }

    .dropdown-item {
        color: var(--navbar-primary) !important;
    }

    .dropdown-item:hover {
        color: var(--navbar-accent) !important;
        background-color: rgba(0, 51, 102, 0.08) !important;
    }
}

/* ===========================================
   ACCESSIBILITY
   =========================================== */

.nav-link:focus-visible,
.mobile-nav-toggle:focus-visible,
.mobile-district-btn:focus-visible,
.mobile-municipality-link:focus-visible {
    outline: 2px solid var(--navbar-accent) !important;
    outline-offset: 2px !important;
}

@media (prefers-reduced-motion: reduce) {
    .navbar,
    .nav-link,
    .dropdown-menu,
    .mobile-nav-toggle,
    .mobile-district-btn,
    .collapse-arrow {
        transition: none !important;
    }
}
