/*
 * ViviSystem PC builder component picker layout.
 * The picker controls stay in place while only the product results scroll.
 */
.vb-picker-dialog {
  height: min(90dvh, 900px);
  max-height: min(90dvh, 900px);
  min-height: 0;
}

.vb-picker-header,
.vb-picker-controls,
.vb-picker-filters {
  flex: 0 0 auto;
}

.vb-picker-results {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(189, 150, 255, .55) transparent;
}

.vb-picker-results::-webkit-scrollbar {
  width: 8px;
}

.vb-picker-results::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: rgba(189, 150, 255, .48);
  background-clip: padding-box;
}

.vb-picker-results:focus-visible {
  outline: 2px solid var(--vb-cyan);
  outline-offset: -3px;
}

.vb-picker-count {
  position: sticky;
  top: 0;
  z-index: 3;
  flex: 0 0 auto;
  padding: 7px 24px 11px;
  background: linear-gradient(145deg, #211832, #171121);
}

.vb-picker-grid {
  flex: 0 0 auto;
  align-content: start;
  align-items: stretch;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
  padding: 0 24px 18px;
}

.vb-product-card {
  min-width: 0;
  min-height: 300px;
}

.vb-product-visual {
  flex: 0 0 142px;
  min-height: 142px;
}

.vb-product-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

.vb-product-actions {
  flex: 0 0 auto;
}

.vb-load-more {
  flex: 0 0 auto;
  margin: 4px auto 18px;
}

body.light .vb-picker-count {
  background: linear-gradient(145deg, #fff, #f5effb);
}

@media (max-width: 780px) {
  .vb-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 16px;
  }
}

@media (max-width: 520px) {
  .vb-picker-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding-inline: 12px;
  }

  .vb-product-card {
    min-height: 0;
  }
}

/* Mobile builder: full-screen chooser, one roomy card per row. */
.vs-builder-mobile-page .vb-picker-dialog {
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}

.vs-builder-mobile-page .vb-picker-results {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.vs-builder-mobile-page .vb-picker-count {
  padding-inline: 14px;
}

.vs-builder-mobile-page .vb-picker-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 11px;
  padding: 0 14px 16px;
}

.vs-builder-mobile-page .vb-product-card {
  min-height: 0;
}

.vs-builder-mobile-page .vb-product-visual {
  flex-basis: 132px;
  min-height: 132px;
  height: 132px;
}

.vs-builder-mobile-page .vb-product-card-body {
  padding: 10px 11px 9px;
}

.vs-builder-mobile-page .vb-product-actions {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr) 36px 36px;
  gap: 6px;
  padding: 0 10px 10px;
}

.vs-builder-mobile-page .vb-product-details,
.vs-builder-mobile-page .vb-product-use,
.vs-builder-mobile-page .vb-product-icon-action {
  min-width: 0;
  min-height: 36px;
  padding-inline: 5px;
  font-size: .58rem;
}

@media (prefers-reduced-motion: reduce) {
  .vb-product-card,
  .vb-product-card:hover {
    transition: none;
    transform: none;
  }
}

/* ── Touch-first, edge-to-edge component picker ───────────────────────
   Keep the chooser controls visible and let the product list own scrolling.
   Do not open the mobile keyboard until the search field is tapped.
*/
.vs-builder-mobile-page .vb-modal {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}

.vs-builder-mobile-page .vb-picker-dialog {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: 100%;
  max-height: none;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.vs-builder-mobile-page .vb-picker-header {
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 15px 11px;
}

.vs-builder-mobile-page .vb-picker-header > div {
  min-width: 0;
}

.vs-builder-mobile-page .vb-picker-header h2 {
  margin: 4px 0 2px;
  font-size: clamp(1.08rem, 5vw, 1.3rem);
  line-height: 1.15;
}

.vs-builder-mobile-page .vb-picker-header p {
  max-width: 42ch;
  font-size: .66rem;
  line-height: 1.4;
}

.vs-builder-mobile-page .vb-modal-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.vs-builder-mobile-page .vb-picker-controls {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px 14px 8px;
}

.vs-builder-mobile-page .vb-picker-search {
  min-width: 0;
  min-height: 46px;
}

.vs-builder-mobile-page .vb-picker-search input {
  min-height: 42px;
  font-size: 16px;
}

.vs-builder-mobile-page .vb-picker-controls select {
  width: 100%;
  min-height: 42px;
  font-size: .7rem;
}

.vs-builder-mobile-page .vb-picker-filters {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 7px;
  max-width: 100%;
  padding: 5px 14px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.vs-builder-mobile-page .vb-picker-filters::-webkit-scrollbar {
  display: none;
}

.vs-builder-mobile-page .vb-picker-chip {
  flex: 0 0 auto;
  min-height: 35px;
  padding: 7px 11px;
  white-space: nowrap;
  scroll-snap-align: start;
  font-size: .62rem;
}

.vs-builder-mobile-page .vb-picker-results {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.vs-builder-mobile-page .vb-picker-count {
  position: sticky;
  top: 0;
  z-index: 4;
  flex: 0 0 auto;
  padding: 8px 14px 10px;
  background: linear-gradient(145deg, #211832, #171121);
  font-size: .59rem;
}

.vs-builder-mobile-page .vb-picker-grid {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  align-items: stretch;
  gap: 10px;
  padding: 0 13px 13px;
  overflow: visible;
}

.vs-builder-mobile-page .vb-product-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 11px;
}

.vs-builder-mobile-page .vb-product-visual {
  position: relative;
  display: grid;
  flex: 0 0 116px;
  width: 100%;
  height: 116px;
  min-height: 116px;
  place-items: center;
}

.vs-builder-mobile-page .vb-product-visual img {
  width: min(92%, 180px);
  height: 92%;
  object-fit: contain;
}

.vs-builder-mobile-page .vb-product-fallback {
  font-size: 2.3rem;
}

.vs-builder-mobile-page .vb-product-card-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 11px 9px;
}

.vs-builder-mobile-page .vb-product-card-body h3 {
  min-height: 0;
  margin: 5px 0 5px;
  font-size: .76rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 3;
}

.vs-builder-mobile-page .vb-product-card-body p {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.vs-builder-mobile-page .vb-product-card-body > strong {
  margin-top: 7px;
  font-size: .78rem;
}

.vs-builder-mobile-page .vb-product-actions {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr) 38px 38px;
  gap: 6px;
  padding: 0 10px 10px;
}

.vs-builder-mobile-page .vb-product-details,
.vs-builder-mobile-page .vb-product-use,
.vs-builder-mobile-page .vb-product-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 39px;
  padding: 5px 4px;
  border: 1px solid rgba(189,150,255,.27);
  border-radius: 6px;
  color: #e8d9ff;
  background: rgba(189,150,255,.09);
  font-size: .59rem;
  line-height: 1.2;
  white-space: normal;
}

.vs-builder-mobile-page .vb-product-icon-action {
  width: 38px;
  padding: 0;
  font-size: .95rem;
}

.vs-builder-mobile-page .vb-product-use:disabled {
  opacity: .42;
}

.vs-builder-mobile-page .vb-load-more {
  display: flex;
  width: calc(100% - 28px);
  min-height: 46px;
  margin: 4px auto 12px;
  flex: 0 0 auto;
}

.vs-builder-mobile-page .vb-load-more[hidden] {
  display: none;
}

.vs-builder-mobile-page .vb-picker-empty {
  margin: 0 13px 12px;
}

@media (max-height: 620px) {
  .vs-builder-mobile-page .vb-picker-header {
    padding-top: calc(7px + env(safe-area-inset-top, 0px));
    padding-bottom: 7px;
  }

  .vs-builder-mobile-page .vb-picker-header p {
    display: none;
  }

  .vs-builder-mobile-page .vb-picker-controls {
    gap: 6px;
    padding-block: 7px;
  }

  .vs-builder-mobile-page .vb-picker-search,
  .vs-builder-mobile-page .vb-picker-search input,
  .vs-builder-mobile-page .vb-picker-controls select {
    min-height: 38px;
  }

  .vs-builder-mobile-page .vb-picker-filters {
    padding-top: 3px;
    padding-bottom: 7px;
  }

  .vs-builder-mobile-page .vb-product-visual {
    flex-basis: 92px;
    height: 92px;
    min-height: 92px;
  }
}

@media (max-width: 360px) {
  .vs-builder-mobile-page .vb-product-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr) 34px 34px;
    gap: 5px;
    padding-inline: 8px;
  }

  .vs-builder-mobile-page .vb-product-icon-action {
    width: 34px;
  }

  .vs-builder-mobile-page .vb-picker-grid {
    padding-inline: 10px;
  }
}
