/**
 * Header - Complete System
 * 
 * Tất cả CSS liên quan đến header (topbar, logo, navigation, search, cart)
 * Bao gồm cả desktop và mobile
 * 
 * @package YenSao_Premium
 */

/* ========================================
   DESKTOP HEADER (Default)
   ======================================== */

/* ===== TOP BAR ===== */
.topbar {
  background: var(--color-stone-950);
  color: var(--color-stone-300);
  font-size: 0.75rem;
}

.topbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar a:hover {
  color: var(--color-white);
}

/* ===== HEADER ===== */
.site-header,
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-stone-200);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.site-header.hide {
  transform: translateY(-100%);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}

/* ===== LOGO ===== */
.site-logo,
.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-logo a,
.header-logo a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  padding-left: 1rem;
}

.logo-icon {
  height: 4.25rem;
  object-fit: cover;
  display: block;
}

.logo-text {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  color: var(--color-stone-800);
}

.logo-name {
  color: var(--color-stone-800);
}

.logo-accent {
  color: var(--color-amber-600);
}

/* ===== NAVIGATION ===== */
.main-navigation,
.nav {
  display: none;
  align-items: center;
  gap: 2rem;
}

@media (min-width: 993px) {
  .main-navigation,
  .nav {
    display: flex;
  }
}

.nav > a,
.nav .nav-item > a {
  color: var(--color-stone-700);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-base);
}

.nav > a:hover,
.nav .nav-item > a:hover {
  color: var(--color-amber-700);
}

/* Dropdown icon */
.nav .nav-item > a i.fa-chevron-down {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  opacity: 0.7;
}

/* Submenu / Dropdown */
.menu-item {
  position: relative;
}

.menu-item-has-children:hover .sub-menu {
  visibility: visible;
  opacity: 1;
}

.sub-menu {
  visibility: hidden;
  opacity: 0;
  transition: all var(--transition-base);
  position: absolute;
  left: 0;
  top: calc(100% + 0.75rem);
  min-width: 220px;
  background: var(--color-white);
  border: 1px solid var(--color-stone-200);
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  z-index: 100;
}

.sub-menu li {
  padding: 0;
  border-radius: 0.5rem;
}

.sub-menu li:hover {
  background: var(--color-amber-50);
}

/* ===== MEGA MENU ===== */
.mega-menu {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 0.75rem);
  width: 680px;
  max-width: 90vw;
  background: #ffffff;
  border: 1px solid #e7e5e4;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  /* padding: 1.5rem; */
  z-index: 100;
}

.menu-item-has-children:hover .mega-menu,
.has-dropdown:hover .mega-menu {
  visibility: visible;
  opacity: 1;
}

.mega-menu-content {
 display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding: 1rem;
}

.mega-menu-col {
  display: flex;
  flex-direction: column;
}

.mega-menu-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-stone-800);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  /* margin-bottom: 1rem; */
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-amber-500);
}

.mega-menu-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mega-menu-col ul li {
  padding: 0;
}

.mega-menu-col ul li a {
  display: block;
  padding: 0.1rem 0.5rem;
  color: var(--color-stone-700);
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all var(--transition-base);
}

.mega-menu-col ul li a:hover {
  background: var(--color-amber-50);
  color: var(--color-amber-700);
  padding-left: 1rem;
}

/* Featured Column */
.mega-menu-featured {
  background: linear-gradient(135deg, #fffef8 0%, #faf9f5 100%);
  border: 2px solid var(--color-amber-200);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}

.mega-menu-featured .featured-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-amber-700);
  margin-bottom: 0.75rem;
}

.mega-menu-featured .featured-desc {
  font-size: 0.875rem;
  color: var(--color-stone-600);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.mega-menu-featured .btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--color-amber-600);
  color: var(--color-white);
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

.mega-menu-featured .btn:hover {
  background: var(--color-amber-700);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

/* ===== HEADER ACTIONS ===== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Search Button */
.header-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 0.5rem;
  background: transparent;
  border: none;
  color: var(--color-stone-700);
  cursor: pointer;
  transition: all var(--transition-base);
}

.header-search:hover {
  background: var(--color-stone-100);
  color: var(--color-amber-700);
  transform: translateY(-1px);
}

.header-search i {
  font-size: 1.125rem;
}

/* Cart Button */
.header-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--color-stone-700);
  text-decoration: none;
  transition: all var(--transition-base);
}

.header-cart:hover {
  background: var(--color-stone-100);
  color: var(--color-amber-700);
  transform: translateY(-1px);
}

.header-cart i {
  font-size: 1.25rem;
  line-height: 1;
}

.cart-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--color-amber-600);
  color: var(--color-white);
  font-size: 0.625rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--color-white);
  animation: cartBadgePulse 0.3s ease;
}

@keyframes cartBadgePulse {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Mobile Menu Toggle (Hidden on desktop) */
.mobile-menu-toggle,
.btn-menu {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-stone-300);
  display: none; /* Hidden by default */
  background: transparent;
  color: var(--color-stone-700);
  cursor: pointer;
}

@media (max-width: 992px) {
  .mobile-menu-toggle,
  .btn-menu {
    display: block; /* Show on mobile */
  }
}

@media (min-width: 993px) {
  .mobile-menu-toggle,
  .btn-menu {
    display: none;
  }
}

/* CTA Button - Nổi bật đặc biệt */
.btn-cta {
  padding: 0.625rem 1.25rem;
  font-size: 0.938rem;
  font-weight: 600;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-cta::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn-cta:hover::before {
  left: 100%;
}

/* ===== SEARCH MODAL ===== */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.search-modal.active {
  display: flex;
  opacity: 1;
}

.search-modal-content {
  background: var(--color-white);
  border-radius: 1.25rem;
  padding: 2.5rem;
  width: 90%;
  max-width: 650px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: searchModalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes searchModalSlideIn {
  from {
    transform: scale(0.9) translateY(-30px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.search-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--color-stone-100);
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-stone-500);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
}

.search-close:hover {
  background: var(--color-amber-600);
  color: var(--color-white);
  transform: rotate(90deg) scale(1.1);
}

/* Search Form Title */
.search-modal-content::before {
  content: "Tìm kiếm sản phẩm";
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-stone-800);
  margin-bottom: 1.5rem;
  font-family: var(--font-serif);
}

.search-modal-content .search-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-modal-content .search-form label {
  flex: 1;
  min-width: 250px;
}

.search-modal-content .search-field {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 2px solid var(--color-stone-200) !important;
  border-radius: 1rem;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: var(--color-stone-50);
  outline: none !important;
  box-shadow: none !important;
}

.search-modal-content .search-field:focus {
  outline: none !important;
  border: 2px solid var(--color-amber-500) !important;
  background: var(--color-white);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.1) !important;
}

.search-modal-content .search-field:focus-visible {
  outline: none !important;
  border: 2px solid var(--color-amber-500) !important;
}

.search-modal-content .search-submit {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: var(--color-white);
  border: none;
  border-radius: 1rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.search-modal-content .search-submit i {
  font-size: 1.125rem;
}

.search-modal-content .search-submit:hover {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
}

.search-modal-content .search-submit:active {
  transform: translateY(0);
}


/* ========================================
   TABLET HEADER (993px - 1024px)
   ======================================== */

@media (min-width: 993px) and (max-width: 1024px) {
  
  /* Logo vertical layout like mobile */
  .header-logo .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }

  .header-logo .logo-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .header-logo .logo-accent {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }
}


/* ========================================
   MOBILE HEADER (≤992px)
   ======================================== */

@media (max-width: 992px) {
  
  /* ===== TOP BAR ===== */
  .topbar {
    padding: 0.5rem 0;
    font-size: 0.813rem;
  }

  .topbar-content {
    gap: 0.5rem;
  }

  .topbar-left span:not(:first-child) {
    display: none;
  }

  .topbar-right {
    font-size: 0.75rem;
  }

  .hidden-mobile {
    display: none !important;
  }

  /* ===== HEADER ===== */
  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 0.75rem 0;
  }

  .header-content {
    gap: 0.5rem;
  }

  /* ===== LOGO ===== */
  .header-logo {
    flex-shrink: 0;
  }

  .header-logo a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
  }

  .header-logo .logo-icon {
    width: 2.75rem;
    height: 2.75rem;
  }

  .header-logo .logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }

  .header-logo .logo-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .header-logo .logo-accent {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  /* ===== NAVIGATION (Hidden on mobile) ===== */
  .main-navigation {
    display: none;
  }

  /* ===== HEADER ACTIONS ===== */
  .header-actions {
    gap: 0.5rem;
    margin-left: auto;
  }

  /* Search Button */
  .header-search {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--color-stone-200);
    background: transparent;
    transition: all 0.3s ease;
  }

  .header-search i {
    font-size: 1rem;
  }

  .header-search:hover {
    background: var(--color-stone-50);
    border-color: var(--color-champagne);
  }

  .header-search:active {
    transform: scale(0.95);
  }

  /* Cart Button */
  .header-cart {
    position: relative;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--color-stone-200);
    background: transparent;
    transition: all 0.3s ease;
  }

  .header-cart i {
    font-size: 1rem;
  }

  .header-cart:hover {
    background: var(--color-stone-50);
    border-color: var(--color-champagne);
  }

  .header-cart:active {
    transform: scale(0.95);
  }

  .header-cart .cart-count {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    background: var(--color-red-500, #EF4444);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
  }

  /* ===== SEARCH MODAL ===== */
  .search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4rem;
  }

  .search-modal.active {
    display: flex;
  }

  .search-modal-content {
    background: white;
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideDown 0.3s ease;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .search-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: var(--color-stone-100);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-stone-600);
    transition: all 0.2s ease;
  }

  .search-close:hover {
    background: var(--color-stone-200);
    color: var(--color-stone-900);
  }

  .search-form input[type="search"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--color-stone-200);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
  }

  .search-form input[type="search"]:focus {
    border-color: var(--color-champagne);
    outline: none;
    box-shadow: 0 0 0 3px rgba(200, 167, 90, 0.1);
  }

  .search-form button[type="submit"] {
    margin-top: 1rem;
    width: 100%;
    padding: 0.875rem;
    background: var(--color-champagne);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .search-form button[type="submit"]:active {
    transform: scale(0.98);
  }

  /* ===== CTA BUTTON (Hidden on mobile) ===== */
  .btn-cta {
    display: none !important;
  }

}


/* ========================================
   SMALL MOBILE (≤480px)
   ======================================== */

@media (max-width: 480px) {
  
  .topbar {
    font-size: 0.75rem;
  }

  .header {
    padding: 0.625rem 0;
  }

  .header-logo .logo-icon {
    width: 2.5rem;
    height: 2.5rem;
  }

  .header-logo .logo-name {
    font-size: 1.125rem;
  }

  .header-logo .logo-accent {
    font-size: 1.125rem;
  }

  .header-actions {
    gap: 0.375rem;
  }

  .header-search,
  .header-cart,
  .mobile-menu-toggle {
    width: 2.25rem;
    height: 2.25rem;
  }

  .header-search i,
  .header-cart i {
    font-size: 0.875rem;
  }

  .search-modal-content {
    width: 95%;
    padding: 1.5rem 1rem;
  }

  .search-modal-content::before {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .search-modal-content .search-form {
    flex-direction: column;
  }

  .search-modal-content .search-form label {
    min-width: 100%;
  }

  .search-modal-content .search-submit {
    width: 100%;
    justify-content: center;
  }
}


/* ========================================
   LANDSCAPE MODE
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
  
  .header {
    padding: 0.5rem 0;
  }

  .topbar {
    display: none;
  }
}


/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  
  /* Larger touch targets */
  .header-search,
  .header-cart,
  .mobile-menu-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  /* Remove hover states */
  .header-search:hover,
  .header-cart:hover,
  .mobile-menu-toggle:hover {
    background: transparent;
  }

  /* Enhance active states */
  .header-search:active,
  .header-cart:active,
  .mobile-menu-toggle:active {
    background: var(--color-stone-100);
  }
}


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

@media (prefers-reduced-motion: reduce) {
  .search-modal,
  .search-modal-content {
    transition: none;
    animation: none;
  }
}


/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
  .header-search,
  .header-cart,
  .mobile-menu-toggle {
    border-width: 2px;
  }
}
