/* ===================================================
   HEADER BLOCK — Global Styles
   Shared across all header themes (header-1 to header-5)
   =================================================== */

.ms-block-header {
    z-index: 100;
    position: relative;
}

/* ---- Logo Constraints ---- */
/* Prevent logos from inflating header height */
[class*="ms-header-template-"] .main-logo img,
[class*="ms-header-template-"] .main-logo picture img,
[class*="ms-header-template-"] .center-logo img,
[class*="ms-header-template-"] .center-logo picture img,
[class*="ms-header-template-"] .mobile-logo img,
[class*="ms-header-template-"] .mobile-logo picture img {
    max-height: 55px;
    width: auto;
    object-fit: contain;
}

/* ---- Topbar Shared ---- */
.header-topbar {
    max-height: 100px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, background-color 0.3s ease;
}

.header-topbar .ms-social-container {
    width: max-content;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.header-topbar .ms-block-social {
    display: flex;
    align-items: center;
}

.header-topbar .ms-block-social a {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.header-topbar .ms-block-social a:hover {
    opacity: 0.75;
    transform: scale(1.1);
}

/* Topbar text blocks — remove extra margins */
.header-topbar .ms-block-text-editor {
    line-height: 1.4;
}

.header-topbar .ms-block-text-editor p {
    margin: 0 !important;
}

/* ---- Action Items Shared ---- */
[class*="ms-header-template-"] .action-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

[class*="ms-header-template-"] .action-item a,
[class*="ms-header-template-"] .action-item i {
    transition: color 0.2s ease, transform 0.2s ease;
}

[class*="ms-header-template-"] .action-item:hover a,
[class*="ms-header-template-"] .action-item:hover i {
    color: var(--ms-color-primary) !important;
    transform: scale(1.08);
}

/* ---- Hamburger Button Global Override ---- */
[id^="navbar_"] > .ms-navbar-btn a {
    padding: 8px 12px !important;
    border: 1px solid var(--ms-color-border) !important;
    border-radius: 6px !important;
    text-align: center !important;
    font-size: 20px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: inherit !important;
    background: transparent !important;
    line-height: 1 !important;
    height: 42px !important;
    width: 42px !important;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

[id^="navbar_"] > .ms-navbar-btn a:hover {
    border-color: var(--ms-color-primary) !important;
    background: var(--ms-color-light) !important;
}

/* ===================================================
   Fixed Header State
   Parent div gets .ms-position-fixed-active when fixed.
   Compact the header: reduce padding, hide topbar,
   shrink logo, add shadow.
   =================================================== */

.ms-position-fixed-active [class*="ms-header-template-"] {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Hide topbar when fixed — use max-height instead of display:none
   to avoid breaking scroll offset calculations */
.ms-position-fixed-active [class*="ms-header-template-"] .header-topbar {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    border: none;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

/* Shrink logo slightly when fixed */
.ms-position-fixed-active [class*="ms-header-template-"] .main-logo img,
.ms-position-fixed-active [class*="ms-header-template-"] .main-logo picture img,
.ms-position-fixed-active [class*="ms-header-template-"] .center-logo img,
.ms-position-fixed-active [class*="ms-header-template-"] .center-logo picture img,
.ms-position-fixed-active [class*="ms-header-template-"] .mobile-logo img,
.ms-position-fixed-active [class*="ms-header-template-"] .mobile-logo picture img {
    max-height: 40px;
}

/* Header-5: reduce spacing when fixed */
.ms-position-fixed-active .ms-header-template-5 .top-row {
    margin-bottom: 8px;
}

.ms-position-fixed-active .ms-header-template-5 .bottom-row {
    padding: 6px 0;
}

/* ---- Offcanvas Cart ---- */
.ms-header-offcanvas-cart {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100% !important;
    z-index: 999999;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0.3s;
}

.ms-header-offcanvas-cart.ms-offcanvas-open {
    visibility: visible;
    pointer-events: auto;
}

.ms-header-offcanvas-cart .ms-offcanvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.ms-header-offcanvas-cart.ms-offcanvas-open .ms-offcanvas-overlay {
    opacity: 1;
}

.ms-header-offcanvas-cart .ms-offcanvas-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 85vw;
    height: 100%;
    background: var(--ms-color-white, #fff);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

.ms-header-offcanvas-cart.ms-offcanvas-open .ms-offcanvas-content {
    transform: translateX(0);
}

.ms-header-offcanvas-cart .ms-offcanvas-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--ms-color-border, #eee);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ms-header-offcanvas-cart .ms-offcanvas-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--ms-color-dark);
}

.ms-header-offcanvas-cart .ms-offcanvas-header .close-offcanvas {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--ms-color-dark);
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.ms-header-offcanvas-cart .ms-offcanvas-header .close-offcanvas:hover {
    background: var(--ms-color-light);
    color: var(--ms-color-primary);
}

.ms-header-offcanvas-cart .ms-offcanvas-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.ms-header-offcanvas-cart .ms-checkout-cart .ms-cart-title {
    display: none !important;
}

.ms-header-offcanvas-cart .ms-checkout-cart .ms-cart-empty {
    border: none !important;
    padding: 0 !important;
}

body.ms-offcanvas-active {
    overflow: hidden;
}

/* ---- Utility Classes ---- */
@media (max-width: 991px) {
    .desktop-only {
        display: none !important;
    }
    .desktop-only-flex {
        display: none !important;
    }
    .desktop-only-block {
        display: none !important;
    }
    .mobile-only {
        display: block !important;
    }
    .mobile-only-flex {
        display: flex !important;
    }
}

@media (min-width: 992px) {
    .mobile-only {
        display: none !important;
    }
    .mobile-only-flex {
        display: none !important;
    }
}

/* ---- Small Mobile Logo ---- */
@media (max-width: 480px) {
    [class*="ms-header-template-"] .main-logo img,
    [class*="ms-header-template-"] .main-logo picture img,
    [class*="ms-header-template-"] .mobile-logo img,
    [class*="ms-header-template-"] .mobile-logo picture img {
        max-height: 40px;
    }
}

/* ===================================================
   Dark Theme Overrides
   =================================================== */
.ms-header-theme-dark {
    background-color: var(--ms-color-dark) !important;
}
.ms-header-theme-dark .header-topbar {
    background-color: #1e2022 !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}
.ms-header-theme-dark .topbar-right .sep {
    background: rgba(255,255,255,0.1) !important;
}
.ms-header-theme-dark .ms-block-menu .ms-navbar-list > li > a:not([class*="ms-btn"]) {
    color: var(--ms-color-white) !important;
}
.ms-header-theme-dark .ms-block-menu .ms-navbar-list > li > a:not([class*="ms-btn"]):hover {
    color: var(--ms-color-primary) !important;
}
.ms-header-theme-dark .ms-block-menu > .ms-navbar-btn a {
    color: var(--ms-color-white) !important;
    border-color: rgba(255,255,255,0.2) !important;
}
.ms-header-theme-dark .ms-block-menu > .ms-navbar-btn a:hover {
    background-color: rgba(255,255,255,0.05) !important;
}
.ms-header-theme-dark .topbar-inner .ms-block-text-editor p,
.ms-header-theme-dark .topbar-inner .ms-block-text-editor * {
    color: var(--ms-color-white) !important;
}

@media (max-width: 991px) {
    .ms-header-theme-dark .ms-block-menu .ms-navbar-list {
        background: var(--ms-color-dark) !important;
        border-top-color: rgba(255,255,255,0.1) !important;
    }
    .ms-header-theme-dark .ms-block-menu .ms-navbar-list > li {
        border-bottom-color: rgba(255,255,255,0.1) !important;
    }
    .ms-header-theme-dark .ms-block-menu .sub-menu {
        background-color: #1e2022 !important;
    }
}