/* =============================================
   SHARED HEADER - Single source of truth
   Extracted from index.html (homepage)
   ALL pages must load this file for consistent nav
   ============================================= */

/* Prevent any element from widening the page and shrinking the header */
html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
}

@supports (overflow: clip) {
    html, body {
        overflow-x: clip !important;
    }
}

/* ===== HEADER ===== */
.header {
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    padding: 0 !important;
}

.header .container {
    padding: 0 20px !important;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-img {
    height: 110px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

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

.nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
}

.nav > a:not(.btn-phone):not(.nav-cart),
.nav .nav-login,
.nav .nav-wholesale,
.nav-item {
    color: var(--dark, #0a1612) !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    transition: color 0.3s ease !important;
    position: relative !important;
    cursor: pointer;
    white-space: nowrap !important;
    padding: 0 !important;
    display: inline !important;
    line-height: 1.6 !important;
    min-width: 0 !important;
    min-height: 0 !important;
}

.nav a:hover, .nav-item:hover {
    color: var(--toledo-green, #008b44);
}

.nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--toledo-green, #008b44);
    transition: width 0.3s ease;
}

.nav a:hover::after {
    width: 100%;
}

/* ===== HEADER BUTTONS ===== */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-login {
    background: none;
    border: 2px solid var(--toledo-green, #008b44);
    color: var(--toledo-green, #008b44);
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-login:hover {
    background: var(--toledo-green, #008b44);
    color: white;
}

.nav .btn-phone,
a.btn-phone {
    background: var(--toledo-green, #008b44) !important;
    color: white !important;
    padding: 10px 22px !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    box-shadow: 0 4px 12px rgba(71, 158, 82, 0.3) !important;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    gap: 8px !important;
    transition: all 0.3s ease !important;
    line-height: normal !important;
}

.btn-phone::after { display: none; }
.btn-phone svg,
a.btn-phone svg {
    color: white !important;
    fill: white !important;
}
a.btn-phone,
a.btn-phone:visited,
a.btn-phone:link {
    color: white !important;
}

.btn-phone:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(71, 158, 82, 0.4);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--dark, #0a1612);
    padding: 4px;
}

/* ===== SHOP DROPDOWN ===== */
.shop-dropdown-wrap { position: relative; }
.shop-dropdown-btn {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700; color: var(--dark, #0a1612); padding: 6px 14px;
    cursor: pointer; background: none; border: 2px solid transparent; font-size: 14px; font-family: inherit;
    border-radius: 8px; transition: all 0.2s ease;
    line-height: 1.6;
    white-space: nowrap;
}
.shop-dropdown-btn:hover {
    background: #f0fdf4; border-color: rgba(0,139,68,0.15); color: var(--toledo-green, #008b44);
}
.shop-dropdown-btn svg { transition: transform 0.25s ease; }
.shop-dropdown-wrap:hover .shop-dropdown-btn svg { transform: rotate(180deg); }
.shop-dropdown-wrap:hover .shop-dropdown-btn {
    background: #f0fdf4; border-color: rgba(0,139,68,0.15); color: var(--toledo-green, #008b44);
}
.shop-mega {
    position: absolute; top: calc(100% + 8px); left: -20px;
    width: 740px; max-width: 95vw;
    background: #fff; border-radius: 16px;
    box-shadow: 0 25px 65px rgba(0,0,0,0.15), 0 8px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    display: none; flex-direction: row; z-index: 1001;
    overflow: hidden;
    animation: megaFadeIn 0.2s ease;
}
@keyframes megaFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.shop-dropdown-wrap::after {
    content: ''; position: absolute; top: 100%; left: 0;
    width: 100%; height: 14px; display: none;
}
.shop-dropdown-wrap:hover::after { display: block; }
.shop-dropdown-wrap:hover .shop-mega { display: flex !important; }

/* Left column: category list */
.mega-categories {
    width: 260px; min-width: 260px;
    border-right: 1px solid #f0f0f0;
    padding: 12px 0;
    background: linear-gradient(180deg, #f8faf8 0%, #f2f5f2 100%);
    flex-shrink: 0;
    display: flex; flex-direction: column;
}
.mega-cat {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 20px; color: #444; text-decoration: none;
    font-size: 13.5px; font-weight: 600;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    gap: 8px;
}
.mega-cat span { flex: 1; }
.mega-cat::after { display: none !important; }
.mega-cat svg { width: 14px; height: 14px; opacity: 0; transition: all 0.2s ease; flex-shrink: 0; transform: translateX(-4px); }
.mega-cat:hover, .mega-cat.active {
    background: #fff; color: var(--toledo-green, #008b44);
    border-left-color: var(--toledo-green, #008b44);
    padding-left: 24px;
}
.mega-cat:hover svg, .mega-cat.active svg { opacity: 0.6; transform: translateX(0); }

/* Right column: subcategories */
.mega-subcategories {
    flex: 1; padding: 24px 28px; min-height: 420px;
    position: relative; overflow-y: auto;
    background: #fff;
}
.subcat-panel { display: none; }
.subcat-panel.active { display: block; animation: subFadeIn 0.15s ease; }
@keyframes subFadeIn { from { opacity: 0; } to { opacity: 1; } }
.subcat-panel h3 {
    font-size: 16px; font-weight: 800; color: var(--dark, #0a1612);
    margin: 0 0 16px; padding-bottom: 12px;
    border-bottom: 2px solid var(--toledo-green, #008b44);
    letter-spacing: -0.01em;
}
.subcat-panel ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
.subcat-panel ul li { break-inside: avoid; }
.subcat-panel ul a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; margin: 2px 0; color: #555; font-size: 13.5px;
    font-weight: 500; text-decoration: none; border-radius: 8px;
    transition: all 0.15s ease;
}
.subcat-panel ul a::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: #d1d5db; flex-shrink: 0; transition: all 0.15s ease;
}
.subcat-panel ul a::after { display: none !important; }
.subcat-panel ul a:hover {
    color: var(--toledo-green, #008b44); background: #f0fdf4;
    padding-left: 14px;
}
.subcat-panel ul a:hover::before { background: var(--toledo-green, #008b44); transform: scale(1.3); }
.subcat-panel .view-all {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 20px; padding: 10px 18px; font-size: 13px;
    font-weight: 700; color: #fff; text-decoration: none;
    background: var(--toledo-green, #008b44); border-radius: 8px;
    transition: all 0.2s ease;
}
.subcat-panel .view-all:hover { background: #006d35; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,139,68,0.3); }
.subcat-panel .view-all::after { display: none !important; }

/* ===== NAV CART ===== */
.nav .nav-cart,
a.nav-cart,
a.nav-cart:visited,
a.nav-cart:link,
a.nav-cart:active {
    position: relative !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    min-width: 0 !important;
    min-height: 0 !important;
    color: #008b44 !important;
}
.nav-cart svg,
a.nav-cart svg,
a.nav-cart:visited svg,
a.nav-cart:link svg {
    color: #008b44 !important;
    fill: none !important;
    stroke: #008b44 !important;
}
.nav-cart::after { display: none !important; }
.cart-count {
    position: absolute; top: -8px; right: -8px; background: var(--toledo-green, #008b44);
    color: white; font-size: 11px; font-weight: 700; width: 18px; height: 18px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* ===== SITE SEARCH ===== */
.site-search-wrap { position: relative; }
.site-search-form { display: flex; align-items: center; background: var(--gray-100, #f3f4f6); border: 2px solid transparent; border-radius: 50px; overflow: hidden; transition: border-color 0.2s, box-shadow 0.2s; }
.site-search-form:focus-within { border-color: var(--toledo-green, #008b44); box-shadow: 0 0 0 3px rgba(71,158,82,0.15); background: #fff; }
#site-search-input { border: none; background: transparent; padding: 9px 16px; font-size: 14px; font-family: inherit; width: 200px; outline: none; color: var(--dark, #0a1612); }
#site-search-input:focus,
#site-search-input:focus-visible { border-color: transparent !important; box-shadow: none !important; outline: none !important; }
#site-search-input::placeholder { color: var(--gray-300, #d1d5db); }
.site-search-btn { background: none; border: none; padding: 8px 14px 8px 0; cursor: pointer; color: var(--gray-300, #d1d5db); display: flex; align-items: center; }
.site-search-btn:focus,
.site-search-btn:focus-visible { box-shadow: none !important; outline: none !important; }
.site-search-form:focus-within .site-search-btn { color: var(--toledo-green, #008b44); }
#site-search-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 420px; max-width: 95vw; max-height: 500px; overflow-y: auto; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05); z-index: 10001; pointer-events: auto; }
#site-search-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.15); z-index: 999; }
.ss-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; color: var(--dark, #0a1612); border-bottom: 1px solid var(--gray-100, #f3f4f6); transition: background 0.15s; cursor: pointer; min-height: 44px; }
.ss-item:hover, .ss-item.active { background: #f8faf8; }
.ss-thumb { width: 50px; height: 50px; border-radius: 6px; object-fit: contain; background: var(--gray-100, #f3f4f6); flex-shrink: 0; }
.ss-no-img { display: flex; align-items: center; justify-content: center; }
.ss-info { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.ss-info:hover .ss-name { color: var(--toledo-green, #008b44); }
.ss-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-name mark { background: rgba(71,158,82,0.2); padding: 1px 2px; border-radius: 2px; }
.ss-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--gray-300, #d1d5db); }
.ss-price { font-weight: 700; color: var(--toledo-green, #008b44); }
.ss-add-cart { background: var(--toledo-green-dark, #006d35); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: background 0.15s; pointer-events: auto; touch-action: manipulation; -webkit-tap-highlight-color: transparent; position: relative; z-index: 2; min-height: 32px; }
.ss-add-cart:hover { background: var(--toledo-green-dark, #006d35); }
.ss-add-cart.added { background: var(--toledo-green, #008b44); }
.ss-add-short { display: none; }
.ss-view-all { display: block; text-align: center; padding: 14px; font-weight: 700; font-size: 14px; color: var(--toledo-green, #008b44); text-decoration: none; border-top: 1px solid var(--gray-200, #e5e7eb); }
.ss-view-all:hover { background: #f0fdf4; }
.ss-no-results { padding: 24px; text-align: center; color: var(--gray-300, #d1d5db); font-size: 14px; }
.ss-typo-hint { padding: 8px 16px; font-size: 12px; color: #666; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .shop-mega { width: 580px; }
    .mega-categories { width: 220px; min-width: 220px; }
    .subcat-panel ul { columns: 1; }
}

@media (max-width: 1024px) {
    .nav { gap: 10px; }
    .nav > a:not(.btn-phone):not(.nav-cart),
    .nav .nav-login,
    .nav .nav-wholesale,
    .shop-dropdown-btn { font-size: 13px !important; }
    #site-search-input { width: 140px; }
    .btn-phone { padding: 8px 14px !important; font-size: 12px !important; }
    .btn-phone span, .btn-phone .phone-text { display: none; }
}

@media (max-width: 768px) {
    html.site-search-active,
    body.site-search-active {
        overflow: hidden !important;
        height: 100% !important;
        overscroll-behavior: none !important;
    }

    body.site-search-active .tg-chat-btn {
        display: none !important;
    }

    .site-search-wrap,
    .site-search-form {
        min-width: 0;
        max-width: 100%;
    }

    #site-search-input,
    .nav .site-search-wrap input#site-search-input {
        font-size: 16px !important;
        line-height: 1.2;
    }

    #site-search-dropdown {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 72px;
        width: auto;
        max-width: calc(100vw - 16px);
        max-height: min(68vh, 560px);
        border-radius: 12px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
        z-index: 10050;
    }

    .ss-item {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 78px;
        gap: 8px;
        align-items: center;
        padding: 10px;
        min-width: 0;
    }

    .ss-thumb {
        width: 44px;
        height: 44px;
    }

    .ss-info {
        min-width: 0;
    }

    .ss-meta {
        flex-wrap: wrap;
        gap: 4px 8px;
    }

    .ss-add-cart {
        padding: 7px 9px;
        font-size: 11px;
        width: 78px;
        min-height: 36px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ss-add-full { display: none; }
    .ss-add-short { display: inline; }
}

@media (max-width: 420px) {
    #site-search-dropdown {
        left: 6px;
        right: 6px;
        max-width: calc(100vw - 12px);
    }

    .ss-item {
        grid-template-columns: 40px minmax(0, 1fr) 76px;
        gap: 7px;
    }

    .ss-thumb {
        width: 40px;
        height: 40px;
    }

    .ss-name {
        font-size: 13px;
    }

    .ss-meta {
        font-size: 11px;
    }

    .ss-add-cart {
        width: 76px;
        padding: 7px 6px;
    }
}

/* Narrow desktop / vertical monitors — switch to mobile layout */
@media (max-width: 1280px) {
  /* Hide the full nav by default on mobile */
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    flex-direction: column;
    padding: 16px;
  }

  /* When nav is toggled open */
  .nav.mobile-open {
    display: flex;
  }

  /* Nav links stack vertically when open */
  .nav > a,
  .nav .nav-link-login {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: 16px;
  }

  /* Hide the shop dropdown complex menu on mobile, show simple link */
  .nav .shop-dropdown-wrap {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
  }
  .nav .shop-dropdown-wrap .shop-dropdown {
    display: none;
  }

  /* Search bar in mobile menu */
  .nav .site-search-wrap {
    width: 100%;
    margin: 12px 0;
    order: -1;
  }
  .nav .site-search-wrap .site-search-form {
    width: 100%;
  }
  .nav .site-search-wrap input {
    width: 100%;
  }

  /* Hide phone button on mobile (number is in footer) */
  .nav .btn-phone {
    display: none;
  }

  /* Show hamburger */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 4px;
    order: 3;
  }

  /* Header content layout */
  .header-content {
    position: relative;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Logo sizing */
  .logo {
    max-width: 160px;
    flex-shrink: 0;
  }
  .logo-img {
    max-height: 64px;
    width: auto;
  }

  /* Hamburger must never shrink or get pushed off */
  .mobile-menu-btn {
    flex-shrink: 0 !important;
    margin-left: 8px;
  }
}


/* ─── Structured Mobile Nav Menu ─────────────────────────────── */
.mobile-nav {
  display: block;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 1001;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}
.mobile-nav-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.mobile-nav-quick a {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1.5px solid #bbf0c4;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  color: #1B3B17;
  text-decoration: none;
}
.mobile-nav-quick a svg { flex-shrink: 0; }
.mobile-nav-label {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mobile-nav-cats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-bottom: 12px;
}
.mobile-nav-cats a {
  padding: 9px 10px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-radius: 6px;
  display: block;
}
.mobile-nav-cats a:active { background: #f3f4f6; }
.mobile-nav-bottom {
  border-top: 1px solid #f0f0f0;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-nav-bottom a {
  padding: 9px 10px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-radius: 6px;
  display: block;
}

@media (max-width: 600px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .header .container {
    padding: 0 12px !important;
  }

  .header-content {
    min-height: 62px;
    padding: 7px 0 !important;
  }

  .logo {
    max-width: 126px;
  }

  .logo-img {
    max-height: 52px !important;
  }

  .mobile-menu-btn {
    width: 38px;
    height: 38px;
    margin-left: 4px;
    padding: 0;
    font-size: 25px;
    line-height: 1;
  }

  .nav-cart svg,
  a.nav-cart svg {
    width: 24px !important;
    height: 24px !important;
  }

  .cart-count {
    width: 17px;
    height: 17px;
    font-size: 10px;
    top: -7px;
    right: -8px;
  }

  .site-search-form {
    min-height: 42px;
    border-radius: 22px;
  }

  #site-search-input {
    height: 38px;
    padding: 7px 12px;
    font-size: 16px !important;
  }

  .site-search-btn {
    padding: 7px 12px 7px 0;
  }

  .site-search-btn svg {
    width: 18px;
    height: 18px;
  }

  #site-search-dropdown {
    top: 64px;
  }
}

@media (max-width: 360px) {
  .header .container {
    padding: 0 10px !important;
  }

  .logo {
    max-width: 112px;
  }

  .logo-img {
    max-height: 46px !important;
  }

  .mobile-menu-btn {
    width: 34px;
    height: 34px;
    font-size: 23px;
  }
}
