/* Header layout for logo, search, nav */

/* Main header container */
header {
  background: var(--primary-color);
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  padding-top: 72px; /* Adjust if header height changes */
}

/* Grid layout for header content */
.header-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  gap: 1.5rem;
  padding: 0 2vw;
}

/* Logo - fixed width, left aligned */
.header-grid .logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.logo {
  white-space: nowrap;
  font-size: 2rem;
  font-weight: bold;
  color: var(--accent-color);
}

header .logo {
  font-size: 2rem;
  font-weight: bold;
  color: var(--accent-color);
}

/* Search bar - flexible but constrained */
.header-search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: var(--border-radius);
  padding: 0.1rem 0.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  max-width: 500px;
  min-width: 200px;
}


.header-search input[type="text"] {
  border: none;
  outline: none;
  padding: 0.5rem 0.7rem;
  font-size: 1rem;
  border-radius: var(--border-radius);
  width: 100%;
  min-width: 0;
}

.header-search button {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
}

.header-search button:hover {
  color: var(--accent-color);
}

/* Navigation - fixed width, right aligned */
.header-grid nav {
  flex: 0 0 auto;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

header nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

header nav a {
  color: #fff;
  transition: color var(--transition);
  font-size: 1.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
}

header nav a:hover {
  color: var(--accent-color);
}

.nav-label {
  font-size: 0.95rem;
  margin-top: 0.2rem;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Account dropdown */
.account-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.account-dropdown > a {
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 2.5rem;
  right: 0;
  background: #fff;
  color: #111;
  min-width: 140px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-radius: var(--border-radius);
  z-index: 2000;
  flex-direction: column;
  padding: 0.5rem 0;
}

.account-dropdown.show .dropdown-content {
  display: flex;
}

.dropdown-content a, .dropdown-content button {
  color: #111;
  background: none;
  border: none;
  text-align: left;
  padding: 0.7rem 1.2rem;
  width: 100%;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition);
}

.dropdown-content a:hover, .dropdown-content button:hover {
  background: #f3f3f3;
}


/* Cart Badge */
.cart-link {
  position: relative;
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff6600;
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* Theme Toggle in Dropdown */
.theme-toggle-dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 1.2rem;
  background: none;
  border: none;
  color: #111;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.theme-toggle-dropdown:hover {
  background: #f3f3f3;
}

.theme-toggle-dropdown i {
  font-size: 1.1rem;
}

[data-theme="dark"] .theme-toggle-dropdown {
  color: var(--text-color);
}

[data-theme="dark"] .theme-toggle-dropdown:hover {
  background: #444;
}


/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  header {
    padding: 0.8rem 1rem;
  }

  body {
    padding-top: 60px;
  }

  .header-grid {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
  }

  .logo {
    font-size: 1.4rem;
  }

  .header-search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 0.5rem;
  }

  .mobile-menu-toggle {
    display: block;
    order: 2;
  }

  header nav,
  #mainNav {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary-color);
    flex-direction: column;
    padding: 1rem;
    gap: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  header nav.mobile-open,
  #mainNav.mobile-open {
    display: flex !important;
  }

  header nav a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1rem;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    width: 100%;
  }

  header nav a:last-child {
    border-bottom: none;
  }

  .nav-label {
    font-size: 1rem;
    margin-top: 0;
  }

  .account-dropdown {
    width: 100%;
    flex-direction: column;
  }

  .account-dropdown > a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1rem;
    width: 100%;
  }

  .dropdown-content {
    position: static;
    background: rgba(255,255,255,0.1);
    box-shadow: none;
    width: 100%;
    padding: 0;
  }

  .dropdown-content a,
  .dropdown-content button {
    color: #fff;
    padding: 0.8rem 2rem;
  }

  .dropdown-content a:hover,
  .dropdown-content button:hover {
    background: rgba(255,255,255,0.1);
  }

  .theme-toggle-dropdown {
    color: #fff;
  }

  .theme-toggle-dropdown:hover {
    background: rgba(255,255,255,0.1);
  }

  .cart-badge {
    top: 5px;
    right: auto;
    left: 20px;
  }

  /* Dark mode mobile adjustments */
  [data-theme="dark"] .dropdown-content a,
  [data-theme="dark"] .dropdown-content button {
    color: #fff;
  }

  [data-theme="dark"] .theme-toggle-dropdown {
    color: #fff;
  }
}

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

  .header-search input[type="text"] {
    font-size: 0.9rem;
    padding: 0.4rem 0.5rem;
  }
}
