/**
 * Fitment Data Hub — storefront selector styles.
 * Self-contained, theme-agnostic; everything scoped under .fdh-selector. No external assets.
 * Aesthetic: a refined "precision fitment instrument" — structured card, technical micro-labels,
 * monospace VIN, confident brand red accent, a strong result card.
 */

.fdh-selector {
  --fdh-accent: #c8102e;
  --fdh-accent-dark: #a10d24;
  --fdh-ink: #14181c;
  --fdh-ink-2: #3c444c;
  --fdh-muted: #6b747d;
  --fdh-line: #e7eaee;
  --fdh-line-2: #d4dade;
  --fdh-surface: #ffffff;
  --fdh-surface-2: #f6f8fa;
  --fdh-surface-3: #eef1f5;
  --fdh-ok: #157347;
  --fdh-ok-bg: #eaf6ef;
  --fdh-ok-line: #bfe3cd;
  --fdh-warn: #8a5300;
  --fdh-warn-bg: #fbf2e0;
  --fdh-warn-line: #f0d9a8;
  --fdh-radius: 16px;
  --fdh-radius-ctl: 10px;
  --fdh-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  container-type: inline-size;
  container-name: fdh;
  box-sizing: border-box;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 1.5em;
  overflow: hidden;
  background: var(--fdh-surface);
  border: 1px solid var(--fdh-line);
  border-radius: var(--fdh-radius);
  box-shadow: 0 1px 2px rgba(20, 24, 28, 0.04), 0 10px 30px -14px rgba(20, 24, 28, 0.22);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fdh-ink);
  text-align: left;
}

.fdh-selector *,
.fdh-selector *::before,
.fdh-selector *::after { box-sizing: border-box; }

.fdh-selector [hidden] { display: none !important; }

.fdh-selector svg { display: block; }

/* ---- header --------------------------------------------------------------------------- */
.fdh-accentbar { height: 4px; background: var(--fdh-accent); }

.fdh-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 22px;
  background: var(--fdh-surface-2);
  border-bottom: 1px solid var(--fdh-line);
}

.fdh-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--fdh-accent);
  color: #fff;
}
.fdh-mark svg { width: 24px; height: 24px; }

.fdh-head-text { display: flex; flex-direction: column; min-width: 0; }
.fdh-title { font-size: 18px; font-weight: 700; line-height: 1.25; color: var(--fdh-ink); letter-spacing: -0.01em; }
.fdh-subtitle { font-size: 13px; color: var(--fdh-muted); margin-top: 2px; }

/* ---- body ----------------------------------------------------------------------------- */
.fdh-body { padding: 20px 22px; }

.fdh-microlabel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fdh-muted);
}
.fdh-microlabel svg { width: 13px; height: 13px; opacity: 0.85; }

/* VIN module */
.fdh-vin { margin-bottom: 4px; }
.fdh-vin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fdh-vin-label { flex: 1 1 100%; margin-bottom: 2px; }

.fdh-vin-input {
  flex: 1 1 240px;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  background: var(--fdh-surface);
  border: 1px solid var(--fdh-line-2);
  border-radius: var(--fdh-radius-ctl);
  font-family: var(--fdh-mono);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fdh-ink);
}
.fdh-vin-input::placeholder { text-transform: none; letter-spacing: normal; color: #9aa3ac; font-family: -apple-system, "Segoe UI", sans-serif; }

.fdh-vin-btn { flex: 0 0 auto; }

.fdh-vin-msg { flex: 1 1 100%; margin-top: 2px; font-size: 13px; color: var(--fdh-muted); }
.fdh-vin-msg:empty { display: none; }

/* divider */
.fdh-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fdh-muted);
}
.fdh-divider::before, .fdh-divider::after { content: ""; flex: 1; height: 1px; background: var(--fdh-line); }

/* fields */
.fdh-fields { display: flex; flex-wrap: wrap; gap: 12px; }

.fdh-field-wrap { display: flex; flex-direction: column; gap: 6px; flex: 1 1 150px; min-width: 140px; cursor: pointer; }
.fdh-field-wrap:has(.fdh-field[hidden]) { display: none; }

.fdh-field {
  width: 100%;
  min-height: 48px;
  padding: 0 34px 0 13px;
  background: var(--fdh-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%236b747d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center;
  border: 1px solid var(--fdh-line-2);
  border-radius: var(--fdh-radius-ctl);
  font-size: 15px;
  font-family: inherit;
  color: var(--fdh-ink);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.fdh-field:hover:not(:disabled) { border-color: var(--fdh-muted); }
.fdh-field:disabled { background-color: var(--fdh-surface-3); color: #a7aeb5; cursor: not-allowed; }

/* buttons */
.fdh-submit, .fdh-vin-btn, .fdh-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  background: var(--fdh-accent);
  border: 1px solid var(--fdh-accent);
  border-radius: var(--fdh-radius-ctl);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.fdh-submit svg, .fdh-add svg { width: 18px; height: 18px; }
.fdh-submit { width: 100%; margin-top: 18px; }

.fdh-submit:hover, .fdh-vin-btn:hover, .fdh-add:hover { background: var(--fdh-accent-dark); border-color: var(--fdh-accent-dark); }
.fdh-submit:active, .fdh-vin-btn:active, .fdh-add:active { transform: translateY(1px); }
.fdh-submit:disabled, .fdh-vin-btn:disabled, .fdh-add:disabled { background: #cdd2d8; border-color: #cdd2d8; color: #eef1f4; cursor: not-allowed; }

.fdh-selector :focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.22); border-color: var(--fdh-accent); }

/* ---- result --------------------------------------------------------------------------- */
.fdh-result { margin-top: 4px; }
.fdh-result:empty { margin-top: 0; }

.fdh-result-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 13px;
  border: 1px solid var(--fdh-line);
  background: var(--fdh-surface-2);
  animation: fdh-rise 0.28s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes fdh-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.fdh-result-match { background: var(--fdh-ok-bg); border-color: var(--fdh-ok-line); }
.fdh-result-incompatible, .fdh-result-none { background: var(--fdh-warn-bg); border-color: var(--fdh-warn-line); }

.fdh-result-heading {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fdh-ink);
}
.fdh-result-heading::before {
  content: "";
  flex: 0 0 auto;
  width: 22px; height: 22px; margin-top: 1px;
  background: no-repeat center / 22px 22px;
}
.fdh-result-match .fdh-result-heading::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%23157347'/%3E%3Cpath d='M7 12.5l3.2 3.2L17 9' fill='none' stroke='white' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.fdh-result-incompatible .fdh-result-heading::before, .fdh-result-none .fdh-result-heading::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%238a5300'/%3E%3Cpath d='M12 7v6M12 16.5v.5' fill='none' stroke='white' stroke-width='2.1' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* Product-page "we'll verify" state — neutral/informational, distinct from the amber no-fit. */
.fdh-result-verify { background: var(--fdh-surface-3); border-color: var(--fdh-line-2); }
.fdh-result-verify .fdh-result-heading::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%234a5568'/%3E%3Cpath d='M12 11v5' fill='none' stroke='white' stroke-width='2.1' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='7.5' r='1.3' fill='white'/%3E%3C/svg%3E");
}

.fdh-result-product { margin-top: 12px; font-size: 15px; font-weight: 600; }
.fdh-result-product a { color: var(--fdh-ink); text-decoration: none; border-bottom: 1px solid rgba(20,24,28,0.25); }
.fdh-result-product a:hover { border-bottom-color: var(--fdh-ink); }

/* Catalog mode — a list of fitting products, each with its own add-to-cart. */
.fdh-catalog-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.fdh-catalog-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; background: var(--fdh-surface); border: 1px solid var(--fdh-line); border-radius: var(--fdh-radius-ctl); flex-wrap: wrap; }
.fdh-catalog-info { flex: 1 1 200px; min-width: 0; }
.fdh-catalog-info .fdh-result-product { margin-top: 0; }
.fdh-catalog-info .fdh-result-price { margin-top: 4px; font-size: 18px; }
.fdh-catalog-add { flex: 0 0 auto; }
.fdh-catalog .fdh-catalog-add .fdh-add { width: auto; margin-top: 0; }
@container fdh (max-width: 460px) {
  .fdh-catalog-item { align-items: stretch; }
  .fdh-catalog .fdh-catalog-add, .fdh-catalog .fdh-catalog-add .fdh-add { width: 100%; }
}

.fdh-result-price { margin-top: 6px; font-size: 22px; font-weight: 700; color: var(--fdh-ink); }
.fdh-result-price .woocommerce-Price-amount { font-size: inherit; font-weight: inherit; }

.fdh-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.fdh-badge-verified { background: #d7efe0; color: #0f5132; }
.fdh-badge-high { background: #d8e7fb; color: #12467f; }
.fdh-badge-medium { background: #fbeccb; color: #7a5200; }
.fdh-badge-unverified { background: #e4e7ea; color: #4a525a; }

.fdh-result-notes { margin-top: 12px; font-size: 13.5px; color: var(--fdh-ink-2); }

.fdh-add { width: 100%; margin-top: 16px; }
.fdh-add-msg { margin-top: 8px; font-size: 13px; color: var(--fdh-accent); }
.fdh-add-msg:empty { display: none; }

/* saved-vehicle banner */
.fdh-saved-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 16px 22px -4px; padding: 11px 14px;
  background: var(--fdh-surface-3); border: 1px solid var(--fdh-line); border-radius: var(--fdh-radius-ctl);
  font-size: 13.5px; color: var(--fdh-ink-2);
}
.fdh-saved-banner strong { color: var(--fdh-ink); }
.fdh-saved-banner a, .fdh-change-vehicle {
  flex-shrink: 0; background: none; border: none; padding: 0;
  color: var(--fdh-accent); font-size: 13.5px; font-weight: 600; text-decoration: underline; cursor: pointer;
}
.fdh-saved-banner a:hover, .fdh-change-vehicle:hover { color: var(--fdh-accent-dark); }

/* ---- footer --------------------------------------------------------------------------- */
.fdh-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--fdh-surface-2); border-top: 1px solid var(--fdh-line);
  font-size: 12px; color: var(--fdh-muted);
}
.fdh-foot-left { display: inline-flex; align-items: center; gap: 6px; }
.fdh-foot-left svg { width: 14px; height: 14px; }
.fdh-foot strong { color: var(--fdh-ink); font-weight: 700; }

/* ---- loading -------------------------------------------------------------------------- */
.fdh-selector .is-loading { position: relative; pointer-events: none; opacity: 0.6; }
.fdh-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff; border-radius: 50%; animation: fdh-spin 0.7s linear infinite; }
@keyframes fdh-spin { to { transform: rotate(360deg); } }
.fdh-dots { display: inline-flex; gap: 4px; }
.fdh-dots span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: fdh-dot 1s ease-in-out infinite; }
.fdh-dots span:nth-child(2) { animation-delay: 0.15s; }
.fdh-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes fdh-dot { 0%,80%,100% { opacity: 0.3; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }

.fdh-msg { margin-top: 10px; font-size: 13.5px; color: var(--fdh-muted); }
.fdh-msg.fdh-error, .fdh-error { color: var(--fdh-accent); }

@media (prefers-reduced-motion: reduce) {
  .fdh-selector *, .fdh-selector *::before, .fdh-selector *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
  }
}

/* ---- responsive: stack on a narrow CONTAINER (theme column), not just narrow viewport --- */
@container fdh (max-width: 440px) {
  .fdh-head { padding: 16px 18px; }
  .fdh-body { padding: 18px; }
  .fdh-vin-input, .fdh-vin-btn { flex: 1 1 100%; }
  .fdh-fields { flex-direction: column; }
  .fdh-field-wrap { flex-basis: auto; }
  .fdh-saved-banner { margin: 14px 18px -4px; flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .fdh-head { padding: 16px 18px; }
  .fdh-body { padding: 18px; }
  .fdh-vin-input, .fdh-vin-btn { flex: 1 1 100%; }
  .fdh-fields { flex-direction: column; }
  .fdh-field-wrap { flex-basis: auto; }
}
