/*
 * Leibal Mobile Header CSS - Exact Store Design
 * Version: 1.0.0
 * 
 * Точная копия мобильного хедера с https://store.leibal.com
 * Включает иконки корзины и пользователя из оригинального дизайна
 */

/* =============================================================================
   CSS CUSTOM PROPERTIES
============================================================================= */

:root {
  --mobile-header-height: 60px;
  --mobile-menu-width: 280px;
  --mobile-animation-speed: 0.3s;
  --mobile-overlay-opacity: 0.5;
  --leibal-primary: #484634;
  --mobile-breakpoint: 768px;
}

/* =============================================================================
   MOBILE HEADER BASE
============================================================================= */

/* Hide mobile navigation on desktop */
.mobile-nav {
  display: none;
}

/* Base mobile header positioning */
@media (max-width: 768px) {
  /* Ensure header is fixed and on top */
  .header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    height: var(--mobile-header-height);
  }
  
  /* Adjust body for fixed header */
  body {
    padding-top: var(--mobile-header-height);
  }
  
  /* Admin bar adjustments */
  .admin-bar .header {
    top: 46px;
  }
  
  .admin-bar body {
    padding-top: calc(var(--mobile-header-height) + 46px);
  }
  
  /* Hide desktop nav, show mobile nav */
  .desktop-nav {
    display: none !important;
  }
  
  .mobile-nav {
    display: block;
    width: 100%;
    height: 100%;
  }
  
  /* Override container styles for mobile */
  .header .container {
    padding: 0;
    max-width: 100%;
    height: 100%;
  }
}

/* =============================================================================
   MOBILE NAVIGATION LAYOUT
============================================================================= */

@media (max-width: 768px) {
  .mobile-nav-container {
    display: grid;
    grid-template-columns: 44px 1fr 100px;
    align-items: center;
    height: var(--mobile-header-height);
    padding: 0 20px;
    gap: 16px;
    position: relative;
  }
  
  /* Mobile menu button positioning - FIXED */
  .mobile-menu-btn {
    justify-self: start;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    position: relative;
    transition: all 0.2s ease;
    border-radius: 4px;
  }
  
  .mobile-menu-btn:hover {
    background: rgba(0, 0, 0, 0.05);
  }
  
  /* Hamburger icon from Leibal */
  .hamburger-icon {
    width: 20px;
    height: 20px;
    display: block !important;
    filter: brightness(0) saturate(100%); /* Make icon black */
    opacity: 0.8;
    transition: all var(--mobile-animation-speed) ease;
  }
  
  .mobile-menu-btn:hover .hamburger-icon {
    opacity: 1;
  }
  
  /* Hide hamburger icon when menu is open */
  .mobile-menu-btn.active .hamburger-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0.8);
  }
  
  /* Show close icon when menu is active */
  .mobile-menu-btn.active::after {
    content: '×';
    position: absolute;
    font-size: 24px;
    font-weight: 300;
    color: #000;
    line-height: 1;
    opacity: 1;
    transition: all var(--mobile-animation-speed) ease;
    font-family: 'Helvetica Neue', sans-serif;
  }
  
  /* Mobile logo centered */
  .mobile-logo {
    justify-self: center;
    font-family: 'Maison Neue', sans-serif;
    font-size: 15px;
    font-weight: 100;
    text-decoration: none;
    color: #000;
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1;
    transition: opacity 0.2s ease;
  }
  
  .mobile-logo:hover {
    opacity: 0.6;
  }
  
  /* Mobile right icons */
  .mobile-nav-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
  }
}

/* =============================================================================
   MOBILE ICON BUTTONS
============================================================================= */

@media (max-width: 768px) {
  .mobile-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #000;
    position: relative;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }
  
  .mobile-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 0.8;
  }
  
  .mobile-icon-btn:active {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
  }
  
  .mobile-icon-btn img,
  .mobile-icon-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none;
  }
  
  /* Specific styling for Leibal icons */
  .mobile-user-btn img,
  .mobile-cart-btn img {
    filter: brightness(0) saturate(100%); /* Make icons black */
    opacity: 0.8;
    transition: opacity 0.2s ease;
  }
  
  .mobile-user-btn:hover img,
  .mobile-cart-btn:hover img {
    opacity: 1;
  }
}

/* =============================================================================
   MOBILE CART COUNT BADGE
============================================================================= */

@media (max-width: 768px) {
  .mobile-cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #000;
    color: white;
    font-size: 9px;
    font-weight: 500;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Maison Neue', sans-serif;
    letter-spacing: 0;
    line-height: 1;
    padding: 0 2px;
    box-sizing: border-box;
    z-index: 1;
  }
  
  /* Hide count when zero or empty */
  .mobile-cart-count:empty,
  .mobile-cart-count[data-count="0"] {
    display: none;
  }
  
  /* Animation for count updates */
  .mobile-cart-count.updated {
    animation: cartBounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  }
  
  @keyframes cartBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
  }
}

/* =============================================================================
   MOBILE MENU OVERLAY
============================================================================= */

.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, var(--mobile-overlay-opacity));
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all var(--mobile-animation-speed) ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* =============================================================================
   MOBILE MENU SLIDE-OUT
============================================================================= */

.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--mobile-menu-width);
  height: 100%;
  background: white;
  z-index: 999;
  transform: translate3d(-100%, 0, 0);
  transition: transform var(--mobile-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
  will-change: transform;
}

.mobile-menu.active {
  transform: translate3d(0, 0, 0);
}

/* =============================================================================
   MOBILE MENU HEADER
============================================================================= */

@media (max-width: 768px) {
  .mobile-menu-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    min-height: var(--mobile-header-height);
    background: white;
    position: sticky;
    top: 0;
    z-index: 1001;
  }
  
  .mobile-menu-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #000;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-menu-close:hover {
    background: rgba(0, 0, 0, 0.05);
  }
  
  .mobile-menu-close svg {
    width: 20px;
    height: 20px;
  }
}

/* =============================================================================
   MOBILE MENU CONTENT
============================================================================= */

@media (max-width: 768px) {
  .mobile-menu-content {
    padding: 0;
  }
  
  .mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  .mobile-menu-list > li {
    border-bottom: 1px solid #f0f0f0;
    position: relative;
  }
  
  .mobile-menu-list > li:last-child {
    border-bottom: none;
  }
  
  .mobile-menu-list > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    text-decoration: none;
    color: #000;
    font-family: 'Maison Neue', sans-serif;
    font-size: 16px;
    font-weight: 100;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    line-height: 1.2;
    position: relative;
    background: white;
  }
  
  .mobile-menu-list > li > a:hover {
    background: #f8f8f8;
  }
  
  .mobile-menu-list > li > a:active {
    background: #f0f0f0;
  }
}

/* =============================================================================
   MOBILE MENU DROPDOWNS
============================================================================= */

@media (max-width: 768px) {
  .mobile-menu-dropdown {
    position: relative;
  }
  
  .mobile-dropdown-toggle {
    cursor: pointer;
  }
  
  .mobile-dropdown-arrow {
    font-size: 18px;
    font-weight: 300;
    transition: transform var(--mobile-animation-speed) ease;
    color: #666;
  }
  
  .mobile-menu-dropdown.open .mobile-dropdown-arrow {
    transform: rotate(90deg);
    color: #000;
  }
  
  .mobile-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f8f8f8;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--mobile-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid #e0e0e0;
  }
  
  .mobile-menu-dropdown.open .mobile-submenu {
    max-height: 500px;
  }
  
  .mobile-submenu li {
    border-bottom: 1px solid #e0e0e0;
  }
  
  .mobile-submenu li:last-child {
    border-bottom: none;
  }
  
  .mobile-submenu a {
    display: block;
    padding: 16px 20px 16px 40px;
    text-decoration: none;
    color: #666;
    font-family: 'Maison Neue', sans-serif;
    font-size: 14px;
    font-weight: 100;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    line-height: 1.2;
    position: relative;
    background: #f8f8f8;
  }
  
  .mobile-submenu a::before {
    content: '—';
    color: #ccc;
    margin-right: 8px;
    font-size: 12px;
    position: absolute;
    left: 20px;
  }
  
  .mobile-submenu a:hover {
    color: #000;
    background: #efefef;
  }
  
  .mobile-submenu a:active {
    background: #e8e8e8;
  }
}

/* =============================================================================
   SEARCH BAR MOBILE ADJUSTMENTS - HIDDEN ON MOBILE
============================================================================= */

/* Hide search completely on mobile */
@media (max-width: 768px) {
  .search-bar,
  #searchBar {
    display: none !important;
    visibility: hidden !important;
  }
  
  /* Hide desktop search button */
  .nav-item.black,
  .mobile-search-btn {
    display: none !important;
  }
  
  /* Ensure search overlay doesn't interfere */
  .search-bar.active {
    display: none !important;
  }
}

/* =============================================================================
   SCROLL LOCK WHEN MENU IS OPEN
============================================================================= */

body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* =============================================================================
   RESPONSIVE BREAKPOINTS
============================================================================= */

/* Large mobile screens (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .mobile-nav-container {
    padding: 0 24px;
    grid-template-columns: 48px 1fr 140px;
  }
  
  .mobile-nav-right {
    gap: 20px;
  }
  
  .mobile-icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .mobile-menu-list > li > a {
    padding: 22px 24px;
    font-size: 17px;
  }
  
  .mobile-submenu a {
    padding: 18px 24px 18px 44px;
    font-size: 15px;
  }
}

/* Small mobile screens (max 480px) */
@media (max-width: 480px) {
  .mobile-nav-container {
    padding: 0 16px;
    grid-template-columns: 40px 1fr 110px;
    gap: 12px;
  }
  
  .mobile-logo {
    font-size: 13px;
  }
  
  .mobile-nav-right {
    gap: 12px;
  }
  
  .mobile-icon-btn {
    width: 28px;
    height: 28px;
    padding: 4px;
  }
  
  .mobile-icon-btn img,
  .mobile-icon-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .mobile-cart-count {
    font-size: 8px;
    min-width: 14px;
    height: 14px;
    top: 1px;
    right: 1px;
  }
  
  .mobile-menu {
    width: 260px;
  }
  
  .mobile-menu-list > li > a {
    padding: 18px;
    font-size: 15px;
  }
  
  .mobile-submenu a {
    padding: 14px 18px 14px 36px;
    font-size: 13px;
  }
  
  .search-container {
    padding: 0 16px;
  }
}

/* =============================================================================
   ACCESSIBILITY ENHANCEMENTS
============================================================================= */

/* Focus states */
@media (max-width: 768px) {
  .mobile-menu-btn:focus,
  .mobile-icon-btn:focus,
  .mobile-menu-close:focus {
    outline: 2px solid var(--leibal-primary);
    outline-offset: 2px;
    border-radius: 4px;
  }
  
  .mobile-menu-list a:focus,
  .mobile-submenu a:focus {
    background: rgba(72, 70, 52, 0.1);
    outline: 2px solid var(--leibal-primary);
    outline-offset: -2px;
  }
  
  .search-input:focus {
    outline: 2px solid var(--leibal-primary);
    outline-offset: 2px;
  }
}

/* Screen reader only text */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* =============================================================================
   PERFORMANCE OPTIMIZATIONS
============================================================================= */

/* Hardware acceleration for smooth animations */
@media (max-width: 768px) {
  .mobile-menu,
  .mobile-menu-overlay,
  .hamburger-line,
  .mobile-dropdown-arrow {
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  
  /* Reduce motion for users who prefer it */
  @media (prefers-reduced-motion: reduce) {
    .mobile-menu,
    .mobile-menu-overlay,
    .hamburger-line,
    .mobile-dropdown-arrow,
    .mobile-submenu,
    .mobile-cart-count {
      transition: none !important;
      animation: none !important;
    }
  }
}

/* =============================================================================
   INTEGRATION WITH EXISTING STYLES
============================================================================= */

/* Ensure mobile styles don't affect desktop */
@media (min-width: 769px) {
  .mobile-nav,
  .mobile-menu,
  .mobile-menu-overlay {
    display: none !important;
  }
}

/* Language switcher mobile integration */
@media (max-width: 768px) {
  .menu-item-language-switcher {
    order: -1;
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
  }
  
  .language-switcher {
    justify-content: center;
    height: auto;
    gap: 12px;
  }
  
  .lang-link {
    min-width: 36px;
    height: 28px;
    font-size: 10px;
    padding: 0 6px;
  }
}

/* =============================================================================
   HOVER STATES FOR TOUCH DEVICES
============================================================================= */

/* Remove hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
  .mobile-icon-btn:hover,
  .mobile-menu-btn:hover,
  .mobile-menu-list > li > a:hover,
  .mobile-submenu a:hover {
    background: transparent;
    opacity: 1;
  }
  
  /* Enhance active/pressed states for touch */
  .mobile-icon-btn:active,
  .mobile-menu-btn:active {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
  }
}

/* =============================================================================
   DARK MODE SUPPORT (Optional)
============================================================================= */

@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .mobile-menu {
    background: #1a1a1a;
    color: white;
  }
  
  .mobile-menu-header {
    background: #1a1a1a;
    border-bottom-color: #333;
  }
  
  .mobile-menu-close {
    color: white;
  }
  
  .mobile-menu-list > li {
    border-bottom-color: #333;
  }
  
  .mobile-menu-list > li > a {
    color: white;
    background: #1a1a1a;
  }
  
  .mobile-menu-list > li > a:hover {
    background: #2a2a2a;
  }
  
  .mobile-submenu {
    background: #2a2a2a;
  }
  
  .mobile-submenu a {
    color: #ccc;
    background: #2a2a2a;
  }
  
  .mobile-submenu a:hover {
    color: white;
    background: #333;
  }
}

/* =============================================================================
   DEBUGGING HELPERS (Remove in production)
============================================================================= */

/* Uncomment for debugging layout issues */
/*
@media (max-width: 768px) {
  .mobile-nav-container * {
    outline: 1px solid red;
  }
  
  .mobile-menu * {
    outline: 1px solid blue;
  }
}
*/