/**
 * Enhanced Header Styles with Dutycast Integration
 * Based on Figma Design: Homepage 2 (Node 2218:3375)
 */

.katacart-enhanced-header {
  background-color: #002823;
  color: #FFFFFF;
  width: 100%;
  z-index: 1000;
  position: relative;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}

/* When custom colors are set via inline styles, they will override these defaults */
.katacart-enhanced-header * {
  color: inherit;
}

/* Sticky header - applied to the API wrapper div */
.layout-api-header.global-site-header.sticky {
  position: sticky;
  top: 0;
  z-index: 1001;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--container-padding, 24px);
  width: 100%;
}

/* Main Header */
.header-main {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Align items to the left */
  gap: 24px;
  padding: 11px 0 17px;
  min-height: 61px;
}

/* Logo */
.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 16px;
}

.logo-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: start !important;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: inherit;
}

.logo-image {
  max-height: 32px !important;
  width: auto;
  display: block;
}

/* Site Identity (Name & Slogan) */
.site-identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 12px;
}

.site-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.2;
  color: inherit;
}

.site-slogan {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.3;
  color: inherit;
}

/* Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.nav-link {
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  opacity: 0.8;
}

/* Navigation Item with Dropdown */
.nav-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-item--has-dropdown .nav-link {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dropdown-icon {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.nav-item--has-dropdown:hover .dropdown-icon {
  transform: rotate(180deg);
}

/* Navigation Dropdown */
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 180px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.nav-item--has-dropdown:hover .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-link {
  display: block;
  padding: 10px 16px;
  color: #002823;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.nav-dropdown-link:hover {
  background: #F3F4F6;
}

/* Right Section */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Language & Currency Switchers */
.language-switcher,
.currency-switcher {
  position: relative;
  flex-shrink: 0;
}

.switcher-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  font-size: 13px;
  font-weight: 500;
}

.switcher-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.switcher-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.switcher-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.switcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 140px;
  z-index: 1000;
  display: none;
}

.switcher-dropdown.active {
  display: block;
}

.switcher-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  color: #002823;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.switcher-option:hover {
  background: #F3F4F6;
}

.switcher-option.active {
  background: #E8F5F1;
  color: #00695C;
  font-weight: 600;
}

/* Dutycast Search Widget */
.header-search {
  flex: 0 1 380px;
  max-width: 380px;
  min-width: 260px;
}

.dutycast-search-widget {
  width: 100%;
}

/* Search wrapper - contains input and button */
.search-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

/* Fallback search input (shown before Dutycast loads) */
.search-fallback {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 10px 48px 10px 16px;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  background: #FFFFFF;
  color: #002823;
  transition: box-shadow 0.2s ease;
  height: 44px;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(126, 217, 179, 0.3);
}

.search-input::placeholder {
  color: #6B7280;
}

.search-button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: #002823;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #FFFFFF;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.search-button:hover {
  background: #003d35;
}

.search-button svg {
  width: 20px;
  height: 20px;
}

/* Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.action-button {
  position: relative;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.action-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  display: none; /* Hide labels on all screen sizes - only show icons */
}

/* Cart Badge */
.badge {
  position: absolute;
  top: -5px;
  right: -1px;
  background: #D42E25;
  color: #FFFFFF;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.badge:empty {
  display: none;
}

/* Dutycast Integration Styles */
/* These will be applied when Dutycast widgets load */
[data-dutycast-type="wishlist"].dutycast-loaded .icon-btn,
[data-dutycast-type="cart"].dutycast-loaded .icon-btn {
  /* Hide fallback buttons when Dutycast loads */
  display: none;
}

/* Responsive Styles */
@media (max-width: 1200px) {
  .header-main {
    gap: 16px;
  }

  .header-nav {
    gap: 16px;
  }

  .nav-link {
    font-size: 13px;
  }

  .header-search {
    max-width: 320px;
    min-width: 240px;
  }
}

@media (max-width: 1024px) {
  .header-main {
    gap: 12px;
  }

  .header-search {
    max-width: 280px;
    min-width: 200px;
  }

  .icon-btn {
    padding: 6px;
  }

  .header-actions {
    gap: 6px;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 0 var(--spacing-16, 16px);
  }

  .header-main {
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-logo {
    order: 1;
  }

  .header-actions {
    order: 2;
    margin-left: auto;
  }

  .header-search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
  }

  .header-nav {
    order: 4;
    flex: 1 1 100%;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
  }

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

  .nav-link {
    font-size: 13px;
  }

  .site-slogan {
    display: none;
  }

  .site-name {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0 var(--spacing-12, 12px);
  }

  .logo-text {
    font-size: 16px;
  }

  .logo-image {
    max-height: 32px;
  }

  .site-identity {
    margin-left: 8px;
  }

  .site-name {
    font-size: 14px;
  }

  .site-slogan {
    font-size: 10px;
  }

  .header-actions {
    gap: 8px;
  }

  .search-input {
    font-size: 13px;
    padding: 8px 40px 8px 12px;
  }

  .search-button {
    width: 32px;
    height: 32px;
  }

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

/* Loading State */
.dutycast-search-widget.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #FFFFFF;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Accessibility */
.icon-btn:focus-visible {
  outline: 2px solid #7ED9B3;
  outline-offset: 2px;
}

.search-input:focus-visible {
  outline: 2px solid #7ED9B3;
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .katacart-enhanced-header {
    position: static;
    box-shadow: none;
  }

  .header-search,
  .header-actions {
    display: none;
  }
}

.block-katacart-content-blocks,
.block-katacart-store-category-grid,
.block-katacart-store-listing {
  max-width: 1400px;
  margin: auto;
  padding: 0 24px;
}