.has-submenu {
    position: relative;
}

.submenu {
    display: none !important;
    position: absolute;
    top: 40px;
    left: 0;
    transform: translateX(-10px);
    background-color: var(--bg-secondary);
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
    list-style: none;
    flex-direction: column;
    gap: 12px;
    min-width: 220px;
    z-index: 999;
}

.submenu.open {
    display: flex !important;
}

.submenu a {
    font-size: 14px;
    font-weight: 400;
    color: var(--txt-main);
}

.submenu a:hover {
    color: var(--action);
}

.menu-links a.is-active {
    color: var(--action);
    font-weight: 600;
}

/* Responsive: tablet & mobile - keep logo and hamburger on one line,
   show links below when opened. */
@media (max-width: 1024px) {
    .menu {
        display: flex;
        flex-wrap: nowrap;
        row-gap: 10px;
        border-radius: 24px;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 8px 12px;
    }

    /* Logo left, hamburger pushed to the right */
    .menu .logo { order: 1; }
    .menu-toggle { order: 2; margin-left: auto; }

    /* Menu links are hidden by default and shown full-width below when opened */
    .menu-links { display: none; order: 3; width: 100%; }
    .menu-links ul {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 0;
        margin: 0;
    }
    .menu-links li { width: 100%; }
    .menu-links a { display: block; padding: 10px 12px; }

    /* Make submenus flow inside the block (not absolute) on smaller screens */
    .has-submenu { position: static; }
    .has-submenu .submenu {
        display: none !important;
        position: static;
        transform: none;
        top: auto;
        left: auto;
        background-color: transparent;
        padding: 0 12px;
        border-radius: 0;
        box-shadow: none;
        min-width: 100%;
        width: 100%;
        box-sizing: border-box;
        z-index: auto;
        flex-direction: column;
        gap: 8px;
    }
    .has-submenu .submenu.open { display: block !important; }

    /* Align submenu items to the left edge of the menu on small screens */
    .has-submenu .submenu a { padding-left: 0; }

    /* When menu is opened, show links below the header */
    .menu.open .menu-links { display: block; margin-top: 8px; }

    /* Hide the primary action when the menu is opened so submenus are visible */
    .menu.open .btn-action { display: none !important; }

    /* Show the action button inside the menu, centered on tablet/mobile */
    .menu .btn-action { display: block !important; margin: 12px auto; }
}

/* Hamburger button: hidden on desktop, visible from tablet down */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 8px;
    margin-left: 8px;
    cursor: pointer;
}
.menu-toggle .hamburger {
    display: inline-block;
    width: 22px;
    height: 16px;
    position: relative;
}
.menu-toggle .hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--txt-main);
    border-radius: 2px;
    position: absolute;
    left: 0;
    transition: transform 200ms ease, top 200ms ease, opacity 200ms ease;
}
.menu-toggle .hamburger span:nth-child(1) { top: 0; }
.menu-toggle .hamburger span:nth-child(2) { top: 7px; }
.menu-toggle .hamburger span:nth-child(3) { top: 14px; }

/* Show hamburger on <=1024px and control menu visibility */
@media (max-width: 1024px) {
    .menu-toggle { display: inline-flex; align-items: center; }
    /* Hide menu links by default on small screens */
    .menu-links { display: none; }
    .menu.open .menu-links { display: block; }

    /* Animate hamburger to X when open */
    .menu.open .menu-toggle .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .menu.open .menu-toggle .hamburger span:nth-child(2) { opacity: 0; }
    .menu.open .menu-toggle .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* Responsive: phones - small tweaks */
@media (max-width: 480px) {
    .logo { height: 42px; }
    .menu { gap: 6px; }
    .menu-links ul { gap: 8px; }
    .menu-links a { font-size: 13px; }
    .btn-action { padding: 8px 14px; font-size: 13px; white-space: nowrap; }
}
