/* ─── LAYOUT CSS — Header, Nav, Footer ─── */

/* ─── Header / Navbar ─── */
#site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-fixed);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--transition), box-shadow var(--transition);
}

[data-theme="dark"] #site-header {
  background: rgba(15, 23, 42, 0.95);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

/* ─── Logo ─── */
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
  flex-shrink: 0;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg { width: 20px; height: 20px; color: white; fill: white; }

.logo-text span { color: var(--color-primary); }

/* ─── Main Nav ─── */
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
}

/* ─── Categories Dropdown ─── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  background: none;
}

.nav-dropdown-toggle:hover {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
}

.nav-dropdown-toggle .chevron {
  width: 14px;
  height: 14px;
  transition: transform var(--transition);
}

.nav-dropdown.open .chevron { transform: rotate(180deg); }

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 12px;
  display: none;
  z-index: var(--z-dropdown);
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.nav-dropdown.open .nav-dropdown-menu { display: grid; animation: scaleIn 0.15s ease; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: pointer;
}

.dropdown-item:hover { background: var(--color-bg-secondary); }

.dropdown-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.dropdown-item-text { flex: 1; }
.dropdown-item-name { font-weight: 600; font-size: 0.875rem; color: var(--color-text); }
.dropdown-item-count { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 1px; }

/* ─── Header Search ─── */
.header-search {
  position: relative;
  width: 200px;
  transition: width 0.3s ease;
}

.header-search:focus-within { width: 300px; }

.header-search-input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  font-size: 0.875rem;
  color: var(--color-text);
  transition: all var(--transition);
}

.header-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-bg);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.header-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.header-search-icon svg { width: 16px; height: 16px; }

/* ─── Search Suggestions Dropdown ─── */
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: var(--z-dropdown);
  display: none;
}

.search-suggestions.visible { display: block; animation: fadeIn 0.15s ease; }

.search-suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.875rem;
}

.search-suggestion-item:hover { background: var(--color-bg-secondary); }
.search-suggestion-item img { width: 24px; height: 24px; border-radius: 4px; object-fit: contain; }

.search-suggestion-name { font-weight: 500; }
.search-suggestion-category { color: var(--color-text-muted); font-size: 0.75rem; }
.search-suggestion-history { color: var(--color-text-muted); }

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

/* ─── Dark Mode Toggle ─── */
.dark-mode-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-text-muted);
}

.dark-mode-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
}

.dark-mode-toggle svg { width: 18px; height: 18px; }
.dark-icon { display: none; }
[data-theme="dark"] .light-icon { display: none; }
[data-theme="dark"] .dark-icon { display: block; }

/* ─── Compare Button ─── */
.compare-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  transition: all var(--transition);
}

.compare-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); }
.compare-btn .count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: white;
  color: var(--color-primary);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: none;
}
.compare-btn.has-items .count-badge { display: inline-flex; }

/* ─── Hamburger Menu ─── */
.hamburger {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: all var(--transition);
}

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

/* ─── Mobile Drawer ─── */
.mobile-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: 300px;
  background: var(--color-card);
  border-left: 1px solid var(--color-border);
  z-index: var(--z-modal);
  padding: 24px 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  color: var(--color-text);
  transition: background var(--transition);
}

.mobile-nav-link:hover { background: var(--color-bg-secondary); }
.mobile-nav-link.active { background: rgba(99, 102, 241, 0.08); color: var(--color-primary); }

.drawer-overlay {
  position: fixed;
  inset: 0;
  top: 64px;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-modal) - 1);
  display: none;
}
.drawer-overlay.visible { display: block; }

/* ─── Main Content ─── */
#main-content { min-height: calc(100vh - 64px - 300px); }

/* ─── Section Headings ─── */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.section-subtitle {
  color: var(--color-text-muted);
  margin-top: 6px;
  font-size: 1rem;
}

.section-link {
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: gap var(--transition);
}
.section-link:hover { gap: 8px; }

/* ─── Footer ─── */
#site-footer {
  background: var(--color-bg-secondary);
  margin-top: 40px;
}

.footer-top {
  padding: 40px 0 24px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr 0.8fr;
  gap: 40px;
}

.footer-brand { display: flex; flex-direction: column; gap: 16px; }
.footer-brand-desc { color: var(--color-text-muted); font-size: 0.9rem; line-height: 1.6; max-width: 280px; }

.footer-col h4 {
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-link {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: color var(--transition);
  cursor: pointer;
}
.footer-link:hover { color: var(--color-primary); }


/* ─── Footer Bottom ─── */
.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-bottom-left { font-size: 0.875rem; color: var(--color-text-muted); }
.footer-bottom-right { display: flex; gap: 24px; }
.footer-bottom-link { font-size: 0.875rem; color: var(--color-text-muted); transition: color var(--transition); cursor: pointer; }
.footer-bottom-link:hover { color: var(--color-primary); }

/* ─── Breadcrumbs ─── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0;
  font-size: 0.875rem;
}

.breadcrumb-item { color: var(--color-text-muted); }
.breadcrumb-item.current { color: var(--color-text); font-weight: 500; }
.breadcrumb-sep { color: var(--color-text-light); }
.breadcrumb-item a { transition: color var(--transition); }
.breadcrumb-item a:hover { color: var(--color-primary); }

/* ─── Back to Top ─── */
#back-to-top {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: all var(--transition);
  z-index: var(--z-fixed);
}

#back-to-top.visible { opacity: 1; transform: translateY(0); }
#back-to-top:hover { background: var(--color-primary-dark); transform: translateY(-2px); }
#back-to-top svg { width: 20px; height: 20px; }

/* ─── Page Transition ─── */
.page-enter { animation: fadeInUp 0.3s ease; }

/* ─── Responsive Layout ─── */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  .footer-brand { grid-column: 1 / -1; }
  .header-search { width: 160px; }
}

@media (max-width: 768px) {
  .main-nav { display: none; }
  .header-search { display: none; }
  .hamburger { display: flex; }
  /* Hide compare btn from header — it's in the mobile drawer */
  .compare-btn { display: none; }
  .header-inner { gap: 8px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-top { padding: 32px 0 20px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .footer-bottom-right { flex-wrap: wrap; justify-content: center; }
  .section-title { font-size: 1.375rem; }
  .section-header { margin-bottom: 20px; }
}
