/* TeakBD E-commerce Header Styles
   Optimized to use CSS Variables from style.css
*/

/* Note: Base resets are handled in style.css */

/* --- 1. UNIVERSAL STYLES & INTERSECTIONS --- */

/* Base Typography & Sticky Logic */
.ecommerce-header {
    font-family: var(--font-main, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif);
    color: var(--text-main, #374151);
    background: var(--bg-white, #ffffff);
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.07));
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    left: 0;
}

/* Base Interactive States */
a:active,
a:focus,
button:active,
button:focus,
button:hover {
    color: #323232;
    box-shadow: none;
    outline: none;
    background: none;
}

/* Universal Header List Resets to prevent bullet points */
.ecommerce-header ul,
.ecommerce-header li,
.mobile-menu ul,
.mobile-menu li {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Logo Section (Appears in every layout) */
.header-logo {
    flex-shrink: 0;
}

.header-logo a {
    display: block;
    align-items: center;
    text-decoration: none;
    font-family: var(--font-main, -apple-system, sans-serif);
    letter-spacing: -0.01em;
    color: inherit;
    box-shadow: none;
    text-shadow: none;
}

.logo-container {
    display: flex;
    align-items: baseline;
    gap: 0.125rem;
    margin-right: 0.5rem;
}

.logo-text {
    display: flex;
    align-items: baseline;
    gap: 0.125rem;
}

.logo-teak {
    font-size: 1.75rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.logo-bd {
    font-size: 1.5rem;
    color: #4a5568;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    transform: skew(-8deg);
}

/* Search Container Hardware (Appears in every layout) */
.header-search-flex {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Icon Buttons & Badges (Cart, Wishlist - Intersecting elements) */
.icon-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: none;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
    color: var(--text-main, #374151);
    font-family: var(--font-main, -apple-system, sans-serif);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    box-shadow: none;
}

.icon-button svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke: currentColor;
    transition: color 0.2s ease, stroke 0.2s ease;
}

/* Universal Interaction Colors for Icon Buttons */
.cart-contents:hover,
#mobileSearchButton:hover {
    color: #2563EB;
}

.wishlist-button:hover {
    color: #EF4444;
}


.count-badge {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    min-width: 1.125rem;
    height: 1.125rem;
    border-radius: 0.5625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3125rem;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.count-badge:empty {
    display: none;
}

.button-text {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Header Action Layout */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Main Container Wrappers */
.header-primary {
    padding: 0.6rem;
}

.header-primary-container {
    max-width: var(--container-max, 1200px);
    margin: 0 auto;
    padding: 0 1.5rem 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Mobile actions container - intersection grouping */
.mobile-search-cart-actions {
    display: flex;
    align-items: center;
}



/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 2. TABLET & DESKTOP OVERRIDES (min-width: 769px) --- */
@media (min-width: 769px) {

    /* Hiding Mobile-Only Hardware on Desktop */
    .teak-mobile-menu-toggle,
    .mobile-menu,
    .mobile-menu-overlay,
    .search-mobile {
        display: none;
    }

    /* --- Account Component (Desktop/Tablet) --- */

    .account-dropdown {
        position: relative;
    }

    .header-account-trigger {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-main, #374151);
        font-size: 1rem;
        border-radius: 6px;
        text-decoration: none;
    }


    .account-icon {
        width: 1.25rem;
        height: 1.25rem;
    }

    .account-menu {
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--bg-white, #ffffff);
        border: 1px solid var(--border-hover);
        border-radius: 8px;
        box-shadow: var(--shadow-md, 0 10px 25px rgba(0, 0, 0, 0.1));
        min-width: 160px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
        z-index: 100;
    }

    .account-dropdown:hover .account-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .account-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .account-menu a {
        display: block;
        padding: 0.75rem 1rem;
        color: var(--text-main, #374151);
        text-decoration: none;
        font-size: 0.875rem;
        transition: background-color 0.2s, color 0.2s;
        box-shadow: none;
    }

    .account-menu a:hover {
        background: var(--bg-gray-light, #f3f4f6);
        color: var(--primary-color, #283bd1);
    }


    .account-menu a:first-child {
        border-radius: 8px 8px 0 0;
    }

    .account-menu a:last-child {
        border-radius: 0 0 8px 8px;
    }

    /* --- Category & Mega Menu Component --- */
    .category-mega-menu {
        display: flex;
        align-items: center;
        margin-left: 2rem;
        margin-right: 0.5rem;
    }

    .category-dropdown {
        position: relative;
    }

    .category-trigger {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        color: var(--text-main, #374151);
        background: white;
        border: 1px solid #d8d8d8;
        border-radius: 5px;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
        text-decoration: none;
    }

    .category-hamburger {
        width: 1rem;
        height: 1rem;
    }

    .category-chevron {
        width: 1rem;
        height: 1rem;
        transition: transform 0.3s ease;
    }

    .category-text {
        font-size: 0.9rem;
        font-weight: 600;
    }

    .category-mega-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--bg-white, #ffffff);
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        box-shadow: none;
        min-width: 43.75rem;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-0.625rem);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
        margin-top: 0.25rem;
    }

    .category-dropdown:hover .category-mega-dropdown,
    .category-dropdown.active .category-mega-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .category-dropdown:hover .category-chevron,
    .category-dropdown.active .category-chevron {
        transform: rotate(180deg);
    }

    .category-dropdown:hover::after {
        height: 0.5rem;
    }

    .category-mega-dropdown::before {
        content: '';
        position: absolute;
        top: -0.5rem;
        left: 1.25rem;
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid var(--border-hover, #d1d5db);
    }

    .category-mega-dropdown::after {
        content: '';
        position: absolute;
        top: -0.4375rem;
        left: 1.3125rem;
        width: 0;
        height: 0;
        border-left: 7px solid transparent;
        border-right: 7px solid transparent;
        border-bottom: 7px solid white;
    }

    .category-dropdown::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 0.25rem;
        background: transparent;
        z-index: 99;
    }

    /* Mega Menu Grid Logic */
    .mega-menu-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        padding: 1rem;
    }

    .mega-menu-column {
        min-height: 120px;
    }

    .mega-menu-column h4 {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        border-bottom: 1.6px solid var(--primary-color);
    }

    .mega-menu-column h4 a,
    .mega-menu-column h4 span.mega-menu-title {
        color: #1f2126;
        text-decoration: none;
        transition: color 0.2s;
        box-shadow: none;
        pointer-events: none;
        cursor: default;
        opacity: 1;
    }

    .mega-menu-column h4 a:hover,
    .mega-menu-column h4 span.mega-menu-title:hover {
        color: var(--primary-color, #703aed);
    }

    .mega-menu-subcategories {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mega-menu-subcategories a {
        display: block;
        padding: 0.5rem 0;
        color: #2f3132;
        text-decoration: none;
        font-size: 0.9rem;
        transition: all 0.2s;
        border-radius: 2px;
        padding-left: 0.5rem;
        margin-left: -0.5rem;
        box-shadow: none;
    }

    .mega-menu-subcategories a:hover {
        color: var(--primary-color, #703aed);
        background: #f8fafc;
        padding-left: 0.75rem;
    }

    /* --- Navigation Styles --- */
    .header-navigation {
        padding: 0.68rem 0;
        border-top: 1px solid var(--border-hover, #d5d5d5);
    }

    .header-nav-container {
        max-width: var(--container-max, 1200px);
        margin: 0 auto;
        padding: 0 1rem;
    }

    .desktop-nav {
        display: flex;
        justify-content: center;
    }

    .category-menu,
    .page-menu {
        display: flex;
        align-items: center;
        gap: 2rem;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .nav-link {
        color: var(--text-main, #374151);
        text-decoration: none;
        font-weight: 400;
        padding: 0.5rem 0;
        transition: color 0.2s;
        position: relative;
        font-size: 0.95rem;
        white-space: nowrap;
        box-shadow: none;
    }

    .nav-link:hover {
        color: var(--primary-color, #703aed);
    }

    .nav-link::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 0;
        height: 1px;
        background: var(--primary-color, #703aed);
        transition: width 0.2s;
    }

    .nav-link:hover::after {
        width: 100%;
    }

    .search-mobile {
        display: none;
    }
}

/* --- 3. TABLET OVERRIDES (769px–1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {

    /* Hide text labels on tablet — icons only to save horizontal space */
    .cart-contents .button-text,
    .wishlist-button .button-text,
    .category-text {
        display: none;
    }

    .category-trigger {
        padding: 0.6rem 0.5rem;
    }
}

/* --- 4. MOBILE OVERRIDES (max-width: 768px) --- */
@media (max-width: 768px) {


    .header-navigation {
        display: none;
    }

    .header-primary-container {
        gap: 0.5rem;
        padding: 0 0.3rem;
        flex-wrap: nowrap;
    }

    .desktop-nav,
    .category-mega-menu,
    .account-dropdown,
    .header-actions .wishlist-button {
        display: none;
    }

    .header-logo {
        flex: 1;
        display: flex;
        justify-content: center;
        margin-left: 0;
        margin-right: 0;
    }

    /* Mobile Search Activation */
    .header-search-flex:not(.active) {
        display: none;
    }

    .header-search-flex {
        display: flex;
        position: absolute;
        top: 100%;
        min-width: 95%;
        z-index: 999;
        height: 55px;
    }

    .icon-button svg {
        width: 26px;
        height: 26px;
    }

    .button-text {
        display: none;
    }

    .mobile-search-cart-actions {
        display: flex;
        align-items: center;
        margin-left: auto;
    }

    .search-mobile {
        display: flex;
    }


    .header-actions .cart-contents .count-badge {
        right: -4px;
        top: -4px;
    }

    /* Mobile Menu Toggle Activation */
    .teak-mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        background: var(--bg-white);
        width: 44px;
        height: 44px;
        cursor: pointer;
        padding: 0 6px;
        flex-shrink: 0;
        order: -1;
    }

    .hamburger-line {
        width: 100%;
        height: 2px;
        background: var(--text-main);
        margin: 3px 0;
        transition: all 0.3s ease;
        transform-origin: center;
    }

    .teak-mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .teak-mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
        opacity: 0;
    }

    .teak-mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Mobile Menu Drawer Reveal */
    .mobile-menu {
        display: flex;
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        max-width: 290px;
        height: 100%;
        background: var(--bg-white);
        z-index: 1600;
        transition: left 0.3s ease;
        box-shadow: none;
        overflow-y: auto;
        flex-direction: column;
    }

    .mobile-menu.active {
        left: 0;
    }

    .mobile-menu-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Drawer Interior Content */
    .mobile-menu-header {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .mobile-tab-nav {
        display: flex;
        border-bottom: 1px solid #dedfe2;
        background: none;
        flex-shrink: 0;
    }

    .mobile-tab-button {
        flex: 1;
        padding: 0.6rem;
        background: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        font-size: 1rem;
        font-weight: 500;
        color: #6b7280;
        text-decoration: none;
        box-shadow: none;
    }

    .mobile-tab-button.active {
        color: #667eea;
        border-bottom-color: #667eea;
    }

    .mobile-tab-content {
        display: none;
        animation: fadeIn 0.3s ease;
        flex-grow: 1;
        overflow-y: auto;
    }

    .mobile-tab-content.active {
        display: block;
    }

    .mobile-menu-section a {
        display: block;
        padding: 0.8rem 1.5rem;
        color: #374151;
        text-decoration: none;
        transition: background-color 0.2s, padding-left 0.2s;
        font-size: 1rem;
        font-weight: 500;
        box-shadow: none;
        border-bottom: 1px solid #f3f4f6;
    }

    .mobile-menu-section a:hover {
        color: #667eea;
        background: #f8fafc;
        padding-left: 2rem;
    }

    .mobile-menu-footer {
        flex-shrink: 0;
        border-top: 1px solid #e5e7eb;
        background: #f9fafb;
        padding: 0.5rem 0;
    }

    .mobile-account-links a {
        display: flex;
        align-items: center;
        padding: 0.75rem 1.5rem;
        color: #374151;
        text-decoration: none;
        transition: background-color 0.2s;
        font-size: 0.95rem;
        font-weight: 500;
        box-shadow: none;
        border-bottom: 1px solid #f3f4f6;
    }

    .mobile-account-icon {
        width: 1.25rem;
        height: 1.25rem;
        display: inline-block;
        vertical-align: middle;
        margin-right: 0.625rem;
        flex-shrink: 0;
    }

    .mobile-menu-close {
        display: block;
        background: none;
        font-size: 2rem;
        cursor: pointer;
        color: #374151;
        text-decoration: none;
        line-height: 1;
        padding: 5px 8px;
    }

    .mobile-category-parent {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        background: none;
        width: 100%;
        text-align: left;
        font-size: 1rem;
        font-weight: 500;
        color: #374151;
        cursor: pointer;
        text-decoration: none;
        box-shadow: none;
        border-bottom: 1px solid #f3f4f6;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .mobile-category-parent.active {
        background-color: #f9fafb;
        color: var(--primary-color, #703aed);
    }

    .mobile-category-icon {
        width: 1.25rem;
        height: 1.25rem;
        transition: transform 0.3s ease;
    }

    .mobile-category-parent.active .mobile-category-icon {
        transform: rotate(180deg);
    }

    .mobile-subcategories {
        display: grid;
        grid-template-rows: 0fr;
        transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }

    .mobile-subcategories.active {
        grid-template-rows: 1fr;
    }

    .mobile-subcategories>ul {
        min-height: 0;
    }

    .mobile-subcategories a {
        display: block;
        padding: 0.75rem 1.5rem;
        color: #6b7280;
        text-decoration: none;
        font-size: 0.875rem;
        box-shadow: none;
    }
}