/* ═══════════════════════════════════════════
   STW Mega Menu – Frontend Styles
   ═══════════════════════════════════════════ */

/* ─── CSS Variables (defaults, overridden by inline styles from PHP) ─── */

:root {
    --stw-hamburger-color: #333333;
    --stw-hamburger-active-color: #0073aa;
    --stw-mobile-bg: #ffffff;
    --stw-mobile-text: #333333;
}

/* ═══════════════════════════════════════════
   HEADER BAR (above menu)
   ═══════════════════════════════════════════ */

.stw-header-bar {
    position: relative;
    border-bottom: 1px solid #e5e5e5;
    z-index: 9998;
}

.stw-header-bar-desktop {
    background: linear-gradient(45deg, var(--stw-hd-grad1, #ffffff), var(--stw-hd-grad2, #f8f9fa), var(--stw-hd-grad3, #e8eaed));
}

.stw-header-bar-mobile {
    background: linear-gradient(45deg, var(--stw-hm-grad1, #ffffff), var(--stw-hm-grad2, #f8f9fa), var(--stw-hm-grad3, #e8eaed));
}

.stw-header-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 6px 16px;
}

.stw-hb-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.stw-hb-group-left {
    justify-content: flex-start;
}

.stw-hb-group-center {
    justify-content: center;
    flex: 1;
}

.stw-hb-group-right {
    justify-content: flex-end;
}

.stw-hb-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.stw-hb-image a,
.stw-hb-image img {
    display: block;
    line-height: 0;
}

.stw-hb-cart .stw-header-cart-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #333;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    position: relative;
}

.stw-hb-cart .stw-header-cart-link:hover {
    background: #e8f0fe;
    color: #0073aa;
}

.stw-header-cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: #0073aa;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    padding: 0 4px;
    line-height: 1;
}

.stw-hb-text-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    border-radius: 4px;
    line-height: 1.3;
}

.stw-hb-text-line {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.stw-hb-text-line:first-child {
    font-weight: 600;
}

a.stw-hb-text-link {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

a.stw-hb-text-link:hover {
    opacity: 0.8;
}

.stw-hb-icon-text {
    display: flex;
    align-items: center;
}

.stw-hb-icon-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.stw-hb-icon-link:hover {
    background: #e8f0fe;
}

.stw-hb-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.stw-hb-icon-texts {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.stw-hb-icon-line1 {
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

.stw-hb-icon-line2 {
    font-size: 12px;
    font-weight: 500;
    color: #555;
}

.stw-hb-shortcode {
    font-size: 13px;
}

/* Desktop header bar — hidden on mobile */
.stw-header-bar-desktop {
    display: block;
}

/* Mobile header bar — hidden on desktop */
.stw-header-bar-mobile {
    display: none;
}

/* ═══════════════════════════════════════════
   DESKTOP MEGA MENU
   ═══════════════════════════════════════════ */

.stw-desktop-nav {
    position: relative;
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    z-index: 9999;
    margin-top: var(--stw-hd-mt, 0px);
    margin-bottom: var(--stw-hd-mb, 0px);
}

.stw-desktop-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
}

.stw-desktop-menu-item {
    position: relative;
}

.stw-desktop-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.stw-desktop-link:hover,
.stw-desktop-link:focus {
    color: #0073aa;
    background: #f8f9fa;
}

.stw-desktop-menu-item.stw-has-mega > .stw-desktop-link::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 8px;
    transition: transform 0.2s;
}

.stw-desktop-menu-item.stw-has-mega:hover > .stw-desktop-link::after,
.stw-desktop-menu-item.stw-has-mega.stw-mega-open > .stw-desktop-link::after {
    transform: rotate(180deg);
}

/* ─── Mega Dropdown ─── */

.stw-mega-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 750px;
    max-width: 750px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-top: 3px solid #0073aa;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 10000;
    padding: 20px;
}

.stw-desktop-menu-item:hover > .stw-mega-dropdown,
.stw-desktop-menu-item.stw-mega-open > .stw-mega-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.stw-mega-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.stw-mega-child-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #333;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.2s;
    text-align: center;
    flex-shrink: 0;
}

.stw-mega-child-link:hover {
    background: #f0f6fc;
    transform: translateY(-2px);
}

.stw-mega-child-img {
    width: 140px;
    height: 140px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    background: #f6f7f7;
}

.stw-mega-child-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

h1.stw-mega-child-title {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
    margin: 0;
    line-height: 1.4;
    text-transform: capitalize;
}

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

.stw-mobile-nav {
    display: none;
    margin-top: var(--stw-hm-mt, 0px);
    margin-bottom: var(--stw-hm-mb, 0px);
}

/* ─── Hamburger Button ─── */

.stw-hamburger {
    position: relative;
    z-index: 10010;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.stw-hamburger-line {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--stw-hamburger-color);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s, background 0.3s;
}

.stw-hamburger.active .stw-hamburger-line {
    background: var(--stw-hamburger-active-color);
}

.stw-hamburger.active .stw-hamburger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.stw-hamburger.active .stw-hamburger-line:nth-child(2) {
    opacity: 0;
}

.stw-hamburger.active .stw-hamburger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ─── Overlay ─── */

.stw-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 10000;
}

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

/* ─── Slide Panel ─── */

.stw-mobile-panel {
    position: fixed;
    top: 0;
    width: 85%;
    max-width: 360px;
    height: 100%;
    background: var(--stw-mobile-bg);
    z-index: 10001;
    overflow-y: auto;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.stw-slide-left {
    left: 0;
    transform: translateX(-100%);
}

.stw-slide-right {
    right: 0;
    transform: translateX(100%);
}

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

.stw-mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
}

.stw-mobile-panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--stw-mobile-text);
}

.stw-mobile-close {
    display: none;
}

/* ─── Mobile Menu List ─── */

.stw-mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.stw-mobile-menu-item {
    border-bottom: 1px solid #f0f0f1;
}

.stw-mobile-item-row {
    display: flex;
    align-items: center;
}

.stw-mobile-link {
    flex: 1;
    display: block;
    padding: 14px 20px;
    color: var(--stw-mobile-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    text-transform: capitalize;
    transition: background 0.2s;
}

.stw-mobile-link:hover {
    background: #f8f9fa;
}

.stw-mobile-toggle {
    background: none;
    border: none;
    border-left: 1px solid #f0f0f1;
    padding: 14px 16px;
    cursor: pointer;
    color: var(--stw-mobile-text);
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    transition: background 0.2s;
}

.stw-mobile-toggle:hover {
    background: #f0f0f1;
}

.stw-mobile-toggle-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.stw-mobile-menu-item.stw-submenu-open .stw-mobile-toggle-icon {
    transform: rotate(45deg);
}

/* ─── Mobile Submenu (Accordion) ─── */

.stw-mobile-submenu {
    display: none;
    background: #f9f9f9;
    padding: 12px 16px;
    border-top: 1px solid #e5e5e5;
}

.stw-mobile-menu-item.stw-submenu-open .stw-mobile-submenu {
    display: block;
}

.stw-mobile-child-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    text-decoration: none;
    color: var(--stw-mobile-text);
    border-radius: 6px;
    transition: background 0.2s;
}

.stw-mobile-child-link:hover {
    background: #e8f0fe;
}

.stw-mobile-child-img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #e5e5e5;
}

.stw-mobile-child-title {
    font-size: 14px;
    font-weight: 500;
    text-transform: capitalize;
    color: var(--stw-mobile-text);
}

/* ═══════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .stw-desktop-nav {
        display: none !important;
    }

    .stw-header-bar-desktop {
        display: none !important;
    }

    .stw-mobile-nav {
        display: block !important;
    }

    .stw-header-bar-mobile {
        display: block !important;
    }

    .stw-header-bar-mobile .stw-header-bar-inner {
        gap: 10px;
        padding: 6px 16px;
    }

    .stw-header-bar-mobile .stw-hb-text-line {
        font-size: 11px;
    }

    .stw-header-bar-mobile .stw-hb-icon-img {
        width: 22px;
        height: 22px;
    }

    .stw-header-bar-mobile .stw-hb-icon-line1,
    .stw-header-bar-mobile .stw-hb-icon-line2 {
        font-size: 10px;
    }

}

@media (min-width: 769px) {
    .stw-desktop-nav {
        display: block !important;
    }

    .stw-header-bar-desktop {
        display: block !important;
    }

    .stw-mobile-nav {
        display: none !important;
    }

    .stw-header-bar-mobile {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .stw-header-bar-mobile .stw-header-bar-inner {
        gap: 6px;
        padding: 4px 16px;
    }

    .stw-header-bar-mobile .stw-hb-section {
        flex-shrink: 1;
        min-width: 0;
    }

    .stw-header-bar-mobile .stw-hb-text-block {
        padding: 2px 6px;
    }
}

/* ─── Edge positioning for mega dropdown when near viewport edge ─── */

.stw-mega-dropdown.stw-mega-edge-left {
    left: 0;
    transform: translateY(0);
}

.stw-mega-dropdown.stw-mega-edge-right {
    left: auto;
    right: 0;
    transform: translateY(0);
}

.stw-desktop-menu-item:hover > .stw-mega-dropdown.stw-mega-edge-left,
.stw-desktop-menu-item.stw-mega-open > .stw-mega-dropdown.stw-mega-edge-left {
    transform: translateY(0);
}

.stw-desktop-menu-item:hover > .stw-mega-dropdown.stw-mega-edge-right,
.stw-desktop-menu-item.stw-mega-open > .stw-mega-dropdown.stw-mega-edge-right {
    transform: translateY(0);
}
