/* ========================================
   Product Options Module
   Scoped additions only; existing site design/colors remain unchanged.
======================================== */

.product-options-panel {
  display: block;
  width: 100%;
  padding: .85rem;

  background: var(--fk-surface, var(--surface, #eef1f4));
  border: var(--fk-border-soft, 1px solid rgba(255, 255, 255, .72));
  border-radius: 1rem;

  box-shadow:
    inset -2px -2px 5px rgba(255, 255, 255, .68),
    inset 2px 2px 5px rgba(163, 170, 179, .10);
}

.product-options-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .65rem;
  margin-bottom: .75rem;
}

.product-options-head h3 {
  margin: 0;
  color: var(--fk-text, #1f2937);
  font-size: .84rem;
  font-weight: 900;
}

.product-options-head p {
  margin: .15rem 0 0;
  color: var(--fk-muted, #6b7280);
  font-size: .62rem;
  line-height: 1.7;
}

.product-options-head > span {
  flex: 0 0 auto;
  color: var(--fk-secondary, var(--secondary, #16a34a));
  font-size: .62rem;
  font-weight: 900;
}

.product-option-groups {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.product-option-group {
  min-width: 0;
  padding: 0;
  border: 0;
}

.product-option-group legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  margin-bottom: .42rem;
  color: var(--fk-text, #1f2937);
  font-size: .7rem;
  font-weight: 900;
}

.product-option-group legend small {
  color: var(--fk-muted, #6b7280);
  font-size: .54rem;
  font-weight: 700;
}

.product-option-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .38rem;
}

.product-option-choice {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.product-option-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.product-option-choice > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 2.65rem;
  padding: .48rem .55rem;

  background: var(--fk-surface, var(--surface, #eef1f4));
  border: var(--fk-border-soft, 1px solid rgba(255, 255, 255, .72));
  border-radius: .8rem;

  box-shadow:
    -2px -2px 5px rgba(255, 255, 255, .72),
    2px 2px 5px rgba(163, 170, 179, .10);

  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.product-option-choice strong {
  min-width: 0;
  overflow: hidden;
  color: var(--fk-text, #1f2937);
  font-size: .65rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-option-choice small {
  margin-top: .12rem;
  color: var(--fk-muted, #6b7280);
  font-size: .52rem;
  line-height: 1.5;
}

.product-option-choice input:checked + span {
  color: var(--fk-primary, #f59e0b);
  border-color: rgba(245, 158, 11, .46);
  box-shadow:
    inset -2px -2px 5px rgba(255, 255, 255, .62),
    inset 2px 2px 5px rgba(163, 170, 179, .10),
    0 0 0 2px rgba(245, 158, 11, .08);
}

.product-option-choice input:checked + span strong {
  color: var(--fk-primary, #f59e0b);
}

.product-options-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px solid rgba(107, 114, 128, .12);
}

.product-options-price-row span {
  color: var(--fk-muted, #6b7280);
  font-size: .6rem;
}

.product-options-price-row strong {
  color: var(--fk-secondary, var(--secondary, #16a34a));
  font-size: .68rem;
  font-weight: 900;
}

.product-option-summary,
.cart-item-options,
.confirm-item-options,
.order-item-options {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem .45rem;
  margin-top: .35rem;
}

.product-option-summary > span,
.cart-item-options > span,
.confirm-item-options > span,
.order-item-options > span {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  padding: .2rem .4rem;

  color: var(--fk-muted, var(--text-secondary, #6b7280));
  background: rgba(31, 157, 85, .06);
  border: 1px solid rgba(31, 157, 85, .12);
  border-radius: 999px;

  font-size: .54rem;
  line-height: 1.5;
}

.product-option-summary b,
.cart-item-options b,
.confirm-item-options b,
.order-item-options b {
  margin-left: .18rem;
  color: var(--fk-secondary, var(--secondary, #16a34a));
  font-weight: 900;
}

/* Seller option builder */
.sp-product-option-builder {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1rem;
}

.sp-option-group-card {
  padding: .85rem;
  background: var(--sp-surface, #fff);
  border: 1px solid var(--sp-border, #eee9e3);
  border-radius: 1rem;
  box-shadow:
    -2px -2px 6px rgba(255, 255, 255, .82),
    2px 2px 6px rgba(218, 213, 206, .16);
}

.sp-option-group-head {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(7rem, .7fr) auto auto;
  align-items: end;
  gap: .55rem;
}

.sp-option-group-head > label:not(.sp-option-required) {
  display: flex;
  flex-direction: column;
  gap: .28rem;
}

.sp-option-group-head label > span,
.sp-option-value-row > label > span {
  color: var(--sp-muted, #6b7280);
  font-size: .6rem;
  font-weight: 800;
}

.sp-option-group-head input[type="text"],
.sp-option-group-head select,
.sp-option-value-row input[type="text"],
.sp-option-value-row input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 2.5rem;
  padding: .52rem .62rem;
  color: var(--sp-text, #1f2937);
  background: var(--sp-bg, #f8f8f8);
  border: 1px solid var(--sp-border, #eee9e3);
  border-radius: .75rem;
  outline: 0;
  font-size: .66rem;
}

.sp-option-required,
.sp-option-default {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.5rem;
  padding: .45rem .58rem;
  color: var(--sp-text, #1f2937);
  background: var(--sp-bg, #f8f8f8);
  border: 1px solid var(--sp-border, #eee9e3);
  border-radius: .75rem;
  font-size: .62rem;
  font-weight: 800;
  white-space: nowrap;
}

.sp-option-values {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin: .7rem 0;
}

.sp-option-value-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1.2fr) minmax(7rem, .8fr) auto auto;
  align-items: end;
  gap: .45rem;
}

.sp-option-value-row > label:not(.sp-option-default) {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.sp-option-remove,
.sp-option-remove-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: .45rem .62rem;
  color: #dc2626;
  background: rgba(220, 38, 38, .05);
  border: 1px solid rgba(220, 38, 38, .13);
  border-radius: .75rem;
  font-size: .62rem;
  font-weight: 900;
}

.sp-option-remove {
  width: 2.5rem;
  padding: 0;
  font-size: 1rem;
}

.sp-option-builder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .8rem;
}

.sp-option-save-state {
  color: var(--sp-success, #16a34a);
  font-size: .62rem;
  font-weight: 800;
}

@media screen and (max-width: 767px) {
  .product-options-panel {
    padding: .7rem;
    border-radius: .9rem;
  }

  .product-option-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-option-choice > span {
    min-height: 2.5rem;
    padding: .42rem .48rem;
  }

  .sp-option-group-head,
  .sp-option-value-row {
    grid-template-columns: 1fr 1fr;
  }

  .sp-option-remove-group,
  .sp-option-remove,
  .sp-option-required,
  .sp-option-default {
    width: 100%;
  }
}

@media screen and (max-width: 390px) {
  .product-options-head {
    flex-direction: column;
  }

  .product-option-choices {
    gap: .32rem;
  }

  .product-option-choice strong {
    font-size: .6rem;
  }

  .product-option-choice small {
    font-size: .48rem;
  }

  .sp-option-group-head,
  .sp-option-value-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-option-choice > span {
    transition: none !important;
  }
}
