/**
 * Tree Menu for Elementor — Styles
 *
 * @package Tree_Menu_Elementor
 * @version 1.4.0
 */

/* ── Container ──────────────────────────────────────────────────────── */
.tree-menu-container {
    display: block;
    width: 100%;
    position: relative;
}

/* ── Base list reset ────────────────────────────────────────────────── */
.tree-menu-list,
.tree-menu-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-menu-list {
    display: flex;
    flex-direction: column;
}

/* ── Menu items ─────────────────────────────────────────────────────── */
/* flex-wrap: wrap so link+arrow stay on row 1, sub-menu wraps to row 2 */
.tree-menu-item {
    position: relative;
    list-style: none;
    margin-bottom: 2px;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

/* ── Links ──────────────────────────────────────────────────────────── */
.tree-menu-list a {
    display: flex;
    align-items: center;
    text-decoration: none;
    padding: 8px 12px;
    flex: 1 1 0%;
    min-width: 0;
    box-sizing: border-box;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
    color: #333333;
    overflow: hidden;
}

/* Link text — truncate long titles with ellipsis, always leave room for arrow */
.tree-menu-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 0%;
}

.tree-menu-list a:hover {
    text-decoration: none;
    background-color: rgba(0, 0, 0, 0.05);
}

.tree-menu-list a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ── Active / current item ──────────────────────────────────────────── */
.tree-menu-list .current-menu-item > a,
.tree-menu-list .current-menu-ancestor > a {
    font-weight: 500;
    background-color: rgba(0, 115, 170, 0.08);
}

/* ── Sub-menus — must take full width on new row ────────────────────── */
.tree-menu-list .sub-menu {
    position: relative;
    list-style: none;
    margin: 0;
    padding-left: 20px;
    flex-basis: 100%;
    width: 100%;
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease-out;
}

/* Collapsed sub-menu */
.has-submenu.collapsed > .sub-menu {
    max-height: 0 !important;
    overflow: hidden;
}

/* ── Connector lines ────────────────────────────────────────────────── */
.tree-menu-list .sub-menu .tree-menu-item::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px solid #cccccc;
}

.tree-menu-list .sub-menu .tree-menu-item::after {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 10px;
    height: 0;
    border-top: 1px solid #cccccc;
    transform: translateY(-50%);
}

.tree-menu-list .sub-menu .tree-menu-item:last-child::before {
    height: 50%;
    bottom: auto;
}

/* ── No-connector modifier ──────────────────────────────────────────── */
.tree-menu-list.no-connector .sub-menu .tree-menu-item::before,
.tree-menu-list.no-connector .sub-menu .tree-menu-item::after {
    display: none;
}

/* ── Depth styling ──────────────────────────────────────────────────── */
.tree-menu-list .depth-0 > a {
    font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════
   SUBMENU ARROW — Standalone button outside <a>
   ══════════════════════════════════════════════════════════════════════ */

.submenu-arrow {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    flex: 0 0 36px;
    height: auto;
    border: none;
    border-radius: 0 4px 4px 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    transition: transform 0.3s ease, background-color 0.2s ease;
}

.submenu-arrow:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.submenu-arrow:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.submenu-arrow svg {
    width: 12px;
    height: 8px;
    transition: transform 0.3s ease;
}

/* PC Collapse enabled: show arrow */
.tree-menu-container[data-enable-collapse="true"] .has-submenu > .submenu-arrow {
    display: flex;
}

/* Collapsed state — arrow points right */
.has-submenu.collapsed > .submenu-arrow svg {
    transform: rotate(-90deg);
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE HAMBURGER MENU
   ══════════════════════════════════════════════════════════════════════ */

.tree-menu-hamburger {
    display: none;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    background-color: #333333;
    color: #ffffff;
}

.tree-menu-hamburger:hover {
    background-color: #444444;
}

.tree-menu-hamburger:active {
    transform: scale(0.98);
}

.tree-menu-hamburger:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.tree-menu-hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 20px;
    height: 14px;
    flex-shrink: 0;
}

.tree-menu-hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 1px;
}

/* Desktop menu wrapper */
.tree-menu-desktop {
    display: block;
}

/* Mobile Panel */
.tree-menu-mobile-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background-color: #ffffff;
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.tree-menu-mobile-panel.active {
    transform: translateX(0);
}

/* Mobile Panel Header */
.tree-menu-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    min-height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid #eeeeee;
    background-color: #f8f8f8;
    position: sticky;
    top: 0;
    z-index: 1;
    box-sizing: border-box;
}

.tree-menu-mobile-title {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 0%;
    min-width: 0;
}

.tree-menu-mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #000000;
    cursor: pointer;
    transition: color 0.2s ease;
}

.tree-menu-mobile-close:hover {
    color: #000000;
}

.tree-menu-mobile-close svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Mobile Menu List */
.tree-menu-mobile-list {
    padding: 12px 0;
}

.tree-menu-mobile-list .tree-menu-list {
    padding: 0;
}

.tree-menu-mobile-list .sub-menu {
    padding-left: 20px;
}

.tree-menu-mobile-list .tree-menu-item {
    margin-bottom: 0;
}

.tree-menu-mobile-list a {
    padding: 12px 20px;
}

/* Mobile: always show arrows in panel */
.tree-menu-mobile-list .has-submenu > .submenu-arrow {
    display: flex;
}

.tree-menu-mobile-list .has-submenu.collapsed > .sub-menu {
    max-height: 0 !important;
    overflow: hidden;
}

.tree-menu-mobile-list .has-submenu.collapsed > .submenu-arrow svg {
    transform: rotate(-90deg);
}

/* Mobile overlay */
.tree-menu-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tree-menu-mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Body lock */
body.tree-menu-body-lock {
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile breakpoint (768px)
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .tree-menu-container[data-has-mobile-menu="true"] .tree-menu-hamburger {
        display: flex;
    }

    .tree-menu-container[data-has-mobile-menu="true"] .tree-menu-desktop {
        display: none;
    }

    .tree-menu-mobile-list .sub-menu {
        padding-left: 15px !important;
    }

    .tree-menu-mobile-list a {
        padding: 10px 14px;
    }

    .tree-menu-mobile-list .sub-menu .tree-menu-item::before,
    .tree-menu-mobile-list .sub-menu .tree-menu-item::after {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   EMPTY / ERROR STATES
   ══════════════════════════════════════════════════════════════════════ */

.tree-menu-empty {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
    background-color: #f5f5f5;
    border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .submenu-arrow svg,
    .tree-menu-mobile-panel,
    .tree-menu-mobile-overlay,
    .tree-menu-list .sub-menu {
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .submenu-arrow {
        opacity: 1;
    }
    .tree-menu-hamburger {
        border: 2px solid currentColor;
    }
}
