/* AnodeFoundry - Minimal Industrial B2B Design */
:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #dce4ed;
  --border-strong: #b6c5d6;
  --navy: #0f2942;
  --navy-dark: #091b2d;
  --accent: #1d4ed8;
  --text: #0f172a;
  --muted: #475569;
  --al: #0284c7;
  --al-bg: #e0f2fe;
  --mg: #a16207;
  --mg-bg: #fef9c3;
  --zn: #334155;
  --zn-bg: #e2e8f0;
  --ok: #15803d;
  --err: #b91c1c;
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
.wrap { max-width: 1220px; margin: 0 auto; padding: 0 16px; }

/* Header */
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--accent);
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-sub {
  font-size: 0.78rem;
  font-weight: 400;
  color: #cbd5e1;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.nav a {
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  text-decoration: none;
}
.nav a.nav-cta {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.nav a.nav-cta:hover { background: #1e40af; }

/* Search Strip */
.search-bar-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.search-form {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.94rem;
  background: #fff;
}
.search-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(15,41,66,0.14);
  z-index: 60;
  max-height: 380px;
  overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.sr-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #eef2f6;
  color: var(--text);
  font-size: 0.88rem;
}
.sr-item:hover { background: var(--surface); text-decoration: none; }
.sr-pid { font-weight: 700; color: var(--navy); white-space: nowrap; }
.sr-meta { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-note { padding: 7px 12px; background: #fffbeb; color: #92400e; font-size: 0.84rem; border-bottom: 1px solid #fde68a; }

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); text-decoration: none; }
.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #1e40af; color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 0.8rem; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.badge-al { background: var(--al-bg); color: var(--al); }
.badge-mg { background: var(--mg-bg); color: var(--mg); }
.badge-zn { background: var(--zn-bg); color: var(--zn); }
.badge-oem { background: #eef2ff; color: #3730a3; font-weight: 600; }
.badge-tag { background: #f1f5f9; color: var(--navy); font-weight: 600; }

/* Compact Hero / Intro */
.compact-intro {
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
}
.compact-intro h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: var(--navy);
}
.intro-line {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill:hover { border-color: var(--accent); background: #eff6ff; text-decoration: none; }
.pill span.cnt { color: var(--muted); font-weight: 400; font-size: 0.76rem; }

/* Sections & Grids */
.sec { padding: 16px 0; }
.sec-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.sec-head h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--navy);
}
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 10px;
}
.card-img-box {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
  overflow: hidden;
}
.card-img-box img { max-height: 142px; width: auto; object-fit: contain; }
.card-noimg {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--surface);
  padding: 14px;
  border: 1px dashed var(--border-strong);
  width: 100%;
  text-align: center;
}
.card-sku { font-weight: 700; color: var(--navy); font-size: 0.96rem; }
.card-title { font-size: 0.85rem; color: var(--text); margin: 3px 0 6px; font-weight: 500; }
.card-specs { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.card-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

/* Filter Strip */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 10px 0 12px;
}
.filter-bar input[type="text"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.86rem;
  min-width: 190px;
  flex: 1;
}
.filter-btn {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--navy);
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 4px; }
table.spec-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
}
table.spec-tbl th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 7px 9px;
  font-weight: 600;
  white-space: nowrap;
}
table.spec-tbl td {
  padding: 7px 9px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
table.spec-tbl tr:hover td { background: #f8fafc; }
table.spec-tbl tr.row-selected td { background: #eff6ff; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
/* Compact All-Models table styling (saves ~1MB inline styles) */
#all-models-tbl td { font-size: 0.8rem; padding: 5px 8px; }
#all-models-tbl td:nth-child(1),
#all-models-tbl td:nth-child(4),
#all-models-tbl td:nth-child(5) {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}
#all-models-tbl td:nth-child(1) { font-weight: 700; white-space: nowrap; }
.kit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.guide-body { max-width: 880px; }
.guide-body h2 { font-size: 1.08rem; color: var(--navy); margin: 16px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.guide-body p { margin: 8px 0; font-size: 0.92rem; }
.guide-body ul { margin: 6px 0 10px 18px; padding: 0; font-size: 0.9rem; }
.guide-body li { margin-bottom: 4px; }

/* Product Detail Page */
.crumb {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 0 6px;
}
.pdp-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
  padding-bottom: 16px;
}
.pdp-gallery {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  background: #fff;
}
.pdp-main-img {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdp-main-img img { max-height: 300px; width: auto; object-fit: contain; }
.pdp-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eef2f6;
}
.pdp-thumb {
  width: 58px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdp-thumb.active { border: 2px solid var(--accent); }
.pdp-thumb img { max-height: 50px; object-fit: contain; }
.pdp-info h1 { margin: 0 0 6px; font-size: 1.32rem; color: var(--navy); }
.kv-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  margin: 8px 0 12px;
}
.kv-strip b { color: var(--navy); }
.kit-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.pdp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

/* Factory Gallery */
.fac-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.fac-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}
.fac-card img { width: 100%; height: 190px; object-fit: cover; }
.fac-cap { padding: 8px 10px; font-size: 0.83rem; }
.fac-cap strong { display: block; color: var(--navy); }

/* Forms & Modals */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg.full { grid-column: 1 / -1; }
.fg label { font-size: 0.82rem; font-weight: 600; color: var(--navy); }
.fg input, .fg textarea, .fg select {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
}
.form-msg { margin-top: 8px; padding: 8px 10px; border-radius: 4px; font-size: 0.86rem; display: none; }
.form-msg.ok { display: block; background: #dcfce7; color: var(--ok); border: 1px solid #86efac; }
.form-msg.err { display: block; background: #fee2e2; color: var(--err); border: 1px solid #fca5a5; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 27, 45, 0.58);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 6px;
  max-width: 540px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.modal-head h3 { margin: 0; color: var(--navy); font-size: 1.05rem; }

/* AI Assistant Floating Widget (Loaded Async After Onload) */
.ai-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15,41,66,0.22);
}
.ai-panel {
  position: fixed;
  right: 18px;
  bottom: 66px;
  width: 340px;
  max-width: calc(100vw - 24px);
  height: 420px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(15,41,66,0.22);
  z-index: 85;
  display: none;
  flex-direction: column;
}
.ai-panel.open { display: flex; }
.ai-head {
  background: var(--navy);
  color: #fff;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ai-log {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}
.ai-msg { padding: 7px 10px; border-radius: 5px; max-width: 88%; white-space: pre-wrap; word-break: break-word; }
.ai-msg.bot { background: #fff; border: 1px solid var(--border); align-self: flex-start; }
.ai-msg.usr { background: var(--navy); color: #fff; align-self: flex-end; }
.ai-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.ai-input-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Footer */
.footer {
  margin-top: 24px;
  background: var(--navy-dark);
  color: #cbd5e1;
  padding: 18px 0;
  font-size: 0.82rem;
}
.footer a { color: #93c5fd; }
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 760px) {
  .pdp-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
}
