.header {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    padding: 24px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

@media (min-width: 901px) {
    .logo {
        margin-left: -55px;
    }
}

.logo img {
    display: block;
    height: 56px;
    width: auto;
    max-width: 100%;
}

/* Navigation */
#nav ul {
    padding: 0;
}

#nav ul,
#nav li {
    margin: 0;
    list-style: none;
}

.header-menu {
    display: flex;
    align-items: center;
    gap: 48px;
}

.header-menu a {
    text-decoration: none;
    color: #1a1a1a;
    font-size: 17px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s ease;
}

.header-menu a:hover {
    color: #2d4cff;
}

/* ---------- Dropdown (desktop) ---------- */
.menu-item-has-children {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.menu-item-has-children {
    display: inline-flex;
}

.menu-item-has-children > a::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-top: -5px;
    margin-left: 2px;
    transition: transform 0.2s ease;
    display: inline-block;
}

.sub-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 200px;
    background-color: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    margin-top: 6px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, margin-top 0.18s ease;
    z-index: 1001;
}

/* Open the dropdown on hover, focus-within (keyboard), or explicit .open class */
.menu-item-has-children:hover > .sub-menu,
.menu-item-has-children:focus-within > .sub-menu,
.menu-item-has-children.open > .sub-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    margin-top: 0;
}

/* Flip the arrow when the menu is open */
.menu-item-has-children:hover > a:after,
.menu-item-has-children:focus-within > a:after,
.menu-item-has-children.open > a:after {
    transform: rotate(225deg);
    margin-top: 2px;
}

.sub-menu a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.sub-menu a:hover {
    background-color: #f5f7fd;
    color: #2d4cff;
}

/* Burger button - hidden by default */
.burger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
    position: relative;
    z-index: 20;
}

.burger-btn span {
    position: absolute;
    left: 4px;
    width: 24px;
    height: 2.5px;
    background-color: #1a1a1a;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease, top 0.25s ease;
}

.burger-btn span:nth-child(1) { top: 8px; }
.burger-btn span:nth-child(2) { top: 15px; }
.burger-btn span:nth-child(3) { top: 22px; }

/* Burger active state (X) */
.burger-btn.active span:nth-child(1) {
    top: 15px;
    transform: rotate(45deg);
}
.burger-btn.active span:nth-child(2) {
    opacity: 0;
}
.burger-btn.active span:nth-child(3) {
    top: 15px;
    transform: rotate(-45deg);
}

/* Tablet */
@media (max-width: 900px) {
    .header {
        padding: 20px 32px;
    }

    .header-menu {
        gap: 32px;
    }

    .header-menu a {
        font-size: 16px;
    }
}

/* Mobile - burger appears, nav becomes a vertical stack */
@media (max-width: 640px) {
    .header {
        padding: 14px 20px;
    }

    .logo img {
        height: 40px;
    }

    /* Show burger */
    .burger-btn {
        display: block;
    }

    /* Hide nav by default on mobile; reveal when .open is toggled */
    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #fff;
        padding: 0;
        border-top: 1px solid #f0f0f0;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        z-index: 999;
    }

    .header-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .nav.open {
        max-height: 600px;
    }

    .header-menu > li {
        border-bottom: 1px solid #f0f0f0;
    }

    .header-menu > li > a {
        padding: 16px 24px;
        font-size: 16px;
    }

    .header-menu > li > a:last-child {
        border-bottom: none;
    }

    /* Reviews item on mobile: link on the left, arrow button on the right */
    .menu-item-has-children {
        display: flex;
        align-items: stretch;
        flex-wrap: wrap;
        justify-content: space-between;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
    }

    .menu-item-has-children > a {
        flex: 1 1 auto;
        padding: 16px 24px;
        font-size: 16px;
        order: 1;
    }

    /* Hide the inline arrow inside the Reviews link on mobile —
       the separate toggle button below handles expansion */
    .menu-item-has-children > a::after {
        content: none;
    }

    /* Show the mobile-only submenu toggle button */
    .menu-item-has-children::after {
        content: "\f347";
        line-height: 1;
        order: 2;
        padding: 0 20px;
        flex: 0 0 auto;
        font-weight: 400;
        font-family: dashicons;
        font-style: normal;
        text-decoration: inherit;
        text-transform: none;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        width: 36px;
        font-size: 20px;
        vertical-align: top;
        text-align: center;
        transition: .15s ease-in;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-left: 1px solid #f0f0f0;
        color: #1a1a1a;
        pointer-events: none;
    }

    .menu-item-has-children.open::after{
        scale: 1 -1;
    }

    /* Mobile dropdown = accordion submenu below the Reviews row */
    .sub-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        min-width: 0;
        order: 3;
        width: 100%;
        flex-basis: 100%;
        background-color: #f9fafc;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        margin-top: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    /* Disable hover-triggered open on mobile to avoid sticky menus on touch */
    .menu-item-has-children:hover > .sub-menu,
    .menu-item-has-children:focus-within > .sub-menu {
        max-height: 0;
    }

    .menu-item-has-children.open > .sub-menu {
        max-height: 400px;
    }

    /* On mobile we do NOT want the desktop arrow rotation on hover/focus */
    .menu-item-has-children:hover > .nav-link .dropdown-arrow,
    .menu-item-has-children:focus-within > .nav-link .dropdown-arrow {
        transform: rotate(45deg);
        margin-top: -4px;
    }

    .sub-menu a {
        padding: 14px 40px;
        font-size: 15px;
        border-bottom: 1px solid #eef0f4;
        white-space: normal;
    }

    .sub-menu a:last-child {
        border-bottom: none;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .header {
        padding: 12px 16px;
    }

    .logo img {
        height: 34px;
    }
}
