/**
 * PFC Vertical Menu Widget Styles
 */

/* Force Elementor column to not constrain our widget */
.elementor-column:has(> .elementor-widget-wrap > .elementor-widget-pfc-vertical-menu.is-collapsed) {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
}

/* Remove padding from column and widget-wrap to allow true 0,0 positioning */
.elementor-column:has(> .elementor-widget-wrap > .elementor-widget-pfc-vertical-menu) {
    padding: 0 !important;
}

.elementor-column > .elementor-widget-wrap:has(> .elementor-widget-pfc-vertical-menu) {
    padding: 0 !important;
}

/* Force Elementor widget container to respect width settings */
.elementor-widget-pfc-vertical-menu {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    flex-basis: auto !important;
    width: auto !important;
}

/* Widget width controlled by JavaScript based on collapsed width setting */

.pfc-vmenu-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1000 !important;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Absolutely positioned to overlay content (unless sticky) */
}

/* Custom positioning - position relative to container, offsets set by controls */
.pfc-vmenu-wrapper.pfc-sticky {
    /* Keep position: absolute from base rule (relative to container) */
    z-index: 9999 !important;
    /* Override base positioning - MUST use !important to beat base rule */
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    /* Ensure wrapper can grow to fit content */
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    width: auto;  /* Let JavaScript control width */
}

/* Position values always applied as top/left via inline styles */

/* Nuclear option: remove ALL list styling from wrapper down */
.pfc-vmenu-wrapper ul,
.pfc-vmenu-wrapper li {
    list-style: none !important;
    list-style-type: none !important;
    list-style-image: none !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.pfc-vmenu-wrapper ul::before,
.pfc-vmenu-wrapper ul::after,
.pfc-vmenu-wrapper li::before,
.pfc-vmenu-wrapper li::after,
.pfc-vmenu-wrapper li::marker {
    display: none !important;
    content: none !important;
}

/* Hamburger Toggle (hidden on desktop) */
.pfc-vmenu-toggle {
    display: none !important; /* Force hide on desktop */
    flex-direction: column;
    justify-content: space-between;
    width: 40px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.pfc-vmenu-toggle:hover {
    opacity: 0.8;
}

.pfc-vmenu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Hamburger animation when active */
.pfc-vmenu-toggle.is-active span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}

.pfc-vmenu-toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.pfc-vmenu-toggle.is-active span:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
}

/* Menu Container */
.pfc-vmenu-container {
    display: block;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    transition: width 0.3s ease;
    overflow: hidden !important; /* Clip menu items when container is narrow */
    position: relative;
    z-index: 999;
    /* Width controlled by Elementor - set to 100% of wrapper */
    width: 100%;
}

/* Collapse/Expand Toggle Button (above menu, always visible) */
.pfc-vmenu-collapse-toggle,
button.pfc-vmenu-collapse-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    min-width: fit-content !important; /* Ensure button is never smaller than content */
    min-height: 32px !important;
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
    background-image: none !important;
    border: 1px solid #ddd !important;
    border-style: solid !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    padding: 6px 12px !important;
    margin: 0 0 1px 0 !important;
    color: #333 !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    position: relative !important;
    z-index: 1000 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important; /* Prevent button from shrinking */
}

.pfc-vmenu-collapse-toggle:hover {
    background: #e0e0e0 !important;
}

.pfc-vmenu-collapse-toggle .pfc-collapse-icon {
    display: block;
}

.pfc-vmenu-collapse-toggle .pfc-expand-icon {
    display: none;
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-collapse-toggle .pfc-collapse-icon {
    display: none;
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-collapse-toggle .pfc-expand-icon {
    display: block;
}

/* Widget container always reserves collapsed width in flexbox */
.elementor-widget-pfc-vertical-menu {
    position: relative !important;
    overflow: visible !important;
}

/* Remove any padding/margin from widget and its Elementor wrapper */
.elementor-widget-pfc-vertical-menu,
.elementor-widget-pfc-vertical-menu > .elementor-widget-container {
    padding: 0 !important;
    margin: 0 !important;
}

/* Wrapper is always absolutely positioned to overlay (see base .pfc-vmenu-wrapper rule above) */

/* Collapsed state */
.pfc-vmenu-wrapper.is-collapsed {
    overflow: visible !important; /* Allow button to extend beyond wrapper width */
    /* No min-width - let user control collapsed width completely */
    /* position is always absolute from base rule */
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-text {
    white-space: nowrap !important;
    overflow: visible !important; /* Changed from hidden to visible */
    text-overflow: ellipsis !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: inherit !important;
    min-width: 30px !important;
    width: auto !important; /* Let text take natural width */
    flex: 1 1 auto !important; /* Allow text to grow and take available space */
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-arrow-btn {
    display: none;
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-submenu {
    display: none !important;
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-item > a {
    justify-content: flex-start;
    padding: 12px 8px;
    flex-wrap: nowrap !important; /* Prevent wrapping in collapsed state */
}

.pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-link {
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    flex-wrap: nowrap !important; /* Prevent wrapping in collapsed state */
}

.pfc-vmenu {
    list-style: none !important;
    margin: 0 !important;
    /* padding controlled by Elementor "Container Padding" control */
}

.pfc-vmenu ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pfc-vmenu li,
.pfc-vmenu-item,
.pfc-vmenu-submenu li {
    list-style: none !important;
    list-style-type: none !important;
    list-style-image: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    /* margin-bottom controlled by Elementor */
    padding: 0 !important;
}

.pfc-vmenu li::before,
.pfc-vmenu li::after,
.pfc-vmenu li::marker,
.pfc-vmenu-item::before,
.pfc-vmenu-item::after,
.pfc-vmenu-submenu li::before,
.pfc-vmenu-submenu li::after {
    display: none !important;
    content: none !important;
    list-style: none !important;
}

/* Top Level Items */
.pfc-vmenu-item {
    position: relative;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    /* margin-bottom controlled by Elementor "Vertical Spacing" control */
    padding: 0 !important;
    list-style: none !important;
}

.pfc-vmenu-item::before {
    display: none !important;
    content: none !important;
}

.pfc-vmenu-item > a {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; /* Allow text to wrap to multiple lines */
    text-decoration: none;
    padding: 12px 20px;
    color: #333;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.pfc-vmenu-link {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; /* Allow text to wrap */
    width: 100%;
}

.pfc-vmenu-text {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink below content width for wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pfc-vmenu-item > a:hover {
    background-color: #f5f5f5;
}

/* Arrow button for expandable items */
.pfc-vmenu-arrow-btn,
button.pfc-vmenu-arrow-btn {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 0 none !important;
    border-style: none !important;
    padding: 4px 8px !important;
    margin-left: 8px !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease !important;
    border-radius: 3px !important;
    color: inherit !important;
    outline: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    min-width: auto !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
}

.pfc-vmenu-arrow-btn:hover {
    background: rgba(0,0,0,0.05) !important;
}

.pfc-vmenu-arrow-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.pfc-vmenu-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform 0.3s ease;
}

/* Rotate arrow when parent item is expanded (works at any nesting level) */
.pfc-vmenu-item.is-expanded > a > .pfc-vmenu-arrow-btn > .pfc-vmenu-arrow {
    transform: rotate(180deg);
}

/* Sub-menu */
.pfc-vmenu-submenu {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #fafafa;
    display: none;
}

/* Show submenu when parent is expanded */
.pfc-vmenu-item.is-expanded > .pfc-vmenu-submenu {
    display: block;
}

.pfc-vmenu-submenu li {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    /* margin-bottom can be controlled if needed */
    padding: 0 !important;
    list-style: none !important;
}

.pfc-vmenu-submenu li::before {
    display: none !important;
    content: none !important;
}

/* Generic submenu link styles (all levels) */
.pfc-vmenu-submenu a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.pfc-vmenu-submenu a:hover {
    background-color: #eee;
    color: #0073aa;
}

/* First level submenu padding controlled by Elementor "Submenu Padding" */
/* Nested levels controlled by "Submenu Padding" LEFT + "Nested Indent" × level */

/* Active/Current menu item styling */
.pfc-vmenu-item.current-menu-item > a,
.pfc-vmenu-item.current-menu-ancestor > a,
.pfc-vmenu-submenu .current-menu-item > a {
    font-weight: 600;
    color: #0073aa;
}

/* Mobile/Responsive Styles */
@media (max-width: 768px) {
    /* CRITICAL: Completely negate .is-collapsed class on mobile */
    /* The PHP adds this class on page load, but it should have NO EFFECT on mobile */
    /* Wrapper should ALWAYS use expanded width on mobile, never collapsed width */
    .elementor-widget-pfc-vertical-menu.is-collapsed,
    .pfc-vmenu-wrapper.is-collapsed {
        /* Reset any collapsed-specific styles */
        overflow: visible !important;
    }

    /* Force wrapper to NOT shrink on mobile even with is-collapsed class */
    /* JavaScript sets data-expanded-width, this ensures CSS doesn't override it */
    .pfc-vmenu-wrapper.is-collapsed {
        min-width: inherit !important; /* Don't override min-width from non-collapsed state */
    }

    /* Hide the collapse/expand toggle on mobile - high specificity to override */
    .pfc-vmenu-collapse-toggle,
    button.pfc-vmenu-collapse-toggle,
    .pfc-vmenu-wrapper .pfc-vmenu-collapse-toggle {
        display: none !important;
        visibility: hidden !important;
    }

    /* CRITICAL: Force override any cached Elementor CSS from old selectors */
    /* This targets EVERY possible selector combination Elementor might have generated */
    .elementor-widget-pfc-vertical-menu,
    .elementor-widget-pfc-vertical-menu.is-collapsed,
    .elementor-widget-pfc-vertical-menu:not(.is-collapsed),
    .elementor-widget-pfc-vertical-menu:has(.pfc-vmenu-wrapper),
    .elementor-widget-pfc-vertical-menu:has(.pfc-vmenu-wrapper.is-collapsed),
    .elementor-widget-pfc-vertical-menu:has(.pfc-vmenu-wrapper:not(.is-collapsed)) {
        width: 50px !important;
        min-width: 50px !important;
        max-width: 50px !important;
        flex: 0 0 50px !important;
        flex-basis: 50px !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        overflow: visible !important;
    }

    /* Wrapper stays absolutely positioned to overlay on mobile */
    /* JavaScript adds 10px offset for touch devices to prevent going off-screen */
    .pfc-vmenu-wrapper,
    .pfc-vmenu-wrapper:not(.is-collapsed),
    .pfc-vmenu-wrapper.is-collapsed {
        position: absolute !important;
        min-width: 50px !important;
        max-width: none !important;
    }

    /* Show hamburger menu */
    .pfc-vmenu-toggle {
        display: flex !important;
        position: relative;
        z-index: 1001;
    }

    /* Menu container - hidden by default, shown when .is-open */
    /* Absolutely positioned relative to wrapper, overlays beyond wrapper width */
    /* Width is 100% of wrapper (wrapper width set by JavaScript from expanded_width) */
    .pfc-vmenu-container,
    .elementor-widget-pfc-vertical-menu:not(.is-collapsed) .pfc-vmenu-container,
    .elementor-widget-pfc-vertical-menu .pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-container {
        display: none;
        position: absolute;
        top: 45px;
        left: 0;
        width: 100% !important;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* Show menu when hamburger is clicked (highest specificity to override all display:none rules) */
    .pfc-vmenu-container.is-open,
    .pfc-vmenu-wrapper .pfc-vmenu-container.is-open,
    .elementor-widget-pfc-vertical-menu .pfc-vmenu-container.is-open,
    .elementor-widget-pfc-vertical-menu .pfc-vmenu-wrapper .pfc-vmenu-container.is-open,
    .elementor-widget-pfc-vertical-menu:not(.is-collapsed) .pfc-vmenu-container.is-open,
    .elementor-widget-pfc-vertical-menu .pfc-vmenu-wrapper.is-collapsed .pfc-vmenu-container.is-open {
        display: block !important;
    }

    /* Force wrapper to ignore collapsed class on mobile */
    .pfc-vmenu-wrapper.is-collapsed {
        overflow: visible !important;
    }

    /* Mobile: Submenus work same as desktop - click arrows to expand */
    /* Arrow buttons visible so users can tap to expand submenus */

    /* Allow menu text to wrap on mobile */
    .pfc-vmenu-text {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .pfc-vmenu-link {
        white-space: normal !important;
    }

    /* CRITICAL: Force parent columns to not reserve space on mobile */
    /* Override any cached Elementor CSS or inline styles */
    .elementor-column:has(> .elementor-widget-wrap > .elementor-widget-pfc-vertical-menu),
    .e-con:has(> .elementor-widget-pfc-vertical-menu),
    .e-flexbox:has(> .elementor-widget-pfc-vertical-menu) {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 0 0 auto !important;
        flex-basis: auto !important;
        flex-grow: 0 !important;
        flex-shrink: 1 !important;
    }
}

/* Elementor Editor Mode - always show menu */
.elementor-editor-active .pfc-vmenu-container {
    display: block !important;
}

/* Smooth transitions for all interactive elements */
.pfc-vmenu-item,
.pfc-vmenu-submenu {
    transition: all 0.3s ease;
}

/* Accessibility */
.pfc-vmenu-item > a:focus,
.pfc-vmenu-submenu a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading state */
.pfc-vmenu-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* ============================================
   STICKY POSITIONING
   ============================================ */

/* Sticky positioning keeps menu in viewport while scrolling */
/* Position relative to parent container, not entire viewport */
/* Widget container maintains normal flow for sticky to work */
.elementor-widget-pfc-vertical-menu:has(.pfc-vmenu-wrapper.pfc-sticky) {
    position: relative !important;
}
