/* Recherche : grille 3 col., cartes .scard, chariot — démo + parcours classique (Tailwind = base). */

#search-form #layout-body.layout {
  display: grid;
  grid-template-areas: "side main rail";
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(260px, 300px);
  gap: 1.25rem;
  align-items: start;
  max-width: none;
  margin: 0;
  padding: 0;
}

#search-form #layout-body.layout #sidebar-desktop { grid-area: side; }
#search-form #layout-body.layout #results-col { grid-area: main; }
#search-form #layout-body.layout #dem-right-rail { grid-area: rail; }

@media (max-width: 1100px) {
  #search-form #layout-body.layout {
    grid-template-columns: 220px minmax(0, 1fr) 260px;
  }
}

@media (max-width: 1023px) {
  #search-form #layout-body.layout #dem-right-rail {
    display: none !important;
  }
  #search-form #layout-body.layout {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
    gap: 0;
  }
  #search-form #layout-body.layout #results-col {
    grid-area: main;
  }
}

#search-form.search-page--dem #sidebar-desktop .search-filters-sticky {
  position: sticky;
  top: 5.5rem;
  max-height: none;
  overflow-y: visible;
  overscroll-behavior: auto;
}

#search-form.search-page--dem #sidebar-desktop .search-filters-sticky {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

@media (min-width: 1024px) {
  #search-form #layout-body.layout #sidebar-desktop .search-filters-sticky {
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
    scrollbar-width: thin;
  }
  #search-form.search-page--dem .dem-sidebar-filters .px-3 {
    max-height: min(70vh, 800px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

/* Colonne panier : figée au scroll (align-self sur la grille) */
#search-form .col-right,
#search-form #layout-body.layout #dem-right-rail {
  position: sticky;
  top: 5.5rem;
  z-index: 25;
  align-self: start;
  width: 100%;
  max-height: calc(100vh - 6rem);
}
#search-form #dem-right-rail .panier {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 6rem);
}

/* Onglets modes : état actif (complète les classes Tailwind) */
#search-form.search-page--dem .search-mode-btn.dem-mode-tab.active {
  border-color: transparent;
  background: linear-gradient(135deg, #194667 0%, #3998aa 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(25, 70, 103, 0.2);
}
#search-form.search-page--dem .search-mode-btn.dem-mode-tab.active svg {
  color: rgba(255, 255, 255, 0.9);
}

/* Arbre actes (embed sidebar) */
#search-form.search-page--dem .nav-search {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
}
#search-form.search-page--dem .nav-tree {
  max-height: none;
  overflow-y: visible;
  padding: 4px 0;
}
#search-form.search-page--dem #sidebar-desktop .dem-acte-tree.dem-acte-tree--no-max {
  max-height: none !important;
  overflow-y: visible;
}

#search-form.search-page--dem .dem-struct-inner {
  padding: 0;
}

/* Arbre actes : famille → sous-groupe */
#search-form.search-page--dem .dem-acte-family-body {
  border-left: 2px solid #e5e7eb;
  margin: 0.25rem 0 0.35rem 0.35rem;
  padding-left: 0.35rem;
}
#search-form.search-page--dem .dem-acte-group--nested {
  margin-bottom: 0.35rem;
}
#search-form.search-page--dem .dem-acte-group--nested .dem-acte-group-body {
  padding-left: 0.25rem;
}
#search-form.search-page--dem .dem-acte-ungrouped {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.35rem;
}
#search-form.search-page--dem .dem-acte-family-sum .dem-acte-sum-title {
  font-weight: 700;
  color: #111827;
}

/* Budget : grille rapide sous la barre */
#search-form.search-page--dem .dem-qr-budget {
  margin-top: 0.5rem;
}
#search-form.search-page--dem .dem-qr-item {
  cursor: pointer;
}

/* En-tête résultats : tri + assurance compacts (coin droit) */
#search-form.search-page--dem .dem-results-toolbar--compact .dem-sp-sort {
  height: 2rem;
  min-height: 2rem;
  line-height: 1.25;
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container {
  font-size: 0.75rem;
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container--default .select2-selection--multiple {
  min-height: 2rem;
  border-radius: 0.5rem;
  border-color: #e5e7eb;
  padding: 1px 2px;
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: #3998aa;
  box-shadow: 0 0 0 1px rgba(57, 152, 170, 0.25);
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container--default .select2-selection--multiple .select2-selection__rendered {
  padding: 2px 4px 2px 2px;
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container--default .select2-selection--multiple .select2-selection__choice {
  font-size: 0.625rem;
  padding: 0 0.25rem;
  margin-top: 3px;
  line-height: 1.35;
}
#search-form.search-page--dem .dem-results-toolbar--compact .select2-container--default .select2-selection--multiple .select2-selection__clear {
  margin-top: 2px;
  font-size: 1rem;
}

/* Liste résultats */
#search-form #struct-list,
#search-form .scard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#search-form #struct-list {
  padding: 0;
}
#search-form .dem-accordion-in-struct {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
}
#search-form .dem-accordion-in-struct > details {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  overflow: hidden;
}
#search-form .dem-accordion-in-struct .border-t {
  padding: 0;
}
#search-form.search-page--dem #results-col.col-center {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#search-form.search-page--dem .struct-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}
#search-form.search-page--dem .struct-panel .sp-head {
  flex-shrink: 0;
}
#search-form.search-page--dem .dem-struct-inner {
  min-width: 0;
}

/* Cartes offres .scard */
#search-form .scard {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.125rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
#search-form .scard:hover {
  border-color: #b8d9e2;
  box-shadow: 0 6px 20px rgba(25, 70, 103, 0.08);
}
#search-form .scard.scard--in-cart,
#search-form .scard:has(.acte-item.in-cart) {
  border-color: #6ee7b7;
  background: linear-gradient(180deg, #f0fdf4 0%, #fff 55%);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.1);
}
#search-form .scard[data-pa-ins-match="0"] {
  border-left: 3px solid #fcd34d;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25), 0 1px 3px rgba(15, 23, 42, 0.05);
}

#search-form .scard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
#search-form .scard-org {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}
#search-form .scard-org-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.65rem;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
#search-form .scard-org-logo--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #194667, #3998aa);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}
#search-form .scard-org-name {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.3;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
#search-form .scard-org-name:hover {
  color: #3998aa;
  text-decoration: underline;
}
#search-form .scard-location {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.35;
}
#search-form .scard-ico-inline {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}
#search-form .scard-price-block {
  flex-shrink: 0;
  text-align: right;
  line-height: 1.1;
}
#search-form .scard-price {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: #194667;
  letter-spacing: -0.02em;
}
#search-form .scard-price-unit {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

#search-form .scard-acte-name {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.35;
}
#search-form .scard-acte-meta {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.4;
}
#search-form .scard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
#search-form .scard-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #4b5563;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}
#search-form .scard-chip--accent {
  color: #0f766e;
  background: #ecfdf5;
  border-color: #a7f3d0;
}
#search-form .scard-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
#search-form .scard-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 0.375rem;
}
#search-form .scard-badge--green {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}
#search-form .scard-badge--warn {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
#search-form .scard-badge--ok {
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
}

#search-form .scard-compat {
  display: none !important;
}
#search-form .acte-item.in-cart {
  background: transparent;
}

#search-form .scard-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid #f3f4f6;
}
#search-form .scard-total {
  display: none;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  font-size: 0.75rem;
  font-weight: 600;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}
#search-form .scard-total.visible {
  display: inline-flex;
}
#search-form .scard-footer-actions {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
#search-form .scard-btn-secondary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
#search-form .scard-btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}
#search-form .scard-btn-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.625rem;
  border: none;
  background: linear-gradient(135deg, #3998aa 0%, #2f7d8c 100%);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: 0 2px 8px rgba(57, 152, 170, 0.35);
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}
#search-form .scard-btn-primary:hover {
  box-shadow: 0 4px 14px rgba(57, 152, 170, 0.4);
  transform: translateY(-1px);
}
#search-form .scard.scard--in-cart .scard-btn-primary,
#search-form .scard:has(.acte-item.in-cart) .scard-btn-primary {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: none;
}

/* Grille mode classique (non démo) */
#search-form #results-col > .grid {
  gap: 1rem;
}
#search-form #results-col > .grid .scard {
  height: 100%;
}
@media (max-width: 479px) {
  #search-form .scard-footer-actions {
    flex-direction: column;
  }
  #search-form .scard-btn-secondary,
  #search-form .scard-btn-primary {
    width: 100%;
    flex: none;
  }
}
#search-form #results-col > .space-y-4 .scard {
  margin: 0;
}

/* Panier rail */
#search-form #dem-right-rail #cart-body,
#search-form #dem-right-rail [data-dem-cart-body] {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem;
  background: #f9fafb;
}
#search-form .dem-cart-sheet-body [data-dem-cart-body] {
  padding: 0.75rem;
  background: #f9fafb;
  min-height: 4rem;
}
#search-form #dem-right-rail .panier-head {
  flex-shrink: 0;
  background: #194667;
}
#search-form .cart-empty {
  padding: 1.25rem 0.75rem !important;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed #cbd5e1;
  color: #64748b;
  line-height: 1.5;
}
#search-form .dem-cart-ctx {
  margin-bottom: 0.625rem;
}
#search-form .cart-items {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.125rem 0.125rem 0.25rem;
}
#search-form #dem-right-rail .cart-items {
  max-height: none;
  overflow: visible;
}
#search-form .dem-cart-sheet-body .cart-items {
  max-height: min(50vh, 280px);
  overflow-y: auto;
  scrollbar-width: thin;
}
#search-form .cart-items::-webkit-scrollbar {
  width: 5px;
}
#search-form .cart-items::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
#search-form .citem {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.65rem 0.75rem;
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
#search-form .citem-ins-warn {
  background: #fffbeb;
  border-color: #fcd34d;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.12);
}
#search-form .ci-info {
  flex: 1;
  min-width: 0;
}
#search-form .ci-nom {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #111827;
}
#search-form .ci-struct {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.125rem;
}
#search-form .ci-warn {
  margin-top: 0.375rem;
}
#search-form .ci-prix {
  font-size: 0.8125rem;
  font-weight: 800;
  color: #0e7490;
  flex-shrink: 0;
  align-self: flex-start;
  padding: 0.2rem 0.45rem;
  border-radius: 0.375rem;
  background: rgba(57, 152, 170, 0.12);
}
#search-form .ci-del {
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1.125rem;
  line-height: 1;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
#search-form .ci-del:hover {
  background: #fee2e2;
  color: #dc2626;
}
#search-form .cart-footer {
  flex-shrink: 0;
  margin-top: 0.5rem;
  padding: 0.875rem 0.75rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 0.75rem;
}
#search-form .cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
#search-form .ct-label {
  font-size: 0.8125rem;
  color: #6b7280;
}
#search-form .ct-value {
  font-size: 1.125rem;
  font-weight: 800;
  color: #194667;
}
#search-form .devis-btn {
  width: 100%;
  background: #059669;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
  transition: background 0.15s, transform 0.15s;
}
#search-form .devis-btn:hover {
  background: #047857;
}
#search-form .cart-footer > p {
  margin: 0 0 0.35rem 0;
}
#search-form .cart-footer .devis-btn {
  margin-top: 0.35rem;
}

#search-form a.cart-clear {
  text-decoration: none;
}

/* Barre tri + assurance */
#search-form.search-page--dem .filters-bar .fb-row-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9ca3af;
  width: 100%;
  margin-bottom: 0.25rem;
  display: block;
}
#search-form.search-page--dem .filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
#search-form.search-page--dem .filters-bar .select2-container {
  min-width: 160px;
  flex: 1 1 200px;
}
#search-form.search-page--dem .filters-bar .sp-sort {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
}

#search-form.search-page--dem .dem-side-unified {
  margin: 0;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  background: #fff;
}

/* Piliers : intégration barre blanche */
#search-form.search-page--dem .piliers.dem-piliers {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.375rem;
  overflow-x: auto;
  padding: 0.625rem 0.75rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#search-form.search-page--dem .piliers.dem-piliers::-webkit-scrollbar {
  display: none;
}

/* Barre mobile Filtres + Chariot (au-dessus du menu bas < md) */
#search-form .dem-mobile-quickbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  align-items: stretch;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}
#search-form .dem-mq-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 0.75rem;
  border-radius: 0.625rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
}
#search-form .dem-mq-btn--cart {
  border-color: rgba(57, 152, 170, 0.35);
  background: #f0fdfa;
  color: #0f766e;
}
#search-form .dem-mq-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #059669;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}
#search-form .dem-mq-cart-count {
  font-size: 11px;
  font-weight: 800;
  background: #3998aa;
  color: #fff;
  border-radius: 999px;
  min-width: 22px;
  padding: 2px 7px;
}
#search-form .dem-mq-btn--cart .dem-mq-cart-count {
  background: #fff;
  color: #0f766e;
  border: 1px solid rgba(57, 152, 170, 0.35);
}

@media (max-width: 767px) {
  #search-form .dem-mobile-quickbar {
    display: flex;
  }
  #search-form.search-page--dem .dem-page-fill > .mx-auto {
    padding-bottom: calc(8.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  #search-form .dem-mobile-quickbar {
    display: flex;
    bottom: env(safe-area-inset-bottom, 0px);
  }
  #search-form.search-page--dem .dem-page-fill > .mx-auto {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 1024px) {
  #search-form #dem-mobile-quickbar,
  #search-form #dem-cart-sheet,
  #search-form #dem-cart-backdrop {
    display: none !important;
  }
}

/* Lots prédéfinis : piste scroll discrète */
#search-form .preset-lots-scroll-wrap {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
#search-form .preset-lots-scroll-wrap::-webkit-scrollbar {
  height: 4px;
}
#search-form .preset-lots-scroll-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

#search-form .fade-in {
  animation: demFadeIn 0.25s ease both;
}
@keyframes demFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
