.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 500;
  height: var(--nav-height);
  background: transparent;
  border-bottom: none;
  padding: 12px 0;
}

.navbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 100%;
  width: 80%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-16);
  gap: 100px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

/* Logo */
.nav-logo {
  text-decoration: none;
  text-align: center;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition);
  transform: translateY(-4px);
}

.nav-logo:hover { filter: brightness(1.3); }

.nav-logo-img {
  height: 46px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* nav-logo-dark = black logo → show in light mode; nav-logo-light = white logo → show in dark mode */
:root[data-theme="dark"] .nav-logo-dark  { display: none; }
:root[data-theme="dark"] .nav-logo-light { display: block; }
:root:not([data-theme="dark"]) .nav-logo-dark  { display: block; }
:root:not([data-theme="dark"]) .nav-logo-light { display: none; }

/* Left nav links */
.nav-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Right section */
.nav-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
}

/* Desktop nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 40px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-1) 0;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transform: translateX(-50%);
  transition: width var(--transition);
}

.nav-links a:hover { color: var(--text-primary); }
.nav-links a:hover::after { width: calc(100% - var(--space-6)); }
.nav-links a.active { color: var(--text-primary); }
.nav-links a.active::after { width: calc(100% - var(--space-6)); }

/* Nav actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}

.nav-icon-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-icon-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
  transition: transform var(--transition);
}

.nav-icon-btn:hover svg { transform: scale(1.1); }

.cart-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  animation: badgePop 0.2s ease;
}

@keyframes badgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-primary);
  transition: background var(--transition);
}

.hamburger:hover { background: var(--bg-hover); }

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.3s ease,
              width 0.3s ease;
  transform-origin: center;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; width: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile drawer overlay */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 501;
  pointer-events: none;
  transition: background 0.35s ease;
}

.mobile-nav-overlay.open {
  background: rgba(0, 0, 0, 0.65);
  pointer-events: all;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Mobile drawer */
.mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  max-width: 85vw;
  height: 100dvh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 502;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-nav.open { transform: translateX(0); }

.mobile-nav-header {
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  flex-shrink: 0;
}

.mobile-nav-links {
  padding: var(--space-6) var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-nav-links a {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition), background var(--transition), transform var(--transition);
  transform: translateX(0);
}

.mobile-nav-links a:hover,
.mobile-nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateX(4px);
}

.mobile-nav-link-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  text-align: left;
  transition: color var(--transition), background var(--transition), transform var(--transition);
}

.mobile-nav-link-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateX(4px);
}

/* Staggered link entrance animation */
.mobile-nav.open .mobile-nav-links a:nth-child(1) { animation: slideIn 0.3s 0.05s both; }
.mobile-nav.open .mobile-nav-links a:nth-child(2) { animation: slideIn 0.3s 0.1s both; }
.mobile-nav.open .mobile-nav-links a:nth-child(3) { animation: slideIn 0.3s 0.15s both; }
.mobile-nav.open .mobile-nav-links a:nth-child(4) { animation: slideIn 0.3s 0.2s both; }
.mobile-nav.open .mobile-nav-links a:nth-child(5) { animation: slideIn 0.3s 0.25s both; }
.mobile-nav.open .mobile-nav-links a:nth-child(6) { animation: slideIn 0.3s 0.3s both; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.mobile-nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) var(--space-4);
}

.mobile-nav-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

.mobile-nav-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* Body lock when mobile nav open */
body.nav-open { overflow: hidden; }

/* Search — a dropdown panel anchored under the navbar, not a full-screen
   takeover. The overlay itself stays fully transparent; it only exists to
   catch clicks outside the panel and close it. */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: transparent;
  display: block;
}

.search-overlay.hidden {
  display: none;
}

.search-panel {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
}

/* A fixed close button in the corner of the page, separate from the input
   itself — outside-click-to-close still works independently of this. */
.search-page-close {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 601;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.search-page-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.search-input-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}

.search-input-wrap input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid #000;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
  box-shadow: var(--shadow-lg);
  transition: box-shadow var(--transition);
  font-family: var(--font-sans);
}

.search-input-wrap input:focus {
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent);
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

.search-results:not(:empty) {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3);
  margin-top: var(--space-2);
}

.search-history-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 var(--space-2) var(--space-2);
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.search-history-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-history-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 50vh;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
  border: 1px solid var(--border);
}

.search-result-item:hover {
  background: var(--bg-hover);
  transform: translateX(4px);
}

.search-result-img {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-base);
}

/* Pulse dot for pending order */
.pulse-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: 0.6; }
}

/* Responsive */
@media (max-width: 900px) {
  .nav-links { display: none; }
}

@media (max-width: 900px) {
  .hamburger { display: flex; }

  /* Full-width fixed bar on phone/tablet instead of the floating pill —
     stays pinned to the top edge-to-edge, still visible while scrolling. */
  .navbar { background: var(--bg-base); border-bottom: 1px solid var(--border); padding: 0; }

  .navbar-inner {
    grid-template-columns: auto 1fr;
    gap: 0;
    width: 100%;
    max-width: none;
    padding: 0 var(--space-4);
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .nav-left { display: none; }

  .nav-logo {
    justify-self: start;
    text-align: left;
    font-size: 1.75rem;
  }

  .nav-logo-img { height: 30px; }

  .nav-right {
    justify-self: end;
    gap: var(--space-2);
  }

  .nav-right .nav-links { display: none; }

  /* Theme/cart/account already live inside the mobile drawer — showing them
     here too just duplicates every one of those links. Search stays as an
     icon next to the hamburger since it's not in the drawer anymore. */
  .nav-actions #theme-btn,
  .nav-actions #cart-btn,
  .nav-actions #account-btn {
    display: none;
  }

  .nav-actions { gap: var(--space-1); }

  .nav-icon-btn { width: 36px; height: 36px; }

  .search-panel { width: 80%; }
}

@media (max-width: 480px) {
  .navbar-inner { width: 94%; padding: 0 var(--space-2); }
  .search-input-wrap input { font-size: var(--text-sm); padding: var(--space-3) var(--space-4); }
}
