/* =========================================================================
   Fil Doux search page — matched to the shop page (fildoux.com/shop)
   Fonts come from your theme (Work Sans for text, Fields for headings).
   ========================================================================= */
#fdms {
  --fd-navy: #041e42;
  --fd-text: #363636;
  --fd-gray: #e4e7e9;
  --fd-gray-dark: #d3d7da;
  --fd-coral: #e5554f;
  --fd-line: #dddedf;
  --fd-small: clamp(10.5px, 0.785vw, 12.5px); /* same scaling as the shop cards */
  margin: 1rem 0 3rem;
  color: var(--fd-text);
  font-family: inherit;
}
#fdms *, #fdms *::before, #fdms *::after { box-sizing: border-box; }
.fdms-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Search box + AI toggle ---------- */
#fdms-searchbox { margin-bottom: 1.5rem; }
.fdms-top { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.fdms-top #fdms-searchbox { flex: 1 1 280px; margin-bottom: 0; }

#fdms .ais-SearchBox-form {
  height: 46px; border: 1px solid var(--fd-line); border-radius: 0; box-shadow: none;
  background: #fff; font-family: inherit;
}
#fdms .ais-SearchBox-form::before { left: 14px; filter: grayscale(1) brightness(0.4); }
#fdms .ais-SearchBox-input {
  font: inherit; font-size: 15px; color: var(--fd-text); padding-left: 42px; border: 0; box-shadow: none;
}
#fdms .ais-SearchBox-form:focus-within { border-color: var(--fd-navy); }
#fdms .ais-SearchBox-input::placeholder { color: #8a8d90; opacity: 1; }
.fdms-ai-on .ais-SearchBox-form { border-color: var(--fd-navy); }

.fdms-ai-toggle {
  display: inline-flex; align-items: center; gap: 0.6rem; background: none; border: 0; padding: 0.25rem;
  cursor: pointer; font: inherit; color: var(--fd-navy); white-space: nowrap;
  text-transform: uppercase; font-size: 15px; letter-spacing: 0.5px;
}
.fdms-ai-track { position: relative; width: 40px; height: 22px; border-radius: 11px; background: #c8ccd0; transition: background 0.2s; }
.fdms-ai-knob {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 0.2s;
}
.fdms-ai-toggle[aria-checked="true"] .fdms-ai-track { background: var(--fd-navy); }
.fdms-ai-toggle[aria-checked="true"] .fdms-ai-knob { transform: translateX(18px); }
.fdms-ai-toggle:focus-visible { outline: 2px solid var(--fd-navy); outline-offset: 3px; }

/* ---------- Layout: filters | results (same proportions as the shop) ---------- */
.fdms-layout { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; align-items: start; }

/* ---------- Filters: accordions like the shop ---------- */
.fdms-facet { margin-bottom: 0.6rem; }
.fdms-facet > summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font-size: 16.5px; line-height: 2.2; text-transform: uppercase; color: var(--fd-navy); font-weight: 400;
}
.fdms-facet > summary::-webkit-details-marker { display: none; }
.fdms-facet > summary::after {
  content: ""; width: 8px; height: 8px; margin-right: 6px; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.2s;
}
.fdms-facet[open] > summary::after { transform: rotate(45deg); }
.fdms-facet > div { padding: 0.75rem 0 0.5rem; }

#fdms-clear .ais-ClearRefinements-button {
  display: inline-block; width: auto; text-align: left; justify-content: flex-start;
  background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 0.75rem; height: auto;
  font: inherit; font-size: 13px; color: var(--fd-navy); text-decoration: underline; cursor: pointer;
}
#fdms-clear .ais-ClearRefinements-button--disabled { display: none; }

/* Color swatches: 30px squares with soft shadow, check mark when selected */
#fdms .fdms-swatches .ais-RefinementList-list { display: flex; flex-wrap: wrap; gap: 0; margin: 0; padding: 0; list-style: none; }
#fdms .fdms-swatches .ais-RefinementList-item { margin: 0 12px 12px 0; padding: 0; }
#fdms .fdms-swatches .ais-RefinementList-label { display: block; cursor: pointer; position: relative; }
.fdms-swatch { display: block; width: 30px; height: 30px; box-shadow: rgb(204, 204, 204) 1px 2px 3px; }
.fdms-swatches .ais-RefinementList-item--selected .fdms-swatch { outline: 2px solid var(--fd-navy); outline-offset: 2px; }
.fdms-swatches .ais-RefinementList-item--selected .ais-RefinementList-label::after {
  content: ""; position: absolute; left: 11px; top: 7px; width: 7px; height: 12px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
  filter: drop-shadow(0 0 1px rgba(0,0,0,.8));
}
.fdms-swatches .ais-RefinementList-label:focus-within .fdms-swatch { outline: 2px solid var(--fd-navy); outline-offset: 2px; }

/* Textile type checkboxes */
#fdms-fabric .ais-RefinementList-list, #fdms-collection .ais-RefinementList-list { margin: 0; padding: 0; list-style: none; }
#fdms-fabric .ais-RefinementList-item, #fdms-collection .ais-RefinementList-item { margin-bottom: 4px; }
#fdms-fabric .ais-RefinementList-label, #fdms-collection .ais-RefinementList-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 15px; }
#fdms-fabric .ais-RefinementList-checkbox, #fdms-collection .ais-RefinementList-checkbox { width: 14px; height: 14px; margin: 0; accent-color: var(--fd-navy); box-shadow: none; }
.fdms-count { opacity: 0.7; }

/* Availability: "Min yards [ ] Go" */
.fdms-min { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.fdms-min input {
  width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--fd-line); border-radius: 0; font: inherit; font-size: 14px;
}
.fdms-min button {
  background: var(--fd-gray); border: 1px solid var(--fd-line); border-radius: 0; padding: 6px 12px;
  font: inherit; font-size: 13px; color: var(--fd-text); cursor: pointer;
}
#fdms-stock .ais-ToggleRefinement-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; }
#fdms-stock .ais-ToggleRefinement-checkbox { accent-color: var(--fd-navy); }

/* ---------- Results ---------- */
#fdms-stats { margin-bottom: 0.75rem; font-size: 13px; opacity: 0.75; }
#fdms .ais-InfiniteHits-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px;
  margin: 0; padding: 0; list-style: none;
}
#fdms .ais-InfiniteHits-item { display: block; padding: 0; margin: 0; box-shadow: none; background: none; border: 0; }

/* Product card — same as the shop: square image, bold uppercase name, type, yards, gray button */
.fdms-card { display: flex; flex-direction: column; align-items: flex-start; height: 100%; }
.fdms-card-img { display: block; width: 100%; margin-bottom: 10px; }
.fdms-card-img img, .fdms-noimg { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 0; }
.fdms-noimg { background: var(--fd-gray); }
#fdms .fdms-name {
  font-size: var(--fd-small); line-height: 1.6; font-weight: 700; text-transform: uppercase;
  color: var(--fd-text); text-decoration: none;
}
#fdms .fdms-name:hover { text-decoration: underline; }
#fdms .fdms-name mark, #fdms .ais-Highlight-highlighted { background: none; color: inherit; padding: 0; }
.fdms-type, .fdms-avail { font-size: var(--fd-small); line-height: 1.6; margin-bottom: 5px; }
.fdms-type { margin-top: 2px; }

#fdms .fdms-btn {
  display: inline-flex; align-items: center; justify-content: center; margin: auto 0 0;
  min-height: 40px; padding: 7px 15px; border: 0; border-radius: 0; box-shadow: none;
  background: var(--fd-gray); color: var(--fd-text); font-family: inherit; font-size: 15px; font-weight: 700;
  line-height: 1.6; text-transform: uppercase; text-decoration: none; letter-spacing: normal; cursor: pointer;
}
#fdms .fdms-card > .fdms-btn { margin-top: 20px; }
#fdms .fdms-btn:hover { background: var(--fd-gray-dark); }
#fdms .fdms-btn.loading { opacity: 0.6; }
#fdms .fdms-btn.added::after { content: " ✓"; }
#fdms .added_to_cart { display: block; margin-top: 6px; font-size: 13px; color: var(--fd-navy); }

/* "Load more" like the shop's pager */
#fdms .ais-InfiniteHits-loadMore {
  display: block; margin: 2rem auto 0; min-height: 44px; padding: 8px 28px; border: 0; border-radius: 0;
  box-shadow: none; background: var(--fd-gray); color: var(--fd-text); font: inherit; font-size: 15px;
  font-weight: 700; text-transform: uppercase; cursor: pointer;
}
#fdms .ais-InfiniteHits-loadMore:hover { background: var(--fd-gray-dark); }
#fdms .ais-InfiniteHits-loadMore--disabled { display: none; }
.fdms-empty { padding: 2rem 0; }

/* ---------- Fabric assistant (chat) ---------- */
#fdms-chat { border: 1px solid var(--fd-line); margin-bottom: 2.25rem; background: #fff; }
.fdms-chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--fd-line);
}
.fdms-chat-head strong {
  display: block; font-family: Fields, Georgia, serif; font-weight: 900; font-size: 24px; line-height: 1.3; color: var(--fd-navy);
}
.fdms-chat-head span { font-size: 14px; }
.fdms-chat-reset {
  background: none; border: 1px solid var(--fd-line); border-radius: 0; padding: 6px 12px;
  font: inherit; font-size: 13px; text-transform: uppercase; cursor: pointer; white-space: nowrap; color: var(--fd-text);
}
.fdms-chat-log { max-height: 520px; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }
.fdms-msg { max-width: 85%; padding: 0.75rem 1rem; line-height: 1.55; font-size: 15px; }
.fdms-msg p { margin: 0 0 0.5em; }
.fdms-msg p:last-of-type { margin-bottom: 0; }
.fdms-msg-user { align-self: flex-end; background: var(--fd-navy); color: #fff; }
.fdms-msg-assistant { align-self: flex-start; background: #f4f5f6; }
.fdms-msg-typing { opacity: 0.75; font-style: italic; }
.fdms-msg-error { align-self: flex-start; background: #fdeeee; color: #8a1f1f; }

.fdms-chat-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 0.9rem; }
.fdms-chat-card { background: #fff; padding: 8px 8px 10px; }
#fdms .fdms-chat-card .fdms-btn { font-size: 13px; min-height: 36px; width: 100%; margin-top: 12px; }

.fdms-chat-starters { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1.25rem 1rem; }
.fdms-chat-chip {
  background: #fff; border: 1px solid var(--fd-navy); color: var(--fd-navy); border-radius: 0;
  padding: 0.45rem 0.85rem; font: inherit; font-size: 14px; cursor: pointer;
}
.fdms-chat-chip:hover { background: var(--fd-navy); color: #fff; }

.fdms-chat-form { display: flex; gap: 0.5rem; padding: 0.9rem 1.25rem; border-top: 1px solid var(--fd-line); }
.fdms-chat-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 0.9rem; border: 1px solid var(--fd-line); border-radius: 0; font: inherit; font-size: 15px;
}
.fdms-chat-form input:focus { outline: none; border-color: var(--fd-navy); }
.fdms-chat-form button {
  background: var(--fd-coral); color: #fff; border: 0; border-radius: 0; padding: 0 1.4rem;
  font: inherit; font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer;
}
.fdms-chat-form button:disabled, .fdms-chat-form input:disabled { opacity: 0.6; cursor: default; }

#fdms-chat[hidden], .fdms-chat-starters[hidden] { display: none; }
/* The assistant only shows in AI mode (when the "AI search" toggle is on). */
#fdms:not(.fdms-ai-on) #fdms-chat { display: none; }

/* ---------- Phones ---------- */
@media (max-width: 767px) {
  .fdms-layout { grid-template-columns: 1fr; gap: 1rem; }
  #fdms .ais-InfiniteHits-list { grid-template-columns: repeat(2, 1fr); }
  .fdms-msg { max-width: 100%; }
  .fdms-chat-head { flex-direction: column; align-items: flex-start; }
  .fdms-chat-products { grid-template-columns: repeat(2, 1fr); }
  #fdms .fdms-btn { font-size: 13px; padding: 7px 10px; }
}

/* Yards that can be ready in about two weeks (ns_inventory_non_sr) */
.fdms-soon { opacity: 0.75; }
