/**
 * Header Behavior Styles
 * Smooth scroll effects with exact measurements
 *
 * @package Transtoyou
 */

/* ===========================
   CSS Variables
   =========================== */
:root {
    --header-top-height: 50px;
    --header-main-height: 82px;
    --nav-menu-height: 52px;
    --header-total-height: 184px; /* 50 + 82 + 52 */
    --header-scrollup-height: 134px; /* 82 + 52 */
    --header-scrolldown-height: 82px; /* only main */
    --header-transition: cubic-bezier(0.4, 0, 0.2, 1);
    --header-transition-duration: 0.3s;
}

/* ===========================
   Reset Body/HTML Margins
   =========================== */
html, body {
    margin: 0 !important;
    padding: 0 !important;
}

#page,
.site,
#masthead {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

@media (max-width: 768px) {
    #masthead {
        box-shadow: none !important;
    }
    
    body.scrolled.scrolling-up #masthead .tty-header-main {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }
}

/* ===========================
   Header Structure
   =========================== */

/* Main wrapper - with dynamic height */
.site-header {
    position: relative;
    width: 100%;
    z-index: 9999;
    transition: height var(--header-transition-duration) var(--header-transition);
    will-change: height;
    overflow: visible;
    margin-top: 0 !important;
}

/* Header wrapper - container for all header parts */
.tty-header-wrapper {
    position: relative;
    width: 100%;
    transition: height var(--header-transition-duration) var(--header-transition);
    will-change: height;
}


.tty-reviews-header-link {
transition: none;
animation: none;
}

/* Header placeholder - prevents content jump */
.header-placeholder {
    display: none;
    width: 100%;
    background-color: transparent;
    transition: none !important;
    margin: 0;
    padding: 0;
}

/* ===========================
   Header Components
   =========================== */

/* Top Bar - EXACTLY 50px */
.tty-header-top {
    position: relative;
    height: 50px;
    min-height: 50px;
    max-height: 50px;
    background: var(--tty-bg-linear-graniet);
    overflow: visible;
    transition: transform var(--header-transition-duration) var(--header-transition),
                opacity var(--header-transition-duration) var(--header-transition);
    will-change: transform, opacity;
    z-index: 1002;
}

/* Main Header - EXACTLY 82px */
.tty-header-main {
    position: relative;
    height: 82px;
    min-height: 82px;
    max-height: 82px;
    background: var(--tty-bg-primary);
    transition: transform var(--header-transition-duration) var(--header-transition),
                box-shadow var(--header-transition-duration) var(--header-transition);
    will-change: transform, box-shadow;
    z-index: 1001;
}

/* Navigation Menu - EXACTLY 52px */
.tty-nav-menu {
    position: relative;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    background: linear-gradient(to bottom, #f2f9f8 0%, #ffffff 100%);
    border-top: 1px solid rgba(0, 95, 95, 0.1);
    border-bottom: 1px solid rgba(0, 95, 95, 0.1);
    transition: transform var(--header-transition-duration) var(--header-transition),
                opacity var(--header-transition-duration) var(--header-transition);
    will-change: transform, opacity;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .tty-nav-menu {
    background: linear-gradient(to bottom, #222828 0%, #181818 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Container heights */
.tty-header-top .container {
    height: 50px;
    display: flex;
    align-items: center;
}

.tty-header-main .container {
    height: 82px;
    display: flex;
    align-items: center;
}

.tty-nav-menu .container {
    height: 52px;
    display: flex;
    align-items: center;
}

/* ===========================
   Desktop Selector Integration
   =========================== */

/* Ensure proper alignment in top bar */
.tty-header-top-right {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 100%;
}

/* Desktop selector positioning */
.tty-desktop-selector-wrapper {
    z-index: 1003;
    height: 32px;
}

/* Ensure selector is above other elements */
.tty-desktop-region-selector {
    position: relative;
    z-index: 10;
}

/* Prevent selector from being hidden during scroll */
body.scrolled .tty-desktop-selector-wrapper {
    opacity: 1;
    visibility: visible;
}

/* ===========================
   Scroll States - Desktop
   =========================== */

/* At top state - all visible */
body.at-top .site-header {
    position: relative !important;
    height: var(--header-total-height);
}

body.at-top .tty-header-wrapper {
    height: var(--header-total-height);
}

body.at-top .header-placeholder {
    display: none !important;
}

body.at-top .tty-header-top,
body.at-top .tty-header-main,
body.at-top .tty-nav-menu {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

body.at-top .tty-header-main {
    box-shadow: none;
    border-radius: 0px;
}

/* Initial state (not scrolled, not at-top) - all visible */
body:not(.scrolled):not(.at-top) .site-header {
    position: relative;
    height: var(--header-total-height);
}

body:not(.scrolled):not(.at-top) .tty-header-wrapper {
    height: var(--header-total-height);
}

body:not(.scrolled):not(.at-top) .header-placeholder {
    display: none !important;
}

body:not(.scrolled):not(.at-top) .tty-header-top,
body:not(.scrolled):not(.at-top) .tty-header-main,
body:not(.scrolled):not(.at-top) .tty-nav-menu {
    transform: translateY(0);
    opacity: 1;
}

/* Scrolled state - header becomes fixed */
body.scrolled .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}

body.scrolled .header-placeholder {
    display: block !important;
}

body .sb-main.sb-chat.sb-active .sb-icon.sb-icon-close.sb-responsive-close-btn {
  width: 40px;
  height: 40px;
  justify-content: center;
  background: rgb(234, 242, 242);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--tty-primary);
  display: flex !important;
  right: 20px;
  top: 15px;
  text-align: center;
  opacity: 1;
}

.sb-text {
  display: none;
}

.sb-header.sb-header-main.sb-header-type-minimal {
  padding: 0 20px 20px 20px;
}

@media (max-width: 786px) {
  body .sb-chat .sb-responsive-close-btn::before {
    font-size: 14px;
    line-height: 19px;
    z-index: 9;
    position: relative;
    top: 10.2px;
    right: 0.2px;
    color: #247772;
    font-weight: 900 !important;
  }
  body .sb-chat .sb-body .sb-scroll-area .sb-header-agent + .sb-list {
    min-height: calc(100% - 65px);
    padding-top: 65px;
    height: 100%;
  }
  
  body .sb-chat .sb-scroll-area .sb-header {
    box-shadow: 0 2px 1px rgba(0, 0, 0, 0.03);
    }
  
   body  .sb-chat .sb-header-agent .sb-profile .sb-name {
    font-size: 16px;
    color: var(--tty-header-primary);
  }
  
   body .sb-chat .sb-body .sb-scroll-area .sb-header-agent {
    background: var(--tty-bg-primary);
  }
   
   body .sb-status.sb-status-online {
       color: #6c757d !important;
    }
  
}


/* ===========================
   BELANGRIJKE FIX VOOR WITTE RUIMTE
   =========================== */

/* Scrolling down - only main header visible (82px) */
body.scrolled.scrolling-down .site-header {
    height: var(--header-scrolldown-height);
}

body.scrolled.scrolling-down .tty-header-wrapper {
    height: var(--header-scrolldown-height);
    margin-top: -50px; /* Trek omhoog om top bar ruimte te vullen */
}

body.scrolled.scrolling-down .header-placeholder {
    height: var(--header-scrolldown-height) !important;
}

body.scrolled.scrolling-down .tty-header-top {
    transform: translateY(0); /* Blijft op plaats */
    opacity: 0;
    pointer-events: none;
}

body.scrolled.scrolling-down .tty-header-main {
    transform: translateY(0); /* Blijft op plaats, wrapper trekt alles omhoog */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.scrolled.scrolling-down.admin-bar .tty-header-main {
    transform: translateY(32px); /* Blijft op plaats, wrapper trekt alles omhoog */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.scrolled.scrolling-down .tty-nav-menu {
    transform: translateY(0) !important; /* Blijft op plaats */
    opacity: 0 !important;
    pointer-events: none;
}

/* Keep nav menu visible when a mega menu is active during scroll down */
body.scrolled.scrolling-down .tty-nav-menu:has(.mega-menu-active) {
    opacity: 1 !important;
    pointer-events: auto !important;
}

body.scrolled.scrolling-down:has(.mega-menu-active) .site-header {
    height: var(--header-scrollup-height);
}

body.scrolled.scrolling-down:has(.mega-menu-active) .tty-header-wrapper {
    height: var(--header-scrollup-height);
    margin-top: -50px;
}

body.scrolled.scrolling-down:has(.mega-menu-active) .header-placeholder {
    height: var(--header-scrollup-height) !important;
}

/* Scrolling up - main header + nav menu visible (134px) */
body.scrolled.scrolling-up .site-header {
    height: var(--header-scrollup-height);
}

body.scrolled.scrolling-up .tty-header-wrapper {
    height: var(--header-scrollup-height);
    margin-top: -50px; /* Trek omhoog om top bar ruimte te vullen */
}

body.scrolled.scrolling-up .header-placeholder {
    height: var(--header-scrollup-height) !important;
}

body.scrolled.scrolling-up .tty-header-top {
    transform: translateY(0) !important; /* Blijft op plaats */
    opacity: 0;
    pointer-events: none;
}

body.scrolled.scrolling-up .tty-header-main {
    transform: translateY(0); /* Blijft op plaats, wrapper trekt alles omhoog */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.scrolled.scrolling-up .tty-nav-menu {
    transform: translateY(0) ; /* Blijft op plaats, wrapper trekt alles omhoog */
    opacity: 1;
    pointer-events: auto;
}

/* ===========================
   Page Load State
   =========================== */

/* Prevent transitions during initial load */
body.initial-load {
    overflow-x: hidden;
}

body.initial-load .site-header,
body.initial-load .site-header * {
    transition: none !important;
}

body.initial-load.scrolled .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

body.initial-load.scrolled .header-placeholder {
    display: block !important;
}

/* Initial load - scrolled down */
body.initial-load.scrolled.scrolling-down .site-header {
    height: var(--header-scrolldown-height);
}

body.initial-load.scrolled.scrolling-down .tty-header-wrapper {
    height: var(--header-scrolldown-height);
    margin-top: -50px;
}

body.initial-load.scrolled.scrolling-down .header-placeholder {
    height: var(--header-scrolldown-height) !important;
}

body.initial-load.scrolled.scrolling-down .tty-header-top {
    transform: translateY(0);
    opacity: 0;
}

body.initial-load.scrolled.scrolling-down .tty-header-main {
    transform: translateY(0);
}

body.initial-load.scrolled.scrolling-down .tty-nav-menu {
    transform: translateY(0);
    opacity: 0;
}

/* Initial load - scrolled up */
body.initial-load.scrolled.scrolling-up .site-header {
    height: var(--header-scrollup-height);
}

body.initial-load.scrolled.scrolling-up .tty-header-wrapper {
    height: var(--header-scrollup-height);
    margin-top: -50px;
}

body.initial-load.scrolled.scrolling-up .header-placeholder {
    height: var(--header-scrollup-height) !important;
}

body.initial-load.scrolled.scrolling-up .tty-header-top {
    transform: translateY(0);
    opacity: 0;
}

body.initial-load.scrolled.scrolling-up .tty-header-main {
    transform: translateY(0);
}

body.initial-load.scrolled.scrolling-up .tty-nav-menu {
    transform: translateY(0);
    opacity: 1;
}

/* Initial load - at top */
body.initial-load.at-top .site-header {
    position: relative !important;
    height: var(--header-total-height);
}

body.initial-load.at-top .tty-header-wrapper {
    height: var(--header-total-height);
    margin-top: 0;
}

body.initial-load.at-top .header-placeholder {
    display: none !important;
}

body.initial-load.at-top .tty-header-top,
body.initial-load.at-top .tty-header-main,
body.initial-load.at-top .tty-nav-menu {
    transform: translateY(0);
    opacity: 1;
}

/* ===========================
   Logo Scaling
   =========================== */

.tty-logo-wrapper {
  width: 240px;
}

.tty-logo-wrapper img {
    height: 68px;
    max-height: 68px;
    width: auto;
    transition: all var(--header-transition-duration) var(--header-transition) !important;
    justify-content: center;
    display: flex;
    margin-bottom: -2px;
    width: 235px;
}


.tty-logo-wrapper:hover img {
    transform: scale(1.05);
}

body.scrolled .tty-logo-wrapper img {
    height: 58px;
    max-height: 58px;
    width: 200.44px;
}

/* ===========================
   Back to Top Button
   =========================== */

.transtoyou-back-to-top {
    position: fixed;
    bottom: 20px;
    right: 88px;
    width: 50px;
    height: 50px;
    background: var(--tty-bg-linear-graniet);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    -webkit-tap-highlight-color: transparent;
}

.transtoyou-back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.transtoyou-back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.transtoyou-back-to-top i {
    font-size: 20px;
}

.transtoyou-back-to-top:focus {
    outline: 2px solid var(--tty-primary);
    outline-offset: 2px;
}

.transtoyou-back-to-top.is-animating {
    pointer-events: none;
}

/* Smooth transition during animation */
body.transtoyou-animating-to-top .site-header,
body.transtoyou-animating-to-top .tty-header-wrapper {
    transition: none !important;
}

/* ===========================
   Performance Optimizations
   =========================== */

/* Prevent layout shift */
.tty-header-top,
.tty-header-main,
.tty-nav-menu {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Hardware acceleration */
.site-header {
    transform: translateZ(0);
    will-change: position, height;
}

/* Smooth scrolling for modern browsers */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ===========================
   Mobile Header Animation
   =========================== */

/* No keyframes needed - using transition instead */

/* ===========================
   Mobile Adjustments - UPDATED FOR HIDE/SHOW
   =========================== */

@media (max-width: 768px) {
    :root {
        --header-main-height: 65px;
        --header-total-height: 65px;
        --header-scrolldown-height: 0px; /* Hidden when scrolling down */
        --header-scrollup-height: 65px;
        --header-transition-duration: 0.25s;
    }
    
     body .sb-chat .sb-body .sb-scroll-area .sb-header-agent {
        padding: 15px 15px;
    }
    
    /* Hide top bar and nav menu on mobile */
    .tty-header-top,
    .tty-nav-menu {
        display: none !important;
    }
    
    /* Adjust main header height */
    .tty-header-main {
        height: 65px;
        min-height: 65px;
        max-height: 65px;
    }
    
    body.scrolled.scrolling-up .tty-header-main {
        border-radius: 0px 0px 24px 24px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .tty-logo-wrapper:hover img {
        transform: none;
    }
    
    .tty-header-main .container {
        height: 65px;
    }
    
    /* Mobile at-top state */
    body.at-top .site-header {
        height: 65px !important;
    }
    
    body.at-top .tty-header-wrapper {
        height: 65px !important;
        margin-top: 0 !important;
    }
    
    /* site-header is transparent container */
    body.scrolled .site-header {
        height: 65px !important;
        overflow: visible;
    }

    /* Mobile scroll states - HIDE ON SCROLL DOWN */
    body.scrolled.scrolling-down .site-header {
        display: none !important;
    }
    
    body.scrolled.scrolling-down .tty-header-wrapper {
        display: none !important;
    }
    
    body.scrolled.scrolling-down .tty-header-main {
        display: none !important;
    }
    
    /* Mobile scroll states - SHOW ON SCROLL UP */
    body.scrolled.scrolling-up .site-header {
        height: 65px !important;
    }
    
    body.scrolled.scrolling-up .tty-header-wrapper {
        height: 65px !important;
        margin-top: 0 !important;
    }
    
    body.scrolled.scrolling-up .tty-header-main {
        transform: translateY(0);
    }
    
   /* iOS Safe Area - no fix needed, display:none removes element completely */
    
    /* ===========================
       Mobile Placeholder Fix
       =========================== */
    
    /* Override global desktop rule that sets placeholder to 0px on mobile */
    body.scrolled .header-placeholder,
    body.scrolled.scrolling-down .header-placeholder,
    body.scrolled.scrolling-up .header-placeholder {
        display: block !important;
        height: 65px !important;
    }
    
    /* Logo adjustments */
    body .tty-logo-wrapper img {
        height: 60px;
        max-height: 60px;
        margin-bottom: 0px;
        width: 212px;
        margin-left: -3px;
    }
    
     body.scrolled .tty-logo-wrapper img {
        height: 50px !important;
        max-height: 50px !important;
        width: 172.80px !important;
        margin-bottom: 0px;
    }
    
    /* Adjust back to top button */
    .transtoyou-back-to-top {
        bottom: 129px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    
    .transtoyou-back-to-top i {
        font-size: 18px;
    }
}

/* ===========================
   WordPress Admin Bar
   =========================== */

body.admin-bar .site-header.scrolled {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .site-header.scrolled {
        top: 46px;
    }
}

/* ===========================
   Accessibility
   =========================== */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    :root {
        --header-transition-duration: 0.01ms;
    }
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ===========================
   Dark Mode Support
   =========================== */

[data-theme="dark"] .tty-header-main {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] body.scrolled .tty-header-main {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .transtoyou-back-to-top {
    background: var(--tty-primary-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ===========================
   Safari Specific Fixes
   =========================== */

@supports (-webkit-overflow-scrolling: touch) {
    .site-header {
        -webkit-transform: translateZ(0);
    }
    
    .tty-header-top,
    .tty-header-main,
    .tty-nav-menu {
        -webkit-backface-visibility: hidden;
        -webkit-transform-style: preserve-3d;
    }
}

/* ===========================
   Cart Icon Fixes
   =========================== */

.tty-header-icon.tty-cart-icon svg {
    width: 28px;
    height: 26px;
}

.tty-header-icon.tty-cart-icon svg path {
    fill: #005F5F !important
}

.tty-header-icon.tty-cart-icon:hover svg path {
    fill: #fff !important;
}

/* ===========================
   Select2 Dropdown Support
   =========================== */

.tty-header-top .select2-container {
    z-index: 1003;
}

.tty-header-top .select2-dropdown {
    z-index: 10000 !important;
}

  body .sb-chat-btn {
    background: var(--tty-bg-linear-graniet);
  }
  
      body .sb-user-conversations > li > [data-count] {
        background: var(--tty-secondary);
        color: var(--tty-text-light);
        left: 50px;
        top: 35px;
        line-height: 20px;
    }
    
@media (min-width: 768px) {
  body .sb-chat-btn {
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--tty-bg-linear-graniet);
  }
  
  body .sb-main.sb-chat.sb-active .sb-icon.sb-icon-close.sb-responsive-close-btn {
   display: none !important;
}

body .sb-icon-close.sb-dashboard-btn {
  display: none !important;
}

  body .sb-icon.sb-icon-close.sb-responsive-close-btn:hover {
  color: #d44646 !important;
  transform: rotate(90deg);
}
  
  body .sb-chat-btn span {
    text-align: center;
    line-height: 22px;
    z-index: 2;
    animation: sb-fade-animation 0.3s;
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--tty-secondary);
    color: var(--tty-text-light);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Figtree', sans-serif;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    left: auto;
    }
    
    
  body .sb-chat-btn img {
    width: 50px;
    height: 50px;
    }
}
