/* Header styles */
.header {
  position: relative;
  width: 100%;
  z-index: 9999;
  background: white;
}

/* Announcement - chiều cao khoảng 30px */
.announcement {
  background-color: #333;
  color: #FF6666;
  padding: 4px 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.875rem;
  height: 30px;
  /* Fixed height for calculation */
}

.announcement-content {
  display: inline-block;
  animation: scroll-left 40s linear infinite;
}

.announcement-text {
  display: inline-block;
  padding-right: 2rem;
}

@keyframes scroll-left {
  0% {
    transform: translateX(120vw);
  }

  2% {
    transform: translateX(70vw);
  }

  100% {
    transform: translateX(-100%);
  }
}

/* STICKY HEADER WRAPPER - CHỈ CHỨA MAIN HEADER VÀNG */
.header-sticky-wrapper {
  background: #FF6666;
  width: 100%;
  z-index: 9999;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  /* Dính ở top khi cuộn */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.main-header {
  background-color: #FF6666;
  padding: 0.75rem 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Logo */
.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-image {
  max-height: 48px;
  width: auto;
  transition: transform 0.2s;
}

.logo-image:hover {
  transform: scale(1.02);
}

@media (max-width: 768px) {
  .logo-image {
    max-height: 36px;
  }
}

/* Search Bar (Renamed to avoid conflict) */
.header-search-container {
  flex-grow: 1;
  max-width: 600px;
  margin: 0 1.5rem;
  display: flex;
  align-items: center;
}

/* Search Bar Seamless Style */
.search-form {
  display: flex;
  width: 100%;
  gap: 0;
  /* Ensure no gap */
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 2px solid #333;
  border-right: none;
  border-radius: 2rem 0 0 2rem;
  outline: none;
  font-size: 0.95rem;
  height: 40px;
  margin: 0;
  /* Remove potential margin */
}

.search-btn {
  background-color: #333;
  border: 2px solid #333;
  border-left: none;
  border-radius: 0 2rem 2rem 0;
  padding: 0 1.5rem;
  color: #FF6666;
  cursor: pointer;
  height: 40px;
  margin: 0;
  /* Remove potential margin */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-weight: bold;
  flex-shrink: 0;
  /* Prevent button from shrinking */
}

.search-btn:hover {
  background-color: #000;
  border-color: #000;
  color: #fff;
}

/* Header Actions (Right Side) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
}

.action-btn:hover {
  transform: translateY(-2px);
  color: #000;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.action-btn i {
  font-size: 1.1rem;
}

.badge-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: #ff0000;
  /* Red background */
  color: #ffffff;
  /* White text */
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(255, 0, 0, 0.3);
}

/* User Profile Widget */
.user-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: #fff;
  padding: 0.35rem 1rem 0.35rem 0.35rem;
  border-radius: 2rem;
  text-decoration: none;
  color: #333;
  transition: all 0.2s;
  margin-left: 0.5rem;
}

.user-widget:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: #333;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: #333;
}

.user-balance {
  font-size: 0.85rem;
  color: #0d6efd;
  font-weight: 600;
}

.login-btns {
  display: flex;
  gap: 0.5rem;
}

.btn-auth {
  padding: 0.4rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-login {
  background-color: #333;
  color: #FF6666;
}

.btn-register {
  background-color: #fff;
  color: #333;
}

/* SECONDARY NAV - CLEAN STYLE */
.secondary-nav {
  background-color: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0;
  position: relative;
  z-index: 40;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  height: 50px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.nav-item-link {
  height: 100%;
  display: flex;
  align-items: center;
  color: #444;
  font-weight: 500;
  text-decoration: none;
  font-size: 16px;
  gap: 0.3rem;
  transition: color 0.2s;
  cursor: pointer;
}

.nav-item-link:hover {
  color: #FF6666;
}

/* Hide main icons except arrow */
.nav-item-link>i:not(.fa-chevron-down) {
  display: none;
}

.nav-item-link .fa-chevron-down {
  font-size: 0.75em;
  color: #888;
  margin-left: 2px;
}

.nav-item-link:hover .fa-chevron-down {
  color: #FF6666;
}

/* Mega Menu Styles */
.has-dropdown {
  position: relative;
}

.mega-menu {
  /* Hidden State - Smooth Transition */
  display: block;
  /* Keep in DOM for layout flow if needed, but absolute pulls it out */
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  position: absolute;
  top: 100%;
  /* Push down exactly 100% */
  left: 0;
  z-index: 99;
  background-color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border: 1px solid #eee;
  border-top: 3px solid #FF6666;
  min-width: 220px;
  border-radius: 0 0 6px 6px;
  transition: all 0.3s ease;
  pointer-events: none;
  /* Ignore clicks when hidden */
}

/* Bridge to prevent menu closing during mouse transfer */
.has-dropdown::after {
  content: '';
  position: absolute;
  top: 80%;
  /* Start slightly overlap */
  left: 0;
  width: 100%;
  height: 30px;
  /* Safe zone */
  background: transparent;
  z-index: 98;
}

.has-dropdown:hover .mega-menu,
.has-dropdown.show .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.mega-menu-content {
  padding: 10px;
}

.mega-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mega-menu-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: #333;
  text-decoration: none;
  font-size: 15px;
  border-radius: 4px;
  transition: background 0.2s;
  white-space: nowrap;
}

.mega-menu-item:hover {
  background-color: #f5f5f5;
  color: #FF6666;
}

/* User Dropdown */
.dropdown-menu {
  /* Base hidden state */
  display: flex !important;
  /* Flex layout but hidden visibility */
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);

  position: absolute;
  z-index: 100;
  background: #fff;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  min-width: 200px;
  padding: 8px 0;
  transition: all 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
  pointer-events: none;
}

/* Bridge for User Dropdown */
.user-dropdown-wrapper::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  height: 20px;
  background: transparent;
}

.user-dropdown-wrapper:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  padding: 8px 15px;
  color: #333;
  text-decoration: none;
  font-size: 15px;
  display: flex;
  align-items: center;
}

.dropdown-item:hover {
  background-color: #f5f5f5;
  color: #000;
}

.dropdown-divider {
  border-top: 1px solid #eee;
  margin: 5px 0;
}

/* Mobile Responsive Styles */
.mobile-search-toggle,
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #333;
}

@media (max-width: 991px) {
  .nav-menu {
    display: none;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .action-btn {
    width: 34px;
    height: 34px;
  }

  .action-btn i {
    font-size: 0.95rem;
  }

  /* Hide user widget on tablet/mobile */
  .user-widget {
    display: none !important;
  }

  /* Hide cart and deposit icons - only show chat, favorites, menu */
  .action-btn[title="Đơn Hàng"],
  .action-btn[title="Nạp Tiền"] {
    display: none !important;
  }

  .logo-image {
    max-height: 32px;
  }

  .main-header {
    padding: 0.5rem 0;
  }

  .header-content {
    gap: 0.5rem;
  }

  /* Show smaller search bar on mobile */
  .header-search-container {
    display: block;
    flex: 1;
    margin: 0 8px;
    max-width: none;
  }

  .search-input {
    padding: 0.4rem 0.8rem;
    height: 34px;
    font-size: 0.85rem;
  }

  .search-btn {
    padding: 0 12px;
    height: 34px;
  }

  /* Hide login buttons on mobile */
  .desktop-only {
    display: none !important;
  }
}

/* Extra small screens - 480px and below */
@media (max-width: 480px) {
  .header-actions {
    gap: 0.2rem;
  }

  .action-btn {
    width: 28px;
    height: 28px;
  }

  .action-btn i {
    font-size: 0.8rem;
  }

  .logo-image {
    max-height: 26px;
  }

  .badge-count {
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    top: -3px;
    right: -3px;
  }

  /* Hide icons on small screens - only show chat, favorites, menu */
  .action-btn[title="Đơn Hàng"],
  .action-btn[title="Nạp Tiền"] {
    display: none;
  }

  .announcement {
    font-size: 0.7rem;
    height: 22px;
    padding: 2px 0;
  }

  .search-input {
    padding: 0.3rem 0.6rem;
    height: 30px;
    font-size: 0.8rem;
  }

  .search-btn {
    padding: 0 10px;
    height: 30px;
  }
}

/* Landscape phones */
@media (max-width: 767px) and (orientation: landscape) {
  .announcement {
    display: none;
  }
}

/* Mobile Menu Overlay - COVERS EVERYTHING */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

.overlay.active {
  display: block;
}

/* Mobile Menu Sidebar - SLIDE FROM RIGHT, FULL HEIGHT */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -85%;
  width: 85%;
  max-width: 320px;
  height: 100vh;
  background: #fff;
  z-index: 9999;
  transition: right 0.3s ease;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.mobile-menu.active {
  right: 0;
}

.mobile-menu-header {
  background: #fff;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.mobile-menu-title {
  font-size: 1rem;
  font-weight: 500;
  color: #333;
}

.mobile-menu-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

/* Nav Items */
.mobile-menu-nav {
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #e8e8e8;
  font-size: 16px;
}

.mobile-nav-item:hover {
  background: #f5f5f5;
}

.mobile-nav-item i {
  color: #999;
  font-size: 0.7rem;
}

/* Contact Footer */
.mobile-menu-contact {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  background: #fff;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  color: #333;
  text-decoration: none;
  font-size: 0.9rem;
}

.contact-item i {
  width: 20px;
  color: #0d6efd;
  text-align: center;
}

/* Seller Red Button */
.btn-seller-red {
  color: #fff !important;
  background-color: #d9534f;
  padding: 5px 15px !important;
  border-radius: 4px;
  transition: background-color 0.2s !important;
  margin-left: 10px;
}

.btn-seller-red:hover {
  background-color: #c9302c !important;
  color: #fff !important;
}