
/**
 * =====================================================
 * HEADER STYLES - REUSABLE COMPONENT
 * =====================================================
 * CSS riêng cho header component
 * Đồng bộ với config.js color scheme
 * 
 * TAILWIND COLORS BEING USED:
 * - bg-primary-500: #1800ad (Dark Blue)
 * - border-button-500: #4338ca (Purple)
 * - text-primary-500: #1800ad
 * - text-primary-200: #93c5fd
 */

/* ==================== HEADER BASE STYLES ==================== */

#header {
  /* Already styled with Tailwind classes in HTML */
  /* This CSS file provides additional animations and effects */
}

/* ==================== ANIMATIONS ==================== */

@keyframes scroll-left-infinite {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.animate-scroll-left-infinite {
  animation: scroll-left-infinite 30s linear infinite;
}

@keyframes header-slide-down {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#header {
  animation: header-slide-down 0.5s ease-out;
}

/* ==================== TOP BAR STYLES ==================== */

.animate-scroll-left-infinite {
  display: flex;
  gap: 1.5rem;
}

/* Info items with dot separator */
.animate-scroll-left-infinite > div::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -0.75rem;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  background-color: #93c5fd; /* primary-200 */
  border-radius: 50%;
}

.animate-scroll-left-infinite > div:first-child::before {
  display: none;
}

/* ==================== CATEGORY MENU STYLES ==================== */

#categoryMenu {
  box-shadow: 0 10px 50px -10px rgba(0, 0, 0, 0.1);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  min-width: 224px;
  width: 224px;
  /* Position will be calculated by JS - align to left of main content area */
}

#categoryMenu::-webkit-scrollbar {
  width: 6px;
}

#categoryMenu::-webkit-scrollbar-track {
  background: transparent;
}

#categoryMenu::-webkit-scrollbar-thumb {
  background: #d4d4d4;
  border-radius: 3px;
}

#categoryMenu::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.menu-item {
  transition: all 0.2s ease-in-out;
}

.menu-item a {
  position: relative;
}

.menu-item a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #1800ad; /* primary-500 */
  transition: width 0.3s ease-in-out;
}

.menu-item a:hover::after {
  width: 100%;
}

/* Mega menu styles removed - will be re-implemented */

/* ==================== SEARCH BAR STYLES ==================== */

.search-input {
  transition: all 0.2s ease-in-out;
}

.search-input:focus {
  border-color: #1800ad; /* primary-500 */
  box-shadow: 0 0 0 2px #93c5fd; /* primary-200 ring */
}

/* ==================== CATEGORY OVERLAY ==================== */

#categoryOverlay {
  animation: fade-in 0.3s ease-in-out;
  backdrop-filter: blur(4px);
}

#categoryOverlay.hidden {
  animation: fade-out 0.3s ease-in-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ==================== MEGA MENU STYLES ==================== */

/* Container - Fixed Structure */
.mega-menu-container {
  position: fixed;
  left: 224px;
  top: 98px;
  width: calc(100vw - 224px - 40px);
  max-width: 1000px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 1002;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.mega-menu-container.hidden {
  display: none !important;
}

.mega-menu-container.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  display: flex;
}

.mega-menu-wrapper {
  padding: 24px;
  min-height: 200px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  max-height: 100%;
}

.mega-menu-wrapper::-webkit-scrollbar {
  width: 6px;
}

.mega-menu-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.mega-menu-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.mega-menu-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Loading State */
.mega-menu-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #6b7280;
}

.mega-menu-loading .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

/* ============================================
   SEARCH OVERLAY STYLES
   ============================================ */

.search-container {
  position: relative;
}

.search-overlay {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
}

.search-overlay-content {
  padding: 0;
}

.search-loading {
  padding: 20px;
}

.search-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  padding: 12px 16px;
  margin: 0;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
}

.search-suggestions {
  border-bottom: 1px solid #e5e7eb;
}

.suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.suggestion-item {
  border-bottom: 1px solid #f3f4f6;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.search-products {
  max-height: 400px;
  overflow-y: auto;
}

.products-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.product-item {
  border-bottom: 1px solid #f3f4f6;
}

.product-item:last-child {
  border-bottom: none;
}

.product-item a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.product-item img {
  flex-shrink: 0;
}

.product-item h4 {
  word-break: break-word;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-no-results {
  padding: 40px 20px;
  text-align: center;
}

/* Scrollbar styling for search overlay */
.search-overlay::-webkit-scrollbar {
  width: 8px;
}

.search-overlay::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.search-overlay::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.search-overlay::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================
   END OF SEARCH OVERLAY STYLES
   ============================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}

.mega-menu-loading p {
  font-size: 14px;
  margin: 0;
}

/* Content Area */
.mega-menu-content {
  transition: opacity 0.2s ease;
}

/* Error State */
.mega-menu-error {
  text-align: center;
  padding: 40px;
  color: #ef4444;
}

.mega-menu-error p {
  margin: 0;
  font-size: 14px;
}

/* Grid Layout */
.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
  align-content: start;
  min-height: 0;
}

/* Column */
.mega-menu-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: 100%;
  overflow: hidden;
}

.mega-menu-title {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #3b82f6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mega Menu Needs (Items Container) */
.mega-menu-needs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: visible;
}

/* Need Link (Individual Item) */
.need-link {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  font-size: 13px;
  color: #4b5563;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.need-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.need-link:hover {
  background-color: #eff6ff;
  color: #3b82f6;
  transform: translateX(4px);
}

.need-icon-emoji {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

/* Badge Colors */
.badge-red {
  display: inline-block;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.badge-blue {
  display: inline-block;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.badge-green {
  display: inline-block;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.badge-orange {
  display: inline-block;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.badge-purple {
  display: inline-block;
  background: linear-gradient(135deg, #a855f7, #9333ea);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

/* List */
.mega-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mega-menu-list li {
  margin: 0;
  padding: 0;
}

.mega-menu-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #4b5563;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.mega-menu-link:hover {
  background-color: #eff6ff;
  color: #3b82f6;
  transform: translateX(4px);
}

/* HOT Badge */
.badge-hot {
  display: inline-block;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: auto;
  animation: pulse-hot 2s ease-in-out infinite;
}

@keyframes pulse-hot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* Active menu item highlight */
.menu-item.active {
  background-color: #dbeafe !important;
}

.menu-item.active a {
  color: #3b82f6 !important;
}

/* ==================== RESPONSIVE ADJUSTMENTS ==================== */

@media (max-width: 1024px) {
  #categoryMenu {
    width: 224px !important;
    min-width: 224px;
    max-height: 60vh;
  }
  
  /* Mega menu responsive */
  .mega-menu-container {
    left: 224px;
    width: calc(100vw - 224px - 40px);
    max-width: 800px;
  }
  
  .mega-menu-grid {
    gap: 24px;
  }
}

@media (max-width: 768px) {
  #categoryMenu {
    width: 90vw !important;
    max-width: 320px;
    min-width: 280px;
  }
  
  #header {
    flex-direction: column;
  }
  
  .animate-scroll-left-infinite {
    animation-duration: 20s;
  }
  
  /* Hide mega menu on mobile - menu items will navigate directly */
  .mega-menu-container {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .animate-scroll-left-infinite {
    gap: 1rem;
  }
}

/* ==================== HEADER SHADOW ON SCROLL ==================== */

#header.shadow-lg {
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.2);
}

/* ==================== BUTTON HOVER EFFECTS ==================== */

#categoryMenuBtn {
  transition: all 0.2s ease-in-out;
}

#categoryMenuBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -2px rgba(67, 56, 202, 0.3);
}

#categoryMenuBtn:active {
  transform: translateY(0);
}

.button__cart {
  transition: all 0.2s ease-in-out;
  position: relative;
}

.button__cart:hover {
  transform: scale(1.05);
}

.button__cart::before {
  content: '';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background-color: #ef4444;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

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

.menu-item a:focus {
  outline: 2px solid #1800ad; /* primary-500 */
  outline-offset: 2px;
  border-radius: 0.375rem;
}

button:focus {
  outline: 2px solid #1800ad;
  outline-offset: 2px;
}

/* ==================== SMOOTH TRANSITIONS ==================== */

* {
  scroll-behavior: smooth;
}

/* Disable smooth scroll for header (prevent jank) */
#header * {
  scroll-behavior: auto;
}

/* ==================== UTILITY CLASSES ==================== */

.scrollbar-none {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* Shadow bottom effect for category menu */
.shadow-bottom-50 {
  box-shadow: 0 50px 30px -30px rgba(0, 0, 0, 0.1);
}

/* ==================== COLOR CONSISTENCY ==================== */

/* Ensure primary colors are consistent */
.text-primary-500 {
  color: #1800ad;
}

.bg-primary-500 {
  background-color: #1800ad;
}

.border-primary-500 {
  border-color: #1800ad;
}

.text-primary-200 {
  color: #93c5fd;
}

.bg-primary-200 {
  background-color: #93c5fd;
}

.text-button-500 {
  color: #4338ca;
}

.bg-button-500 {
  background-color: #4338ca;
}

.border-button-500 {
  border-color: #4338ca;
}

.text-button-600 {
  color: #3730a3;
}

.bg-button-600 {
  background-color: #3730a3;
}

/* ==================== PRINT STYLES ==================== */

@media print {
  #header,
  #categoryOverlay,
  #categoryMenu {
    display: none !important;
  }
  
  .h-24\.5 {
    height: 0 !important;
  }
}
