/* Archive/Page Headers */
.page-header,
.ast-archive-description {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.page-header .page-title,
.ast-archive-description .ast-archive-title {
    color: var(--text-color);
}

a {
    color: var(--primary-color);
    transition: color 0.3s;
}

a:hover {
    color: var(--primary-color);
}

/* Header Overrides */
.site-header {
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

/* Top Bar */
.top-bar {
    background: var(--top-bar-bg);
    padding: 8px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    /* Added padding */
}

.top-bar-left,
.top-bar-right {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: end;
    flex: 1;
}

.top-bar-left {
    justify-content: start;
}

.top-bar-right {
    justify-content: end;
}

.top-bar-center {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.promo-text {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    animation: fadeInPromo 0.8s ease-in-out 2s forwards;
}

@keyframes fadeInPromo {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-text {
    color: var(--text-muted);
}

/* Light Mode: Dark text for top bar */
.top-bar-left,
.top-bar-right,
.welcome-text {
    color: var(--top-bar-text-color) !important;
}

.top-bar a {
    color: var(--top-bar-link-color);
    text-decoration: none;
    transition: color 0.3s;
}

.top-bar a:hover {
    color: var(--primary-color);
}

/* Main Header */
.main-header {
    padding: 20px 0;
}

.main-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 0 20px;
    /* Added padding */
}

header .logo {
    min-width: 140px;
}

.logo a {
    font-size: 2rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
    letter-spacing: 1px;
    display: block;
}

.logo a span {
    color: var(--primary-color);
}

/* Header Search Area */
.header-search-area {
    flex: 1;
    max-width: 800px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

/* Category Menu Button */
.category-menu-wrapper {
    position: relative;
}

.category-menu-btn {
    background: var(--primary-color);
    color: #000;
    border: none;
    padding: 0 25px;
    height: 45px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.category-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 185, 0, 0.3);
    background: #e0a800;
}

/* Category Dropdown */
.category-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 280px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 0;
    margin-top: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.category-menu-wrapper:hover .category-menu-dropdown,
.category-menu-wrapper.force-hover .category-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Menu List */
.category-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
    /* Establish positioning context for submenus */
}

.category-menu-item {
    position: static;
    /* Allow submenus to position relative to the list */
}

.category-menu-item>a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.category-menu-item>a:hover {
    background: var(--search-bg);
    color: var(--primary-color);
}

.category-menu-item>a i {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Sub Menu (Flyout) */
.sub-menu {
    position: absolute;
    top: -10px;
    left: 100%;
    width: 250px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 0;
    list-style: none;
    margin: 0 0 0 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    /* Removed transform to allow fixed children to escape overflow */
    margin-left: -10px;
    transition: opacity 0.3s ease, visibility 0.3s ease, margin-left 0.3s ease;
    /* Scrollable Fix */
    max-height: calc(100vh - 150px);
    /* Prevent overflow off screen */
    overflow-y: auto;
    overflow-x: visible;
    /* Enable vertical scrolling, allow horizontal overflow for nested sub-menus */
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: var(--primary-color) var(--card-bg);
}

/* Webkit Scrollbar Styling for Submenu */
.sub-menu::-webkit-scrollbar {
    width: 6px;
}

.sub-menu::-webkit-scrollbar-track {
    background: var(--card-bg);
    border-radius: 10px;
}

.sub-menu::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
}

.category-menu-item:hover>.sub-menu,
.category-menu-item.force-hover>.sub-menu,
.sub-menu .category-menu-item:hover>.sub-menu,
.sub-menu.clone-active {
    opacity: 1;
    visibility: visible;
    margin-left: 8px;
    /* Animate margin instead of transform */
}

/* Nested sub-menu (child of sub-menu) - HIDDEN because JS clones it outside scrollable container */
.category-menu-dropdown .sub-menu .sub-menu {
    display: none !important;
    /* JS will clone this and display it outside the scrollable container */
}

/* Ensure nested sub-menu items have correct styles */
.category-menu-dropdown .sub-menu .category-menu-item>a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.category-menu-dropdown .sub-menu .category-menu-item>a:hover {
    background: var(--search-bg);
    color: var(--primary-color);
}

/* Position nested sub-menu relative to hovered parent */
.category-menu-dropdown .sub-menu .category-menu-item {
    position: relative;
}

/* Cloned Submenu (JS-generated for nested sub-menus) */
.cloned-submenu {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.cloned-submenu .category-menu-item>a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.cloned-submenu .category-menu-item>a:hover {
    background: var(--search-bg);
    color: var(--primary-color);
}

/* Maintain hover state on parent item when clone is active */
.category-menu-item.hover-active>a {
    background: var(--search-bg);
    color: var(--primary-color);
}

/* Search Bar Wrapper (Refined) */
.search-bar-wrapper {
    flex: 1;
    display: flex;
    background: var(--search-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.search-form {
    position: relative;
    margin-bottom: 0;
    flex: 1;
    display: flex;
}

.search-field {
    background: transparent !important;
    border: none !important;
    color: var(--search-text) !important;
    width: 100%;
    padding: 10px 20px !important;
    font-size: 0.95rem;
}

.search-field:focus {
    outline: none;
}

.search-submit {
    background: transparent !important;
    border: none !important;
    color: var(--text-color) !important;
    padding: 0 20px !important;
    cursor: pointer;
    font-size: 1.1rem;
    transition: 0.16s ease;
}

.search-submit:hover {
    transform: scale(1.2);
    color: var(--primary-color) !important;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-actions a {
    color: var(--text-color);
    font-size: 1.2rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--search-bg);
    border-radius: 50%;
    transition: all 0.3s;
}

.header-actions a:hover {
    background: var(--primary-color);
    color: #000;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary-color);
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Wishlist Count Badge - Identical to Cart Count */
.wishlist-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary-color);
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Navigation Bar */
.main-navigation-bar {
    border-top: 1px solid var(--border-color);
    background: var(--nav-bar-bg);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.main-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    justify-content: center;
}

.main-nav ul li a {
    display: block;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s;
}

.main-nav ul li a:hover {
    color: var(--primary-color);
    background: var(--search-bg);
}

/* Buttons */
.button,
.wp-block-button__link,
input[type="submit"],
button[type="submit"],
a.button.product_type_simple,
a.button.promo-btn {
    background: var(--primary-color);
    color: #000;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 30px;
    border: none;
    transition: all 0.3s ease;
    text-decoration: none;
}

.button:hover:not(.search-submit),
.wp-block-button__link:hover:not(.search-submit),
input[type="submit"]:hover:not(.search-submit),
button[type="submit"]:hover:not(.search-submit) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 215, 0, 0.3);
    background-color: #e6c200;
    color: #000;
}

.header-cart-wrapper {
    position: relative;
}

.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.cart-dropdown p.woocommerce-mini-cart__buttons.buttons {
    margin-bottom: 1.08em;
}

.header-cart-wrapper:hover .cart-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.empty-cart-message {
    text-align: center;
    color: var(--text-muted);
    margin: 0;
    padding: 20px 0;
}

/* Dynamic Logo Styles */
.logo-for-light {
    display: var(--logo-for-light-display) !important;
}

.logo-for-dark {
    display: var(--logo-for-dark-display) !important;
}

.site-logo {
    max-height: 40px;
    width: auto;
}

/* Footer styles moved to css/footer.css */

/* Universal Theme Transition - Optimized */
.theme-transitioning,
.theme-transitioning * {
    transition: none !important;
    /* Disable transitions while overlay covers the screen */
}

/* Smooth Background Transition Setup (Overlay Method) */
html {
    background-color: #111;
    /* Dark Base */
}

body {
    background-color: transparent !important;
    /* Let html show through */
    position: relative;
    /* For pseudo-element positioning */
    z-index: 0;
}

/* Light Mode Overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f4f4;
    /* Light Base */
    z-index: -1;
    opacity: var(--page-overlay-opacity);
    transition: opacity 0.5s ease;
    pointer-events: none;
}

/* Fix Desktop Mini-Cart Styles */
.header-cart-wrapper .widget_shopping_cart .cart_list li,
.header-cart-wrapper .widget_shopping_cart li,
.header-cart-wrapper ul.product_list_widget .cart_list li,
.header-cart-wrapper ul.product_list_widget li {
    padding: 15px 0 !important;
    min-height: auto !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 0 !important;
    padding-bottom: 15px !important;
    display: flex !important;
    align-items: center !important;
    gap: 15px !important;
}

.header-cart-wrapper .widget_shopping_cart ul li:hover {
    padding-left: 0 !important;
}

ul.cart_list div:not(.mini-cart-item-details) a {
    width: 60px !important;
}

/* Reuse Mini-Cart Image Wrapper Styles */
.header-cart-wrapper .mini-cart-image-wrapper {
    position: relative;
    width: 60px;
    /* Match old size */
    height: 60px;
    /* Match old size */
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.header-cart-wrapper .mini-cart-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: static !important;
    margin: 0 !important;
}

/* Remove Button Styling for Desktop */
.header-cart-wrapper .woocommerce-mini-cart-item .remove_from_cart_button {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.67) !important;
    color: #FFF !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    opacity: 0;
    transition: opacity 0.2s ease;
    text-decoration: none !important;
    z-index: 10;
    border-radius: 0 !important;
}

.header-cart-wrapper .mini-cart-image-wrapper:hover .remove_from_cart_button {
    opacity: 1;
}

.header-cart-wrapper .woocommerce-mini-cart-item .remove_from_cart_button::before {
    content: "×";
    font-family: Arial, sans-serif;
    font-weight: bold;
    font-size: 24px !important;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Product Details - Match Legacy Styles */
.header-cart-wrapper .mini-cart-item-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.header-cart-wrapper .mini-cart-item-details a {
    font-size: 0.95rem;
    /* Match legacy font size */
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    display: block;
    margin-bottom: 5px;
    line-height: 1.2;
    padding: 0 !important;
    transition: color 0.2s;
    /* Line Clamp for max 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    width: auto;
    border-radius: 2px;
    height: 38px;
}

.header-cart-wrapper .mini-cart-item-details a:hover {
    color: var(--primary-color);
    background: initial;
}

.header-cart-wrapper .woocommerce-mini-cart-item .quantity {
    display: block;
    font-size: 0.9rem;
    /* Match legacy font size */
    color: var(--text-muted);
}

/* Subtotal - Match Legacy Styles */
.header-cart-wrapper .woocommerce-mini-cart__total {
    padding: 15px 0;
    border-top: 2px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
    font-size: 1rem;
    /* Reset font size */
}

/* Buttons - Match Legacy Styles */
.header-cart-wrapper .woocommerce-mini-cart__buttons {
    display: flex;
    gap: 10px;
    flex-direction: row;
    /* Horizontal layout like before */
    margin-bottom: 13px;
}

.header-cart-wrapper .woocommerce-mini-cart__buttons .button {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: auto;
    /* Reset width */
}

.header-cart-wrapper .woocommerce-mini-cart__buttons .button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.header-cart-wrapper .woocommerce-mini-cart__buttons .checkout {
    background-color: var(--primary-color);
    color: #000;
    border: 1px solid var(--primary-color);
}

.header-cart-wrapper .woocommerce-mini-cart__buttons .checkout:hover {
    background-color: #e0a800;
    border-color: #e0a800;
    color: #000;
}

/* minicart manual enhancements */
.woocommerce-js ul.product_list_widget li img {
    width: 60px !important;
    height: 60px !important;
    transform: none !important;
}

p.woocommerce-mini-cart__empty-message {
    text-align: center;
    margin-top: 10px;
}

/* Desktop Mini-Cart Scrollable Styles */
.header-cart-wrapper .cart-dropdown {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 100px);
}

.header-cart-wrapper .woocommerce-mini-cart {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 280px);
    /* Account for header, total, and buttons */
    padding-right: 4px;
    /* Space for scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--card-bg);
}

/* Scrollbar styling matching AJAX search results */
.header-cart-wrapper .woocommerce-mini-cart::-webkit-scrollbar {
    width: 6px;
}

.header-cart-wrapper .woocommerce-mini-cart::-webkit-scrollbar-track {
    background: var(--card-bg);
}

.header-cart-wrapper .woocommerce-mini-cart::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.header-cart-wrapper .woocommerce-mini-cart::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Only Visible - Hide on desktop when top-bar is visible */
.mobile-only-visible {
    display: none !important;
}

/* ===========================================
   STICKY HEADER STYLES
   =========================================== */

/* Safety: Ensure no padding-top when not in sticky mode */
body:not(.desktop-sticky):not(.mobile-sticky) {
    padding-top: 0 !important;
}

/* Desktop Sticky */
body.desktop-sticky .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

body.desktop-sticky .top-bar {
    display: none;
}

/* Mobile Sticky */
body.mobile-sticky .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    background: var(--header-bg);
}

body.mobile-sticky .goled-global-category-bar {
    background: var(--header-bg);
}

.search-bar-wrapper input.search-field {
    border-radius: 20px !important;
    margin: 3px;
    padding: 7px 17px !important;
    height: 37px;
}

.search-bar-wrapper input.search-field:focus {
    background: #1111117d !important;
    border: none !important;
}

.search-loading,
.search-no-results {
    text-align: center;
    padding: 10px;
}

@media (max-width: 1200px) {
    .mobile-only-visible {
        display: flex !important;
    }
}