/* Custom Navbar Styling */

/* Google Fonts - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

/* Basis styling */
.custom-navbar-container {
    font-family: 'korolev', sans-serif;
    position: relative;
    z-index: 1000;
}

/* =============================================
   HAMBURGER BUTTON - Hidden on desktop
   ============================================= */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    flex-direction: column;
    gap: 6px;
    z-index: 1003;
    position: relative;
}

.navbar-toggle:hover,
.navbar-toggle:focus {
    outline: none;
    background: transparent;
}

.hamburger-line {
    width: 28px;
    height: 2.5px;
    background-color: #333;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* Hamburger animation to X */
.navbar-toggle.active .hamburger-line:first-child {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar-toggle.active .hamburger-line:last-child {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* =============================================
   CLOSE BUTTON - Hidden on desktop
   ============================================= */
.navbar-close {
    display: none;
}

/* =============================================
   OVERLAY
   ============================================= */
.navbar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.navbar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Logo og kontrolrapport - hidden on desktop */
.navbar-logo {
    display: none;
}

.navbar-kontrolrapport {
    display: none;
}

/* =============================================
   DESKTOP MENU
   ============================================= */
.navbar-menu-container {
    position: relative;
}

.custom-navbar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    background: #fff;
}

.custom-navbar-menu li {
    position: relative;
    list-style: none;
    opacity: 1;
    transform: translateY(0);
}

.custom-navbar-menu ul {
    list-style: none;
}

.custom-navbar-menu ul li {
    list-style: none;
}

.custom-navbar-menu a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 16px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

/* Hover */
.custom-navbar-menu a:hover {
    color: #8C7131;
    border-bottom-color: #8C7131;
    transform: translateY(-1px);
}

/* Desktop dropdown */
.custom-navbar-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    min-width: 230px;
    border-radius: 0 0 8px 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 999;
    list-style: none;
    margin: 0;
    padding: 0;
}

.custom-navbar-menu li:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-navbar-menu .sub-menu li {
    width: 100%;
    list-style: none;
}

.custom-navbar-menu .sub-menu a {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
    border-bottom: none;
}

.custom-navbar-menu .sub-menu a:hover {
    background: #f8f9fa;
    padding-left: 25px;
    transform: none;
    color: #8C7131;
}

/* Third level desktop */
.custom-navbar-menu .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    border-radius: 8px;
}

/* Desktop chevron indicator */
.custom-navbar-menu .menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 8px;
    background-image: url('https://nordthy.udvikling360.dk/wp-content/uploads/2025/03/line-angle-down-icon.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
    vertical-align: middle;
}

.custom-navbar-menu .menu-item-has-children:hover > a::after {
    transform: rotate(180deg);
}

.custom-navbar-menu .sub-menu .menu-item-has-children > a::after {
    transform: rotate(-90deg);
    width: 8px;
    height: 8px;
}

.custom-navbar-menu .sub-menu .menu-item-has-children:hover > a::after {
    transform: rotate(-90deg);
}


/* =============================================================
   MOBILE / TABLET - Accordion Style (max 1024px)
   ============================================================= */
@media (max-width: 1024px) {

    /* Show hamburger */
    .navbar-toggle {
        display: flex;
        z-index: 1001;
    }

    /* ---- Slide-in panel from right (dark background) ---- */
    .navbar-menu-container {
        position: fixed;
        top: 0;
        right: -100%;
        width: 75%;
        max-width: 340px;
        height: 100vh;
        height: 100dvh;
        background: #FAF7EF;
        z-index: 1002;
        transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        overflow-y: auto;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
        -webkit-overflow-scrolling: touch;
    }

    .navbar-menu-container.active {
        right: 0;
    }

    /* Flex layout for logo top, menu middle, kontrolrapport bottom */
    .navbar-menu-container {
        display: flex;
        flex-direction: column;
    }

    /* ---- Close button (white) ---- */
    .navbar-close {
        display: flex;
        position: absolute;
        top: 18px;
        right: 18px;
        background: none;
        border: none;
        padding: 10px;
        cursor: pointer;
        z-index: 1004;
        width: 40px;
        height: 40px;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        border-radius: 50%;
        transition: background-color 0.3s ease;
    }

    .navbar-close:hover,
    .navbar-close:focus {
        background-color: rgba(0, 0, 0, 0.05);
        outline: none;
    }

    .close-line {
        width: 18px;
        height: 2px;
        background-color: #1a1a1a;
        position: absolute;
        border-radius: 1px;
        transition: all 0.3s ease;
    }

    .close-line:first-child {
        transform: rotate(45deg);
    }

    .close-line:last-child {
        transform: rotate(-45deg);
    }

    .navbar-close:hover .close-line {
        background-color: #8C7131;
    }

    /* ---- Menu list ---- */
    .custom-navbar-menu {
        flex-direction: column;
        align-items: stretch;
        padding: 0 0 20px;
        background: transparent;
    }

    .custom-navbar-menu li {
        width: 100%;
        border-bottom: none;
        opacity: 0;
        transform: translateX(30px);
        transition: all 0.4s ease;
    }

    .custom-navbar-menu li.submenu-open {
        transform: translateX(0) !important;
    }

    .custom-navbar-menu li:first-child {
        border-top: none;
    }

    /* Stagger animation */
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(1) {
        animation: slideInStagger 0.4s ease forwards 0.05s;
    }
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(2) {
        animation: slideInStagger 0.4s ease forwards 0.1s;
    }
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(3) {
        animation: slideInStagger 0.4s ease forwards 0.15s;
    }
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(4) {
        animation: slideInStagger 0.4s ease forwards 0.2s;
    }
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(5) {
        animation: slideInStagger 0.4s ease forwards 0.25s;
    }
    .navbar-menu-container.active .custom-navbar-menu li:nth-child(n+6) {
        animation: slideInStagger 0.4s ease forwards 0.3s;
    }

    @keyframes slideInStagger {
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* ---- Top-level links (accordion titles) ---- */
    .custom-navbar-menu > li > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 18px 24px;
        font-family: 'korolev', sans-serif;
        font-weight: 700;
        font-size: 14px;
        letter-spacing: 0.5px;
        text-transform: none;
        color: #1a1a1a;
        text-decoration: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        border-left: none;
        border-top: none;
        border-right: none;
        background: transparent;
        transition: color 0.3s ease;
    }

    .custom-navbar-menu > li > a:hover,
    .custom-navbar-menu > li > a:focus {
        color: #1a1a1a;
        background: transparent;
        transform: none;
        padding-left: 24px;
        border-left: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        outline: none;
        opacity: 1;
    }

    /* ---- Chevron for accordion ---- */
    .custom-navbar-menu .menu-item-has-children > a::after {
        content: '';
        display: block;
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        margin-left: auto;
        position: static;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        transform: rotate(0deg);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .custom-navbar-menu .menu-item-has-children.submenu-open > a::after {
        transform: rotate(180deg);
    }

    /* ---- Sub-menu (accordion panel) ---- */
    .custom-navbar-menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        border-radius: 0;
        background: transparent;
        min-width: unset;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        padding: 0;
        margin: 0;
    }

    .custom-navbar-menu .sub-menu.open {
        max-height: 800px;
        padding: 4px 0 8px;
        transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .custom-navbar-menu .sub-menu li {
        border-bottom: none;
        border-top: none;
        opacity: 1;
        transform: none;
        animation: none;
    }

    .custom-navbar-menu .sub-menu li:first-child {
        border-top: none;
    }

    /* Sub-menu links (Poppins) */
    .custom-navbar-menu .sub-menu a {
        display: block;
        padding: 8px 24px 8px 40px;
        font-family: 'Poppins', sans-serif;
        font-weight: 300;
        font-size: 13px;
        letter-spacing: 0;
        text-transform: none;
        color: rgba(0, 0, 0, 0.6);
        text-decoration: none;
        background: transparent;
        border-bottom: none;
        border-left: none;
        transition: color 0.2s ease;
    }

    .custom-navbar-menu .sub-menu a:hover,
    .custom-navbar-menu .sub-menu a:focus {
        color: #1a1a1a;
        background: transparent;
        padding-left: 40px;
        border-left: none;
        border-bottom: none;
        transform: none;
        outline: none;
    }

    /* ---- Sub-menu chevrons (2nd level) ---- */
    .custom-navbar-menu .sub-menu .menu-item-has-children > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .custom-navbar-menu .sub-menu .menu-item-has-children > a::after {
        width: 12px;
        height: 12px;
        right: auto;
        position: static;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.3)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    }

    .custom-navbar-menu .sub-menu .menu-item-has-children.submenu-open > a::after {
        transform: rotate(180deg);
    }

    /* ---- Third level ---- */
    .custom-navbar-menu .sub-menu .sub-menu {
        background: transparent;
    }

    .custom-navbar-menu .sub-menu .sub-menu a {
        padding-left: 56px;
        font-size: 12px;
        color: rgba(0, 0, 0, 0.45);
    }

    .custom-navbar-menu .sub-menu .sub-menu a:hover {
        padding-left: 56px;
        color: #1a1a1a;
    }

    /* ---- Logo i popup ---- */
    .navbar-logo {
        display: block;
        padding: 20px 24px 0;
        margin-bottom: 16px;
    }

    .navbar-logo img {
        height: 85px !important;
        width: auto !important;
        max-height: 85px !important;
    }

    /* ---- Kontrolrapport ---- */
    .navbar-kontrolrapport {
        display: block;
        padding: 16px 24px 24px;
        margin-top: 0;
    }

    .navbar-kontrolrapport img {
        max-width: 80px !important;
        height: auto !important;
        width: auto !important;
    }

    /* ---- Overlay active ---- */
    .navbar-overlay {
        display: block;
    }
}

/* ---- Tablet (max 768px) ---- */
@media (max-width: 768px) {
    .navbar-menu-container {
        width: 80%;
        max-width: 320px;
    }

    .custom-navbar-menu > li > a {
        font-size: 14px;
        padding: 16px 20px;
    }

    .custom-navbar-menu .sub-menu a {
        padding: 7px 20px 7px 36px;
        font-size: 13px;
    }

    .custom-navbar-menu .sub-menu .sub-menu a {
        padding-left: 50px;
        font-size: 12px;
    }
}

/* ---- Small mobile (max 480px) ---- */
@media (max-width: 480px) {
    .navbar-menu-container {
        width: 85%;
        max-width: 100%;
    }

    .custom-navbar-menu > li > a {
        font-size: 14px;
        padding: 15px 18px;
    }

    .custom-navbar-menu .sub-menu a {
        padding: 7px 18px 7px 32px;
        font-size: 13px;
    }

    .custom-navbar-menu .sub-menu .sub-menu a {
        padding-left: 46px;
    }
}