/**
 * Align Kit Builder - Step 5 Options Styling
 *
 * Styles for conditional Step 5 options, swatches dropdown, search bar, and checkboxes.
 *
 * @package Align Child
 */

/* Step 5 A-la-carte Card Customizations to match Image 3 */
.component-a-la-carte-card {
  align-items: center !important;
  border-radius: 12px !important;
  padding: 12px 16px !important;
}

.component-a-la-carte-card.checked {
  border: 1.5px solid var(--Engine-Red, #AD1A24) !important;
}

.component-a-la-carte-card > .custom-check-box,
.component-a-la-carte-card > .component-checkbox {
  display: none !important;
}

.component-a-la-carte-card .component-desc {
  display: block;
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
  font-size: 13px;
  line-height: 1.4;
  color: #71717A;
  margin-top: 2px;
}

/* Hide description only for components with step 5 child addons (e.g. Bimini Top) */
.component-a-la-carte-card.has-step5-addons .component-desc,
.component-a-la-carte-card[data-has-step5-addons="1"] .component-desc {
  display: none !important;
}

.component-a-la-carte-card .component-price {
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
  font-weight: 700;
  color: var(--Engine-Red, #AD1A24);
  line-height: 1.2;
  white-space: nowrap;
}

.component-a-la-carte-card .component-title {
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
  font-weight: 700;
  color: #1F1F1F;
  line-height: 1.2;
}

.component-a-la-carte-card.no-desc:not(.has-child-options):not(.has-step5-addons) .component-meta {
  justify-content: center;
}

/* Desktop layout & sizing (>= 992px) */
@media (min-width: 992px) {
  .component-a-la-carte-card.has-desc,
  .component-a-la-carte-card.has-step5-addons,
  .component-a-la-carte-card[data-has-step5-addons="1"],
  .component-a-la-carte-card.has-child-options,
  .component-a-la-carte-card:has(.component-desc),
  .component-a-la-carte-card:has(.step5-child-options-container) {
    align-items: flex-start !important;
  }

  .component-header-row {
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 12px !important;
  }

  .component-a-la-carte-card .component-price {
    font-size: 20px !important;
    margin-top: 0 !important;
    text-align: right;
  }

  .component-a-la-carte-card .component-title {
    font-size: 18px !important;
  }
}

/* Mobile & Tablet layout & sizing (< 992px) */
@media (max-width: 991px) {
  .component-a-la-carte-card,
  .component-a-la-carte-card.has-desc {
    align-items: center !important;
    padding: 10px 14px !important;
    gap: 12px !important;
    border-radius: 12px !important;
  }

  .component-a-la-carte-card.has-child-options,
  .component-a-la-carte-card:has(.step5-child-options-container) {
    align-items: flex-start !important;
  }

  .component-a-la-carte-card .component-thumb,
  .component-a-la-carte-card .component-a-la-carte-thumb {
    width: 60px !important;
    height: 60px !important;
    background-color: transparent !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
  }

  .component-a-la-carte-card .component-a-la-carte-thumb img {
    object-fit: contain !important;
  }

  .component-a-la-carte-card .component-meta {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
  }

  .component-a-la-carte-card .component-header-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    width: 100% !important;
  }

  .component-a-la-carte-card .component-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--kb-dark, #1F1F1F) !important;
    line-height: 1.25 !important;
    margin: 0 !important;
  }

  .component-a-la-carte-card .component-price {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--Engine-Red, #AD1A24) !important;
    line-height: 1.2 !important;
    text-align: left !important;
    margin: 0 !important;
  }

  .component-desc,
  .component-a-la-carte-card .component-desc {
    display: none !important;
  }
}

/* Child options container inside parent card */
.step5-child-options-container {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  margin-top: 8px !important;
  margin-bottom: 0;
  margin-left: 0;
  padding: 0 !important;
  background: transparent;
  border: none;
  border-radius: 0;
  box-sizing: border-box;
  width: 100% !important;
}

.step5-option-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
  border-bottom: none;
  width: 100%;
}

.step5-option-row:last-child {
  border-bottom: none;
}

.step5-option-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  cursor: pointer;
  user-select: none;
  width: 100% !important;
}

.step5-option-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.step5-option-header .custom-check-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid #DFD8CB !important;
  border-radius: 4px;
  background-color: #FFFFFF !important;
  background: #FFFFFF !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.step5-option-row.is-selected .step5-option-header .custom-check-box {
  background-color: #FFFFFF !important;
  background: #FFFFFF !important;
  border-color: #CBD5E1 !important;
  color: var(--Engine-Red, #AD1A24) !important;
}

.step5-option-header .custom-check-box svg {
  width: 12px;
  height: 10px;
  display: block;
}

.step5-option-title {
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
  font-size: 14.5px !important;
  font-weight: 500 !important;
  color: #1F1F1F !important;
  flex: 1 !important;
  margin-left: 2px !important;
}

.step5-option-price {
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--Engine-Red, #AD1A24) !important;
  white-space: nowrap !important;
  text-align: right !important;
  margin-left: auto !important;
}

.step5-option-color-wrap {
  margin-left: 28px;
  margin-top: 4px;
}

.step5-option-color-wrap:empty {
  display: none !important;
  margin: 0 !important;
}

.step5-option-inherit-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #64748b;
  background: #ffffff;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.step5-option-swatch-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

.btn-step5-open-swatches {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--Engine-Red, #AD1A24);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-step5-open-swatches:hover {
  background: #fef2f2;
  border-color: var(--Engine-Red, #AD1A24);
}

.step5-option-swatches-grid {
  margin-top: 8px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step5-swatches-search-bar input {
  width: 100%;
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0 8px;
  font-size: 11.5px;
  box-sizing: border-box;
}

.step5-swatches-items-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.step5-swatch-item-btn {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.step5-swatch-item-btn.is-active {
  border-color: var(--Engine-Red, #AD1A24);
  outline: 2px solid #fecaca;
}

.step5-swatches-loading,
.step5-swatches-error,
.step5-swatches-empty {
  font-size: 11.5px;
  color: #64748b;
  padding: 8px;
  text-align: center;
}

/* Mutually Exclusive Disabled Component Styling */
.component-a-la-carte-card.is-disabled {
  opacity: 0.5 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  filter: grayscale(0.25);
  user-select: none !important;
  border-color: #E2E8F0 !important;
  background-color: #F8FAFC !important;
}

.component-a-la-carte-card.is-disabled .component-title,
.component-a-la-carte-card.is-disabled .component-price,
.component-a-la-carte-card.is-disabled .component-desc {
  color: #94A3B8 !important;
}

.component-a-la-carte-card.is-disabled .component-checkbox,
.component-a-la-carte-card.is-disabled .custom-check-box {
  cursor: not-allowed !important;
  pointer-events: none !important;
  opacity: 0.5 !important;
}

/* ============================================================
 * Parent-scope Step 5 color picker (opt-in per component,
 * AJAX-loaded via AlignStep5VariationLoader).
 * ============================================================ */
.component-a-la-carte-card.has-color-choice { flex-wrap: wrap; }

.component-color-choice-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  box-sizing: border-box;
}

.component-a-la-carte-card.checked.has-color-choice .component-color-choice-wrap {
  display: flex !important;
}

.component-color-choice-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.component-color-choice-label {
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.btn-component-color-open {
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--Engine-Red, #AD1A24);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity .15s ease;
  font-family: var(--kb-font-heading, 'Barlow', sans-serif);
}
.btn-component-color-open:hover { opacity: 0.7; }
.btn-component-color-open svg { width: 14px; height: 14px; flex-shrink: 0; transition: transform .2s ease; }
.btn-component-color-open.is-open svg { transform: rotate(180deg); }

/* Horizontal scroll row: cards side-by-side, scroll-snap + drag/wheel via bindHorizontalScroll. */
.component-color-choice-grid {
  display: flex; flex-wrap: nowrap; gap: 10px; width: 100%;
  overflow-x: auto; overflow-y: hidden; padding: 4px 2px 10px 2px;
  -webkit-overflow-scrolling: touch;
  cursor: grab; user-select: none;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}
.component-color-choice-grid::-webkit-scrollbar { height: 6px; }
.component-color-choice-grid::-webkit-scrollbar-track { background: transparent; }
.component-color-choice-grid::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.component-color-choice-grid.is-dragging { cursor: grabbing; }

/* Individual variation card: thumbnail on top, label below. */
.component-color-card {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 89px; padding: 6px; background: #ffffff;
  border: 2px solid transparent; border-radius: 8px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease; appearance: none; font-family: inherit;
  box-sizing: border-box;
}
.component-color-card:hover { border-color: #cbd5e1; box-shadow: 0 2px 6px rgba(15, 23, 42, .08); }
.component-color-card.is-active { border-color: var(--Engine-Red, #AD1A24); box-shadow: 0 0 0 2px #fecaca; }
.component-color-card-thumb {
  width: 77px; height: 77px; border-radius: 6px; overflow: hidden;
  background: #f1f5f9; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.component-color-card-thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; display: block; }
.component-color-card-label {
  font-size: 11.5px; font-weight: 500; color: #0f172a; line-height: 1.25; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}

.component-color-choice-loading,
.component-color-choice-error,
.component-color-choice-empty { font-size: 12px; color: #64748b; text-align: center; padding: 12px; width: 100%; }
.component-color-choice-error { color: #dc2626; }

