/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060c18;
  --surface: #0c1624;
  --surface-2: #111e30;
  --surface-3: #162438;
  --border: #1d3050;
  --border-light: #254060;
  --primary: #38bdf8;
  --primary-dim: #1e6fa8;
  --primary-glow: rgba(56,189,248,0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.15);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --text: #dde8f5;
  --text-2: #7ca0bf;
  --text-3: #3d6080;
  --mono: 'Space Mono', monospace;
  --sans: 'Barlow', sans-serif;
  --cond: 'Barlow Condensed', sans-serif;

  --type-gate: #38bdf8;
  --type-globe: #a78bfa;
  --type-check: #34d399;
  --type-ball: #fb923c;
  --type-butterfly: #f472b6;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

/* Ambient grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(56,189,248,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56,189,248,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 40%, rgba(56,189,248,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(99,102,241,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* === HEADER === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6,12,24,0.92);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Logo */
.logo-link { text-decoration: none; flex-shrink: 0; }

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-hook {
  width: 28px;
  height: 52px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-name {
  font-family: var(--cond);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.12em;
  color: var(--text);
}

.logo-sub {
  font-family: var(--cond);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--primary);
  margin-top: 1px;
}

/* Header search */
.header-search { flex: 1; max-width: 540px; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-2);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 40px 10px 42px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.search-input:focus {
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.clear-search-btn svg { width: 14px; height: 14px; }
.clear-search-btn.visible { opacity: 1; }
.clear-search-btn:hover { color: var(--text); }

/* Language nav */
.lang-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.lang-btn:hover { background: var(--surface-2); color: var(--text); }

.lang-btn.active {
  background: var(--primary-glow);
  border-color: var(--primary-dim);
  color: var(--primary);
}

/* === HERO STRIP === */
.hero-strip {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, var(--surface) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 24px 20px;
}

.hero-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-title {
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.05;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 4px;
  font-weight: 300;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  white-space: nowrap;
}

.results-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
}

.results-count strong {
  color: var(--primary);
  font-weight: 700;
}

.clear-filters-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.clear-filters-btn:hover {
  border-color: var(--primary-dim);
  color: var(--primary);
  background: var(--primary-glow);
}

/* === APP LAYOUT === */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  min-height: calc(100vh - 180px);
  padding: 0 24px;
}

/* === FILTERS PANEL === */
.filters-panel {
  padding: 20px 20px 20px 0;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.filters-panel::-webkit-scrollbar { width: 4px; }
.filters-panel::-webkit-scrollbar-track { background: transparent; }
.filters-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Filter section */
.filter-section {
  margin-bottom: 4px;
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  user-select: none;
}

.filter-section-header:hover { background: var(--surface-2); }

.filter-section-label {
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}

.filter-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.filter-section.collapsed .filter-chevron { transform: rotate(-90deg); }

.filter-section-body {
  padding: 4px 4px 8px 4px;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.filter-section.collapsed .filter-section-body { display: none; }

/* Filter active count badge */
.filter-count-badge {
  background: var(--primary-glow);
  border: 1px solid var(--primary-dim);
  color: var(--primary);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
}

/* Checkboxes */
.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.filter-option:hover { background: var(--surface-2); }

.filter-option input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-light);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s;
}

.filter-option input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.filter-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 8px;
  height: 5px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg);
}

.filter-option-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
  flex: 1;
}

.filter-option-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}

/* Type color dots */
.type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Toggle switches */
.filter-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.filter-toggle-row:hover { background: var(--surface-2); }

.filter-toggle-label {
  font-size: 13px;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: all 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--primary-glow);
  border-color: var(--primary-dim);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: var(--primary);
}

/* DN size chips grid */
.dn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 4px 4px 12px;
}

.dn-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.dn-chip:hover { border-color: var(--primary-dim); color: var(--primary); }
.dn-chip.active { background: var(--primary-glow); border-color: var(--primary-dim); color: var(--primary); }

/* Manufacturer scrollable list */
.mfr-list {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* === RESULTS AREA === */
.results-area {
  padding: 20px 0 20px 24px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* === VALVE CARD === */
.valve-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: cardIn 0.35s ease both;
  position: relative;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.valve-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border-color: var(--border-light);
}

/* Type accent stripe */
.valve-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.valve-card.type-gate::before    { background: var(--type-gate); }
.valve-card.type-globe::before   { background: var(--type-globe); }
.valve-card.type-check::before   { background: var(--type-check); }
.valve-card.type-ball::before    { background: var(--type-ball); }
.valve-card.type-butterfly::before { background: var(--type-butterfly); }

/* Card header */
.card-header {
  padding: 18px 18px 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.card-type-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.type-gate    .card-type-icon { background: rgba(56,189,248,0.1); }
.type-globe   .card-type-icon { background: rgba(167,139,250,0.1); }
.type-check   .card-type-icon { background: rgba(52,211,153,0.1); }
.type-ball    .card-type-icon { background: rgba(251,146,60,0.1); }
.type-butterfly .card-type-icon { background: rgba(244,114,182,0.1); }

.card-title-group { flex: 1; min-width: 0; }

.card-type-label {
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.type-gate    .card-type-label { color: var(--type-gate); }
.type-globe   .card-type-label { color: var(--type-globe); }
.type-check   .card-type-label { color: var(--type-check); }
.type-ball    .card-type-label { color: var(--type-ball); }
.type-butterfly .card-type-label { color: var(--type-butterfly); }

.card-model {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  align-items: flex-end;
}

/* Card manufacturer */
.card-manufacturer {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.flag { font-size: 18px; line-height: 1; }

.mfr-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.mfr-country {
  font-size: 12px;
  color: var(--text-2);
  margin-left: 2px;
}

/* Card specs grid */
.card-specs {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.spec-item { display: flex; flex-direction: column; gap: 2px; }

.spec-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.spec-value {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 400;
  line-height: 1.3;
}

.spec-value.mono { font-family: var(--mono); font-size: 11px; }

/* Certificates */
.card-certs {
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.cert-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Stock holders */
.card-stock {
  padding: 10px 18px;
  font-size: 12px;
  color: var(--text-2);
}

.stock-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 3px;
}

.stock-names { color: var(--text-2); font-size: 12px; }

/* === BADGES === */
.badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-avl {
  background: var(--amber-dim);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--amber);
}

.badge-no-avl {
  background: rgba(100,116,139,0.1);
  border: 1px solid rgba(100,116,139,0.2);
  color: var(--text-3);
}

.badge-stock {
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.25);
  color: var(--green);
}

.badge-no-stock {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--red);
}

/* === NO RESULTS === */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
}

.no-results-icon { font-size: 48px; margin-bottom: 16px; }

.no-results-title {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 8px;
}

.no-results-text { font-size: 14px; color: var(--text-2); }

/* === LOADING === */
.filters-loading, .results-loading {
  display: flex;
  justify-content: center;
  padding: 60px 0;
  grid-column: 1 / -1;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === FOOTER === */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-hook { width: 16px; height: 30px; }

.footer-name {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--text-2);
}

.footer-note {
  font-size: 12px;
  color: var(--text-3);
}

/* === MOBILE FILTER BAR === */
.mobile-filter-bar {
  display: none;
  position: sticky;
  top: 64px;
  z-index: 50;
  background: rgba(6,12,24,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-filter-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 9px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.mobile-filter-btn:hover,
.mobile-filter-btn[aria-expanded="true"] {
  border-color: var(--primary-dim);
  color: var(--primary);
  background: var(--primary-glow);
}

.mobile-results-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}

/* Overlay */
.filter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.filter-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Close button inside panel (mobile only) */
.close-filters-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
}

.close-filters-btn:hover { color: var(--text); border-color: var(--border-light); }

/* Lang label hide on small screens */
.lang-label { display: inline; }

/* Mobile language section in filter panel */
.mobile-lang-section { display: none; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }
.mobile-lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px 12px;
}
.mobile-lang-btn { font-size: 13px !important; padding: 7px 12px !important; }

@media (max-width: 860px) {
  /* Hide header lang nav, show it in filter panel instead */
  .lang-nav { display: none; }
  .mobile-lang-section { display: block; }
}

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 240px 1fr; }
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  /* Mobile filter bar shows */
  .mobile-filter-bar { display: flex; }

  /* Filter panel: slides in from left as overlay */
  .filters-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 100;
    background: var(--surface);
    border-right: 1px solid var(--border-light);
    border-bottom: none;
    padding: 16px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    max-height: 100vh;
  }

  .filters-panel.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }

  .filter-overlay { display: block; }

  .close-filters-btn { display: flex; }

  .results-area { padding: 16px 0; }

  /* Hide desktop hero results count on mobile (shown in mobile bar) */
  .hero-meta { display: none; }

  .hero-strip { padding: 20px 16px 16px; }
  .hero-inner { flex-direction: column; align-items: flex-start; gap: 8px; }

  .results-grid { grid-template-columns: 1fr; }
  .header-inner { gap: 10px; }
  .header-search { max-width: none; }
}

@media (max-width: 640px) {
  /* Language: hide text labels, show only flags */
  .lang-label { display: none; }
  .lang-btn { padding: 6px 8px; font-size: 16px; }
  .logo-sub { display: none; }
}

@media (max-width: 420px) {
  .hero-title { font-size: 26px; }
  .card-specs { grid-template-columns: 1fr; }
}

/* Staggered card animation delays */
.valve-card:nth-child(1)  { animation-delay: 0.02s; }
.valve-card:nth-child(2)  { animation-delay: 0.04s; }
.valve-card:nth-child(3)  { animation-delay: 0.06s; }
.valve-card:nth-child(4)  { animation-delay: 0.08s; }
.valve-card:nth-child(5)  { animation-delay: 0.10s; }
.valve-card:nth-child(6)  { animation-delay: 0.12s; }
.valve-card:nth-child(7)  { animation-delay: 0.14s; }
.valve-card:nth-child(8)  { animation-delay: 0.16s; }
.valve-card:nth-child(9)  { animation-delay: 0.18s; }
.valve-card:nth-child(10) { animation-delay: 0.20s; }
.valve-card:nth-child(11) { animation-delay: 0.22s; }
.valve-card:nth-child(12) { animation-delay: 0.24s; }
