/* Left navigation drawer — default theme (#sidebar / #sidebar-overlay)
   Visual language aligned to navigation-drawer mock (no Tailwind).
   Brand fonts/colors come from store theme vars already injected by PHP
   (--primary-color, --tpl-font-family, --tpl-text-*, surfaces). */

html.nav-drawer-scroll-lock,
body.nav-drawer-scroll-lock,
body.noscroll {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.nav-drawer-scroll-lock {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
}

#sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

@supports ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  #sidebar-overlay.active {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

#sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/*
 * Drawer chrome uses fixed light neutrals (mock).
 * Store --primary-color only for accents (logo monogram, open badges, link hover).
 * Avoid section/product card theme vars — they muddy contrast on dark store themes.
 */
#sidebar {
  --nd-font: var(--tpl-font-family, inherit);
  --nd-primary: var(--primary-color, var(--theme-color, #c2d26a));
  --nd-on-primary: #0f172a;
  --nd-text: #0f172a;
  --nd-text-secondary: #64748b;
  --nd-text-muted: #94a3b8;
  --nd-surface: #ffffff;
  --nd-surface-subtle: #f8fafc;
  --nd-border: #f1f5f9;
  --nd-border-strong: #e2e8f0;
  --nd-ink: #0f172a;
  --nd-radius: 0.75rem;

  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 9999;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--nd-surface);
  color: var(--nd-text);
  border-right: 1px solid var(--nd-border);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
  padding: 0;
  max-height: 100vh;
  overflow: hidden;
  font-family: var(--nd-font), system-ui, sans-serif;
}

#sidebar.active {
  transform: translateX(0);
}

/* —— Header (div, not <header> — page header CSS was bleeding blue theme) —— */
#sidebar .nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  min-height: 4.25rem;
  height: auto;
  margin: 0;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  color: #0f172a;
  box-shadow: none;
  position: relative;
  top: auto;
  z-index: 2;
  flex-shrink: 0;
}

.nav-drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.nav-drawer-logo-wrap {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-drawer-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-drawer-logo-fallback {
  color: var(--nd-primary);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.nav-drawer-brand-text {
  min-width: 0;
}

.nav-drawer-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-drawer-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-drawer-close {
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-drawer-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

/* —— Body / sections —— */
.nav-drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}

.nav-drawer-section {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--nd-border);
}

.nav-drawer-section:last-child {
  border-bottom: 0;
}

.nav-drawer-section--utils {
  background: #f8fafc;
}

.nav-drawer-section--utils .nav-drawer-section-label {
  color: #94a3b8;
}

.nav-drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
}

.nav-drawer-section-label {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nd-text-muted);
}

.nav-drawer-section-meta {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--nd-text-secondary);
  background: var(--nd-surface-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: 0.375rem;
}

/* —— Catalog dept cards —— */
.nav-drawer-dept {
  border: 1px solid var(--nd-border-strong);
  border-radius: var(--nd-radius);
  background: var(--nd-surface);
  overflow: hidden;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-drawer-dept:last-child {
  margin-bottom: 0;
}

.nav-drawer-dept.is-open {
  border-color: color-mix(in srgb, var(--nd-primary) 55%, var(--nd-border-strong));
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.nav-drawer-dept-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s ease;
}

.nav-drawer-dept-toggle:hover {
  background: color-mix(in srgb, var(--nd-surface-subtle) 90%, transparent);
}

.nav-drawer-dept-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.nav-drawer-dept-img {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--nd-surface-subtle);
  flex-shrink: 0;
}

.nav-drawer-dept-copy {
  min-width: 0;
}

.nav-drawer-dept-name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--nd-text);
  line-height: 1.25;
}

.nav-drawer-dept-hint {
  margin: 0.1rem 0 0;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--nd-text-muted);
}

.nav-drawer-dept-aside {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.nav-drawer-dept-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  background: var(--nd-surface-subtle);
  color: var(--nd-text-secondary);
}

.nav-drawer-dept.is-open .nav-drawer-dept-badge {
  background: var(--nd-primary);
  color: var(--nd-on-primary);
}

.nav-drawer-dept-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
}

.nav-drawer-dept.is-open .nav-drawer-dept-body {
  grid-template-rows: 1fr;
}

.nav-drawer-dept-body-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  border-top: 1px solid transparent;
  background: #f8fafc;
  padding: 0 0.6rem;
  transition: opacity 0.22s ease, padding 0.28s ease, border-color 0.28s ease;
}

.nav-drawer-dept.is-open .nav-drawer-dept-body-inner {
  opacity: 1;
  border-top-color: #f1f5f9;
  padding: 0.55rem 0.6rem 0.65rem;
}

.nav-drawer-chevron {
  width: 1rem;
  height: 1rem;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.28s ease;
}

.nav-drawer-dept.is-open .nav-drawer-chevron {
  transform: rotate(180deg);
}

.nav-drawer-child,
.nav-drawer-all {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem 0.55rem 0.9rem;
  margin-bottom: 0.2rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  overflow: hidden;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, font-weight 0.15s ease;
}

.nav-drawer-child:last-of-type,
.nav-drawer-all:last-of-type {
  margin-bottom: 0;
}

.nav-drawer-row-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.nav-drawer-row-label {
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-drawer-row-count {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 0.625rem;
  font-weight: 500;
  color: #94a3b8;
  white-space: nowrap;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-drawer-all {
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.35rem;
}

.nav-drawer-all .nav-drawer-row-dot {
  background: transparent;
}

/* Recommended hover: white pill + primary left rail + primary dot + count pill */
.nav-drawer-child:hover,
.nav-drawer-all:hover {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}

.nav-drawer-child:hover::before,
.nav-drawer-all:hover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 4px;
  border-radius: 0 6px 6px 0;
  background: var(--nd-primary);
}

.nav-drawer-child:hover .nav-drawer-row-dot,
.nav-drawer-all:hover .nav-drawer-row-dot {
  background: var(--nd-primary);
}

.nav-drawer-child:hover .nav-drawer-row-count,
.nav-drawer-all:hover .nav-drawer-row-count {
  background: color-mix(in srgb, var(--nd-primary) 35%, #ffffff);
  color: #0f172a;
}

.nav-drawer-child.is-extra {
  display: none;
}

.nav-drawer-dept.is-expanded .nav-drawer-child.is-extra {
  display: flex;
}

.nav-drawer-leaf {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--nd-border-strong);
  border-radius: var(--nd-radius);
  background: var(--nd-surface);
  color: var(--nd-text);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-drawer-leaf .nav-drawer-dept-name {
  flex: 1 1 auto;
  min-width: 0;
}

.nav-drawer-leaf-count {
  flex-shrink: 0;
  font-size: 0.625rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
}

.nav-drawer-leaf:last-child {
  margin-bottom: 0;
}

.nav-drawer-leaf:hover {
  border-color: var(--nd-border-strong);
  background: var(--nd-surface-subtle);
  color: var(--nd-text);
  text-decoration: none;
}

.nav-drawer-more {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--nd-border-strong);
  border-radius: 0.5rem;
  background: var(--nd-surface);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--nd-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-drawer-more:hover {
  color: var(--nd-text);
  border-color: var(--nd-border-strong);
}

.nav-drawer-more svg {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--nd-text-muted);
}

.nav-drawer-dept.is-expanded .nav-drawer-more {
  display: none;
}

/* —— Pages links —— */
.nav-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-drawer-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.7rem;
  border-radius: 0.65rem;
  color: var(--nd-text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-drawer-link:hover,
.nav-drawer-link:focus {
  background: color-mix(in srgb, var(--nd-primary) 16%, var(--nd-surface));
  color: var(--nd-text);
  text-decoration: none;
}

/* —— Quick utilities —— */
.nav-drawer-utils {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.nav-drawer-util {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.nav-drawer-util:hover {
  border-color: #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  text-decoration: none;
}

.nav-drawer-util-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.nav-drawer-util--wa {
  grid-column: 1 / -1;
  justify-content: space-between;
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  margin-top: 0.15rem;
}

.nav-drawer-util--wa:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #065f46;
}

.nav-drawer-util--wa .nav-drawer-util-icon {
  background: #25d366;
  color: #fff;
}

.nav-drawer-wa-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #065f46;
}

.nav-drawer-wa-pulse {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: nav-drawer-pulse 1.6s ease-out infinite;
}

.nav-drawer-wa-cta {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #047857;
}

@keyframes nav-drawer-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* —— Footer socials —— */
.nav-drawer-footer {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--nd-border);
  background: var(--nd-surface-subtle);
  display: flex;
  align-items: center;
  gap: 0.35rem 0.75rem;
  flex-wrap: wrap;
}

.nav-drawer-social {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--nd-text-secondary);
  text-decoration: none;
}

.nav-drawer-social:hover {
  color: var(--nd-text);
  text-decoration: none;
}

.nav-drawer-social-sep {
  color: var(--nd-text-muted);
  font-size: 0.65rem;
  user-select: none;
}

.nav-drawer-body::-webkit-scrollbar {
  width: 6px;
}

.nav-drawer-body::-webkit-scrollbar-thumb {
  background: var(--nd-border-strong);
  border-radius: 999px;
}

.nav-drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

@media (min-width: 640px) {
  .nav-drawer-header {
    padding: 1.15rem 1.25rem;
  }
}
