
/*
 * Topbath Custom Side Menu
 * Version: 1.2.0
 *
 * Responsive styling for the custom side menu.
 */

/* Opening button */

.topbath-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    background: #222222;
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.topbath-menu-trigger:hover,
.topbath-menu-trigger:focus {
    background: #444444;
    color: #ffffff;
}

.topbath-menu-trigger-icon {
    display: flex;
    width: 20px;
    flex-direction: column;
    gap: 5px;
}

.topbath-menu-trigger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.topbath-menu-trigger-label {
    display: inline-block;
}

/* Full-screen overlay */

.topbath-side-menu {
    position: fixed;
    inset: 0;
    z-index: 999999;
    visibility: hidden;
    pointer-events: none;
    direction: rtl;
}

.topbath-side-menu.is-open {
    visibility: visible;
    pointer-events: auto;
}

.topbath-side-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.topbath-side-menu.is-open .topbath-side-menu-backdrop {
    opacity: 1;
}

/* Side panel */

.topbath-side-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    width: 88px;
    height: 100%;
    height: 100dvh;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 0;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.16);
    transform: translateX(100%);
    transition: width 0.25s ease, transform 0.25s ease;
    overscroll-behavior: contain;
}

.topbath-side-menu.is-open .topbath-side-menu-panel {
    transform: translateX(0);
}

.topbath-side-menu.is-open .topbath-side-menu-panel.is-hover-expanded {
    width: 300px;
}

/* Close button */

.topbath-side-menu-close {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    width: 48px;
    min-width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    margin: 12px 20px 16px auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f2f2;
    color: #222222;
    font-family: Arial, sans-serif;
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
}

.topbath-side-menu-close:hover {
    background: #e5e5e5;
    color: #000000;
}

/* Menu content */

.topbath-side-menu-content {
    width: 100%;
    padding: 0 0 24px;
}

.topbath-menu-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.topbath-menu-item {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.topbath-menu-item-row {
    display: flex;
    width: 100%;
    min-height: 56px;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #eeeeee;
}

/* Desktop collapsed menu */

@media (min-width: 769px) {

    .topbath-menu-link {
        display: flex;
        width: 88px;
        min-width: 88px;
        height: 56px;
        flex: 0 0 88px;
        align-items: center;
        justify-content: center;
        gap: 0;
        margin: 0;
        padding: 4px 0;
        color: #222222;
        font-family: inherit;
        font-size: 15px;
        font-weight: 500;
        line-height: 1.4;
        text-align: right;
        text-decoration: none;
    }

    .topbath-menu-link:hover,
    .topbath-menu-link:focus {
        color: #111111;
        background: #f7f7f7;
        text-decoration: none;
    }

    .topbath-menu-item-icon {
        display: flex;
        width: 48px;
        min-width: 48px;
        height: 48px;
        flex: 0 0 48px;
        align-items: center;
        justify-content: center;
    }

    .topbath-menu-item-image {
        display: block;
        width: 48px;
        height: 48px;
        max-width: 100%;
        object-fit: contain;
    }

    .topbath-menu-label {
        display: none;
    }

    /* Hide submenu arrows while the menu is collapsed. */

    .topbath-submenu-toggle {
        display: none;
    }

    /* Expanded desktop menu */

    .topbath-side-menu-panel.is-hover-expanded .topbath-menu-link {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
        justify-content: flex-start;
        gap: 14px;
        padding: 10px 18px;
    }

    .topbath-side-menu-panel.is-hover-expanded .topbath-menu-label {
        display: block;
        min-width: 0;
        opacity: 1;
        visibility: visible;
        white-space: normal;
    }

    .topbath-side-menu-panel.is-hover-expanded .topbath-submenu-toggle {
        display: flex;
    }

    .topbath-menu-item-row:hover {
        background: #f7f7f7;
    }
}

/* Submenu toggle */

.topbath-submenu-toggle {
    display: flex;
    width: 42px;
    min-width: 42px;
    height: 48px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    margin: 0 4px 0 8px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #333333;
    cursor: pointer;
}

.topbath-submenu-toggle:hover {
    background: #eeeeee;
}

.topbath-submenu-arrow {
    display: block;
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.topbath-submenu-toggle[aria-expanded="true"] .topbath-submenu-arrow {
    transform: rotate(225deg);
}

/* Submenu */

.topbath-submenu-container {
    width: 100%;
    background: #f8f8f8;
}

.topbath-submenu-container[hidden] {
    display: none;
}

.topbath-menu-depth-1 .topbath-menu-item-row {
    min-height: 48px;
    border-bottom: 1px solid #eeeeee;
}

.topbath-menu-depth-1 .topbath-menu-link {
    padding: 9px 22px 9px 12px;
    font-size: 14px;
}

.topbath-menu-depth-2 .topbath-menu-link,
.topbath-menu-depth-3 .topbath-menu-link {
    padding-right: 34px;
    font-size: 13px;
}

.topbath-menu-depth-1 .topbath-menu-item-icon,
.topbath-menu-depth-1 .topbath-submenu-toggle {
    display: none;
}

/* Error message */

.topbath-menu-error {
    padding: 16px;
    color: #b00020;
    font-size: 14px;
    text-align: right;
}

/* Mobile */

@media (max-width: 768px) {

    .topbath-menu-trigger {
        min-height: 44px;
    }

    .topbath-side-menu-panel,
    .topbath-side-menu.is-open .topbath-side-menu-panel.is-hover-expanded {
        width: min(88vw, 360px);
        max-width: 100%;
    }

    .topbath-menu-item-row {
        min-height: 62px;
    }

    .topbath-menu-link {
        display: flex;
        min-width: 0;
        flex: 1 1 auto;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 14px;
        color: #222222;
        font-family: inherit;
        font-size: 15px;
        font-weight: 500;
        line-height: 1.4;
        text-align: right;
        text-decoration: none;
    }

    .topbath-menu-label {
        display: block;
        min-width: 0;
        opacity: 1;
        visibility: visible;
        white-space: normal;
    }

    .topbath-menu-item-icon {
        display: flex;
        width: 42px;
        min-width: 42px;
        height: 42px;
        flex: 0 0 42px;
        align-items: center;
        justify-content: center;
    }

    .topbath-menu-item-image {
        display: block;
        width: 42px;
        height: 42px;
        object-fit: contain;
    }

    .topbath-submenu-toggle {
        display: flex;
    }

    .topbath-menu-depth-1 .topbath-menu-link {
        padding-right: 24px;
    }

    .topbath-menu-depth-2 .topbath-menu-link,
    .topbath-menu-depth-3 .topbath-menu-link {
        padding-right: 38px;
    }
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {

    .topbath-side-menu-panel,
    .topbath-side-menu-backdrop,
    .topbath-menu-label,
    .topbath-submenu-arrow {
        transition: none;
    }
}
