/**
 * GI Main Menu Styles
 * 
 * 3-level dropdown navigation matching Grabit theme design
 * Desktop: hover + click
 * Mobile: off-canvas panel with accordion
 * No jQuery dependency
 */

/* ===================================
   DESKTOP NAVIGATION
   =================================== */

.gi-nav {
    position: relative;
}

.gi-menu.level-1 {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.gi-menu.level-1 > .menu-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0 20px;
    transition: all 0.3s ease-in-out;
}

@media (max-width: 1199px) {
    .gi-menu.level-1 > .menu-item {
        margin: 0 15px;
    }
}

.gi-menu.level-1 > .menu-item > .menu-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    line-height: 60px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    color: #4b5966;
    transition: all 0.3s ease 0s;
    text-transform: capitalize;
}

/* Underline animation on hover */
.gi-menu.level-1 > .menu-item > .menu-link::before {
    content: "";
    position: absolute;
    top: auto;
    bottom: 0;
    width: 0;
    height: 2px;
    margin: 0 auto;
    background: transparent;
    left: 0;
    right: auto;
    transition: all 0.3s ease 0s;
}

.gi-menu.level-1 > .menu-item:hover > .menu-link::before,
.gi-menu.level-1 > .menu-item.active > .menu-link::before,
.gi-menu.level-1 > .menu-item.current-menu-item > .menu-link::before {
    background: #5caf90;
    width: 100%;
}

.gi-menu.level-1 > .menu-item > .menu-link:hover,
.gi-menu.level-1 > .menu-item.active > .menu-link,
.gi-menu.level-1 > .menu-item.current-menu-item > .menu-link {
    color: #5caf90;
}

/* ===================================
   SUBMENU TOGGLE BUTTON
   =================================== */

.gi-submenu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 8px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    color: inherit;
    vertical-align: middle;
    flex-shrink: 0;
}

.gi-submenu-toggle:hover,
.menu-link:hover .gi-submenu-toggle {
    color: #5caf90;
}

.gi-submenu-toggle i {
    transition: transform 0.3s ease-in-out;
    font-size: 12px;
    line-height: 1;
    pointer-events: none;
}

.gi-submenu-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.gi-submenu-toggle:focus {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
    border-radius: 3px;
}

/* Prevent link click when clicking toggle */
.menu-link {
    position: relative;
}

.menu-link .gi-submenu-toggle {
    position: relative;
    z-index: 2;
}

/* ===================================
   LEVEL 2 DROPDOWN (under Level 1)
   =================================== */

.gi-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    margin-top: 30px;
    padding: 15px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 5px;
    box-shadow: 2px 2px 15px 0 rgba(0, 0, 0, 0.07);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    z-index: 1000;
}

.gi-submenu[aria-hidden="false"] {
    margin-top: 0;
    opacity: 1;
    visibility: visible;
}

/* Hover to open (desktop only) */
@media (min-width: 992px) {
    .menu-item.level-1:hover > .gi-submenu.level-2 {
        margin-top: 0;
        opacity: 1;
        visibility: visible;
    }
    
    .menu-item.level-2:hover > .gi-submenu.level-3 {
        margin-top: -5px;
        opacity: 1;
        visibility: visible;
    }
}

.gi-submenu .menu-item {
    position: relative;
    display: block;
}

.gi-submenu .menu-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 400;
    color: #777;
    text-decoration: none;
    transition: all 0.3s ease-in-out;
    text-transform: capitalize;
}

.gi-submenu .menu-link:hover,
.gi-submenu .menu-item.active > .menu-link,
.gi-submenu .menu-item.current-menu-item > .menu-link {
    color: #5caf90;
    padding-left: 25px;
}

.gi-submenu .menu-link:focus {
    outline: 2px solid #5caf90;
    outline-offset: -2px;
}

.gi-submenu .gi-submenu-toggle {
    margin-left: auto;
    width: 16px;
    height: 16px;
}

/* ===================================
   LEVEL 3 DROPDOWN (flyout right)
   =================================== */

.gi-submenu.level-3 {
    top: 0;
    left: 100% !important;
    margin-top: 30px;
    margin-left: 0;
}

.gi-submenu.level-3[aria-hidden="false"] {
    margin-top: -5px;
}

/* Hover state for Level 3 */
.menu-item.level-2:hover > .gi-submenu.level-3 {
    margin-top: -5px !important;
}

/* Smart flip if near viewport edge */
.menu-item.level-2.flip-submenu > .gi-submenu.level-3 {
    left: auto !important;
    right: 100% !important;
    margin-left: 0;
    margin-right: 0;
}

/* ===================================
   MOBILE TOGGLE BUTTON
   =================================== */

.gi-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #eee;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    color: #4b5966;
    font-size: 14px;
    font-weight: 500;
    gap: 8px;
}

.gi-mobile-toggle:hover {
    background: #f8f8f8;
    border-color: #5caf90;
    color: #5caf90;
}

.gi-mobile-toggle i {
    font-size: 18px;
}

@media (max-width: 991px) {
    .gi-mobile-toggle {
        display: inline-flex;
    }
    
    .gi-nav {
        display: none !important;
    }
    
    #gi-main-menu-desk .gi-main-menu {
        display: flex;
        justify-content: flex-end;
        padding-right: 12px;
    }
}

/* ===================================
   MOBILE OFF-CANVAS PANEL
   =================================== */

.gi-mobile-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 340px;
    max-width: 88vw;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: all 0.3s ease-in-out;
    box-shadow: 2px 2px 15px 0 rgba(0, 0, 0, 0.15);
    padding: 15px 20px 20px;
}

@media (max-width: 480px) {
    .gi-mobile-panel {
        width: 300px;
    }
}

.gi-mobile-panel[hidden] {
    display: block !important;
    transform: translateX(-100%);
}

.gi-mobile-panel:not([hidden]) {
    transform: translateX(0);
}

/* Mobile panel header */
.gi-mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.gi-mobile-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #4b5966;
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

.gi-mobile-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 30px;
    line-height: 1;
    color: #777;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

.gi-mobile-panel-close:hover {
    color: #e04848;
    transform: rotate(90deg);
}

/* Mobile menu content */
.gi-mobile-panel-content {
    padding: 0;
}

.gi-mobile-panel .gi-menu {
    flex-direction: column;
}

.gi-mobile-panel .gi-menu.level-1 {
    padding: 0;
    margin: 0;
}

.gi-mobile-panel .menu-item.level-1 {
    display: block;
    width: 100%;
    margin: 0 0 12px 0;
    border-bottom: none;
}

.gi-mobile-panel .menu-item.level-1 > .menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    line-height: 1.4;
    color: #777;
    border: 1px solid #eee;
    border-radius: 5px;
    background: #fff;
    font-size: 15px;
    font-weight: 500;
    text-transform: capitalize;
    transition: all 0.3s ease-in-out;
}

.gi-mobile-panel .menu-item.level-1 > .menu-link::before {
    display: none;
}

.gi-mobile-panel .menu-item.level-1 > .menu-link:hover,
.gi-mobile-panel .menu-item.level-1.current-menu-item > .menu-link {
    color: #5caf90;
    border-color: #5caf90;
}

.gi-mobile-panel .menu-item.level-1 .gi-submenu-toggle {
    width: 24px;
    height: 24px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Level 2 submenu in mobile */
.gi-mobile-panel .gi-submenu.level-2 {
    position: static;
    width: 100%;
    min-width: auto;
    margin: 0;
    padding: 0;
    opacity: 1;
    visibility: visible;
    border: none;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.gi-mobile-panel .gi-submenu.level-2[aria-hidden="false"] {
    max-height: 1000px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.gi-mobile-panel .gi-submenu.level-2 .menu-item {
    margin: 0;
}

.gi-mobile-panel .gi-submenu.level-2 > .menu-item > .menu-link {
    padding: 12px 15px;
    font-size: 14px;
    font-weight: 400;
    color: #777;
    border: none;
    border-radius: 0;
    background: transparent;
}

.gi-mobile-panel .gi-submenu.level-2 > .menu-item > .menu-link:hover {
    color: #5caf90;
    background: #f8f8f8;
    padding-left: 20px;
}

/* Level 3 submenu in mobile */
.gi-mobile-panel .gi-submenu.level-3 {
    position: static;
    left: auto !important;
    margin: 0;
    padding: 0;
    background: transparent;
}

.gi-mobile-panel .gi-submenu.level-3[aria-hidden="false"] {
    max-height: 800px;
    margin-top: 5px;
}

.gi-mobile-panel .gi-submenu.level-3 .menu-link {
    padding-left: 30px;
    font-size: 13px;
    color: #999;
}

.gi-mobile-panel .gi-submenu.level-3 .menu-link:hover {
    color: #5caf90;
    padding-left: 35px;
}

.gi-mobile-panel .gi-submenu .gi-submenu-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* ===================================
   MOBILE OVERLAY
   =================================== */

.gi-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

.gi-mobile-overlay[hidden] {
    display: block !important;
    pointer-events: none;
}

.gi-mobile-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Body scroll lock when mobile menu open */
body.gi-menu-open {
    overflow: hidden;
}

body.gi-menu-open::before {
    content: none;
}

/* ===================================
   ACCESSIBILITY
   =================================== */

.menu-link:focus,
.gi-mobile-toggle:focus,
.gi-mobile-panel-close:focus {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
    border-radius: 3px;
}

.gi-submenu-toggle:focus {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
    border-radius: 3px;
}

.menu-link:focus-visible,
.gi-submenu-toggle:focus-visible {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
}

/* Skip to content link */
.gi-skip-link,
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #5caf90;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    transition: all 0.3s ease-in-out;
}

.gi-skip-link:focus,
.skip-to-content:focus {
    top: 0;
}

/* Screen reader only */
.gi-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===================================
   RTL SUPPORT
   =================================== */

[dir="rtl"] .gi-submenu.level-3 {
    left: auto !important;
    right: 100% !important;
    margin-left: 0;
    margin-right: 0;
}

[dir="rtl"] .gi-submenu-toggle {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .gi-mobile-panel {
    left: auto;
    right: 0;
    transform: translateX(100%);
}

[dir="rtl"] .gi-mobile-panel:not([hidden]) {
    transform: translateX(0);
}

[dir="rtl"] .gi-mobile-panel .gi-submenu.level-3 .menu-link {
    padding-left: 15px;
    padding-right: 30px;
}

[dir="rtl"] .gi-mobile-panel .gi-submenu.level-3 .menu-link:hover {
    padding-left: 15px;
    padding-right: 35px;
}

[dir="rtl"] .gi-submenu .menu-link:hover {
    padding-left: 20px;
    padding-right: 25px;
}

/* ===================================
   RESPONSIVE ADJUSTMENTS
   =================================== */

@media (max-width: 1199px) {
    .gi-menu.level-1 > .menu-item {
        margin: 0 12px;
    }
    
    .gi-menu.level-1 > .menu-item > .menu-link {
        font-size: 14px;
        line-height: 50px;
    }
}

@media (max-width: 991px) {
    .gi-menu.level-1 > .menu-item {
        margin: 0 8px;
    }
    
    .gi-menu.level-1 > .menu-item > .menu-link {
        font-size: 13px;
        line-height: 45px;
    }
    
    #gi-main-menu-desk .nav-desk {
        display: none;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .gi-mobile-toggle,
    .gi-mobile-panel,
    .gi-mobile-overlay,
    .gi-submenu-toggle {
        display: none !important;
    }
    
    .gi-submenu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        max-height: none !important;
        transform: none;
        border: none;
        box-shadow: none;
        padding-left: 20px;
    }
    
    .gi-menu.level-1 {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===================================
   HIGH CONTRAST MODE
   =================================== */

@media (prefers-contrast: high) {
    .gi-menu.level-1 > .menu-item > .menu-link {
        border: 1px solid transparent;
    }
    
    .gi-menu.level-1 > .menu-item > .menu-link:focus {
        border-color: currentColor;
    }
    
    .gi-submenu {
        border: 2px solid currentColor;
    }
}

/* ===================================
   REDUCED MOTION
   =================================== */

@media (prefers-reduced-motion: reduce) {
    .gi-menu,
    .gi-submenu,
    .gi-submenu-toggle i,
    .gi-mobile-panel,
    .gi-mobile-overlay,
    .gi-mobile-panel-close,
    .menu-link {
        transition: none !important;
        animation: none !important;
    }
}

