/**
 * apmultivariantqty - Front-end Stylesheet
 * Brand Color Palette: Derived from official logo (#f2801f primary orange, #f9b11c secondary amber)
 * Author: Aptivanet
 */

:root {
  --ap-primary: #f2801f;
  --ap-primary-hover: #ea580c;
  --ap-primary-dark: #c2410c;
  --ap-secondary: #f9b11c;
  --ap-secondary-light: #fef08a;
  --ap-warm-bg: #fffbf7;
  --ap-warm-tint: #fff7ed;
  --ap-warm-border: #fed7aa;
  --ap-text-dark: #1e293b;
  --ap-text-muted: #64748b;
  --ap-border-color: #e2e8f0;
}

/* ==========================================================================
   1. MAIN CONTAINER
   ========================================================================== */
.ap-multivariant-container {
  background: #ffffff;
  border: 1px solid var(--ap-border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-top: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
}

.ap-multivariant-header {
  border-bottom: 1px solid var(--ap-border-color);
  padding-bottom: 0.85rem;
}

.ap-multivariant-header .ap-multivariant-title {
  color: var(--ap-text-dark);
  margin-bottom: 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.ap-multivariant-header .ap-icon-title {
  color: var(--ap-primary);
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   2. STEP NUMBER BADGES (1, 2, 3) - Guaranteed High Visibility & Contrast
   ========================================================================== */
.ap-step-badge,
.ap-multivariant-container .badge.badge-primary,
.ap-multivariant-container .badge-primary {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #f2801f 0%, #f9b11c 100%) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 0.85rem !important;
  line-height: 1 !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 6px rgba(242, 128, 31, 0.4) !important;
  margin-right: 0.5rem !important;
  vertical-align: middle !important;
  padding: 0 !important;
  border: none !important;
}

/* ==========================================================================
   3. STEP 1 - TARGET TOTAL QUANTITY CARD
   ========================================================================== */
.ap-target-total-card {
  background: linear-gradient(135deg, var(--ap-warm-bg) 0%, var(--ap-warm-tint) 100%) !important;
  border: 1px solid var(--ap-warm-border) !important;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(242, 128, 31, 0.08);
  transition: box-shadow 0.2s ease;
}

.ap-target-total-card:hover {
  box-shadow: 0 4px 12px rgba(242, 128, 31, 0.12);
}

.ap-target-total-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ap-text-dark);
}

.ap-target-total-group {
  max-width: 175px;
}

.ap-target-total-group .btn {
  padding: 0.45rem 0.85rem;
  background-color: #ffffff;
  border: 1.5px solid #fdba74;
  color: var(--ap-primary);
  font-weight: 700;
  transition: all 0.15s ease-in-out;
}

.ap-target-total-group .btn:hover {
  background-color: var(--ap-primary);
  border-color: var(--ap-primary);
  color: #ffffff;
}

.ap-input-target-total {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ap-primary-dark);
  border: 1.5px solid #fdba74;
  background-color: #ffffff;
  text-align: center;
}

.ap-input-target-total:focus {
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px rgba(242, 128, 31, 0.25);
  outline: none;
}

/* ==========================================================================
   4. STEP 2 - ATTRIBUTES SELECTORS (Color, Technique, Position, etc.)
   ========================================================================== */
.ap-variants-selectors {
  background-color: #f8fafc;
  border: 1px solid var(--ap-border-color);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
}

.ap-selectors-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ap-text-dark);
  border-bottom: 1px solid var(--ap-border-color) !important;
}

.ap-variant-group {
  margin-bottom: 1.15rem;
}

.ap-variant-group:last-child {
  margin-bottom: 0;
}

.ap-variant-group-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

.ap-selected-attr-name {
  color: var(--ap-primary-hover);
  font-weight: 700;
}

/* Color swatches */
.ap-color-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ap-color-label {
  display: inline-block;
  cursor: pointer;
  margin-bottom: 0;
}

.ap-color-label input.input-color {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ap-color-label .color {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background-size: cover;
  background-position: center;
}

.ap-color-label:hover .color {
  border-color: var(--ap-secondary);
  transform: scale(1.08);
}

.ap-color-label input.input-color:checked + .color,
.ap-color-label .color.active {
  border-color: var(--ap-primary);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--ap-primary);
}

.color-text-fallback {
  font-size: 10px;
  font-weight: 800;
  color: #4a5568;
}

/* Radio buttons / pills */
.ap-radio-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ap-radio-label {
  display: inline-block;
  cursor: pointer;
  margin-bottom: 0;
}

.ap-radio-label input.input-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ap-radio-label .radio-label {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.88rem;
  background-color: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  user-select: none;
}

.ap-radio-label:hover .radio-label {
  border-color: var(--ap-secondary);
  background-color: var(--ap-warm-bg);
  color: var(--ap-primary-hover);
  padding: 0.4rem 1rem;
}

.ap-radio-label input.input-radio:checked + .radio-label,
.ap-radio-label .radio-label.active {
  border-color: var(--ap-primary);
  background-color: var(--ap-warm-tint);
  color: var(--ap-primary-dark);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(242, 128, 31, 0.22);
  padding: 0.4rem 1rem;
}

/* Dropdown select */
.ap-select-container select.form-control-select {
  max-width: 320px;
  height: 2.6rem;
  padding: 0.375rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ap-text-dark);
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background-color: #ffffff;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ap-select-container select.form-control-select:focus {
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px rgba(242, 128, 31, 0.2);
}

/* ==========================================================================
   5. STEP 3 - ALLOCATION HEADER & STATUS BANNER
   ========================================================================== */
.ap-target-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ap-text-dark);
}

.ap-target-group-highlight,
.ap-target-section-title .text-primary {
  color: var(--ap-primary-hover) !important;
}

.ap-allocation-target-summary {
  background-color: #f1f5f9;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--ap-border-color);
  font-size: 0.85rem;
}

.ap-allocation-target-summary .ap-target-badge-val {
  color: var(--ap-primary-dark) !important;
  font-size: 1rem;
}

/* Allocation Status Banner */
.ap-allocation-status {
  border-radius: 10px;
  padding: 0.9rem 1.25rem;
  font-size: 0.95rem;
  border-width: 1px;
  border-style: solid;
  transition: all 0.25s ease-in-out;
}

.ap-allocation-status.alert-warning {
  background-color: #fffbeb !important;
  border-color: #fde68a !important;
  color: #92400e !important;
}

.ap-allocation-status.alert-warning .ap-allocation-icon {
  color: #d97706;
}

.ap-allocation-status.alert-success {
  background-color: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
  color: #065f46 !important;
}

.ap-allocation-status.alert-success .ap-allocation-icon {
  color: #059669;
}

.ap-allocation-status.alert-danger {
  background-color: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}

.ap-allocation-status.alert-danger .ap-allocation-icon {
  color: #dc2626;
}

.ap-allocation-badge {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.45em 0.9em;
  border-radius: 20px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ap-allocation-badge.badge-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
}

.ap-allocation-badge.badge-success {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
}

.ap-allocation-badge.badge-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}

/* ==========================================================================
   6. VARIANTS TABLE
   ========================================================================== */
.ap-table-responsive {
  margin-bottom: 0;
  border-radius: 10px;
  overflow-x: auto;
  border: 1px solid var(--ap-border-color);
}

.ap-table-variants {
  margin-bottom: 0;
  border-collapse: collapse;
  width: 100%;
}

.ap-table-variants thead th {
  background-color: #f8fafc;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 2px solid var(--ap-border-color);
  padding: 0.85rem 0.75rem;
  white-space: nowrap;
}

.ap-table-variants tbody td {
  padding: 0.75rem 0.75rem;
  vertical-align: middle;
  border-top: 1px solid #f1f5f9;
  font-size: 0.92rem;
  transition: background-color 0.15s ease;
}

.ap-table-variants tbody tr:hover {
  background-color: #f8fafc;
}

/* Active Row Highlight when quantity > 0 */
.ap-comb-row.ap-row-active {
  background-color: #fffbf7 !important;
}

.ap-comb-row.ap-row-active td {
  border-color: #fed7aa;
}

.ap-variant-name {
  display: block;
  color: var(--ap-text-dark);
  font-weight: 600;
  font-size: 0.95rem;
}

.ap-variant-ref {
  font-size: 0.8rem;
  color: var(--ap-text-muted);
}

.ap-variant-minqty {
  font-size: 0.78rem;
  color: var(--ap-primary-hover);
  font-weight: 600;
  margin-top: 2px;
}

.ap-icon {
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
  flex-shrink: 0;
}

.ap-icon-small {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}

/* Stock badges */
.ap-badge-stock {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35em 0.7em;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ap-badge-stock.badge-success {
  background-color: #def7ec;
  color: #03543f;
}

.ap-badge-stock.badge-warning {
  background-color: #fef08a;
  color: #854d0e;
}

.ap-badge-stock.badge-danger {
  background-color: #fde8e8;
  color: #9b1c1c;
}

/* Volume Discounts Card & Tiers */
.ap-volume-discounts-card {
  background: linear-gradient(135deg, #fffbf7 0%, #fff7ed 100%) !important;
  border: 1px solid #fed7aa !important;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(242, 128, 31, 0.08);
}

.ap-volume-header {
  gap: 8px;
}

.ap-volume-title {
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--ap-text-dark);
}

.ap-volume-subtitle {
  font-size: 0.82rem;
  color: var(--ap-text-muted);
}

.ap-scope-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25em 0.6em;
  border-radius: 12px;
}

.ap-volume-tier-pills {
  gap: 8px;
}

.ap-tier-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background-color: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ap-tier-pill .ap-tier-qty-label {
  font-weight: 600;
}

.ap-tier-pill .ap-tier-discount-badge {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.15em 0.55em;
  border-radius: 12px;
  line-height: 1.2;
  transition: all 0.2s ease-in-out;
}

.ap-tier-pill:hover {
  border-color: var(--ap-primary);
  box-shadow: 0 2px 6px rgba(242, 128, 31, 0.2);
}

/* Active Tier Pill when quantity threshold is met */
.ap-tier-pill.ap-tier-active {
  background: linear-gradient(135deg, var(--ap-primary) 0%, var(--ap-secondary) 100%) !important;
  color: #ffffff !important;
  border-color: #ea580c !important;
  box-shadow: 0 3px 10px rgba(242, 128, 31, 0.4) !important;
  transform: translateY(-1px);
}

.ap-tier-pill.ap-tier-active .ap-tier-qty-label {
  color: #ffffff !important;
  font-weight: 700;
}

.ap-tier-pill.ap-tier-active .ap-tier-discount-badge {
  background-color: #ffffff !important;
  color: var(--ap-primary-dark) !important;
  border-color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  font-weight: 800;
}

.ap-col-price {
  white-space: nowrap;
  font-size: 0.95rem;
}

.ap-price-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.ap-regular-price {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 500;
  line-height: 1.2;
}

.ap-regular-price s {
  text-decoration: line-through;
}

.ap-unit-price {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ap-text-dark);
  line-height: 1.2;
  transition: color 0.2s ease;
}

.ap-unit-price.ap-price-discounted {
  color: #047857;
}

.ap-discount-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2em 0.55em;
  border-radius: 12px;
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  display: inline-block;
}

.ap-col-qty {
  width: 140px;
}

.ap-qty-group {
  max-width: 125px;
}

.ap-qty-group .btn {
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  color: #475569;
  transition: all 0.15s ease-in-out;
}

.ap-qty-group .btn:hover {
  background-color: var(--ap-warm-tint);
  border-color: #f97316;
  color: var(--ap-primary-dark);
}

.ap-input-qty {
  font-weight: 700;
  font-size: 1rem;
  height: auto;
  padding: 0.3rem 0.2rem;
  border: 1px solid #cbd5e1;
  color: var(--ap-text-dark);
  text-align: center;
}

.ap-input-qty:focus {
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 2px rgba(242, 128, 31, 0.2);
  outline: none;
}

.ap-col-total {
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ap-text-dark);
  width: 100px;
}

.ap-row-disabled {
  opacity: 0.55;
  background-color: #fafbfc;
}

/* ==========================================================================
   7. FOOTER SUMMARY & ACTION BUTTON
   ========================================================================== */
.ap-multivariant-footer {
  border: 1px solid var(--ap-warm-border) !important;
  background: linear-gradient(135deg, var(--ap-warm-bg) 0%, var(--ap-warm-tint) 100%) !important;
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
}

.ap-summary-item .ap-total-qty {
  color: var(--ap-primary-dark) !important;
  font-size: 1.4rem;
  font-weight: 800;
}

.ap-summary-item .ap-total-price {
  color: var(--ap-text-dark) !important;
  font-size: 1.4rem;
  font-weight: 800;
}

.ap-btn-bulk-add {
  background: linear-gradient(135deg, #f2801f 0%, #ea580c 100%) !important;
  border: none !important;
  color: #ffffff !important;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.75rem 1.6rem;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(242, 128, 31, 0.4) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.3px;
}

.ap-btn-bulk-add:hover:not(:disabled) {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(242, 128, 31, 0.5) !important;
  color: #ffffff !important;
}

.ap-btn-bulk-add:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(242, 128, 31, 0.4) !important;
}

.ap-btn-bulk-add:disabled {
  background: #cbd5e1 !important;
  color: #64748b !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none !important;
}

.ap-btn-bulk-add .ap-btn-cart-icon {
  width: 20px;
  height: 20px;
  vertical-align: -3px;
}

/* Alert notifications */
.ap-multivariant-alert {
  position: relative;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}

/* Spinner */
.spinner-border-sm {
  width: 1.1rem;
  height: 1.1rem;
  border-width: 0.22em;
  display: inline-block;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: ap-spin 0.75s linear infinite;
}

@keyframes ap-spin {
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   8. RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 767.98px) {
  .ap-multivariant-container {
    padding: 0.85rem;
    border-radius: 10px;
  }
  
  .ap-multivariant-footer {
    flex-direction: column;
    align-items: stretch !important;
    gap: 1.2rem;
  }
  
  .ap-summary-actions {
    width: 100%;
  }
  
  .ap-btn-bulk-add {
    width: 100%;
    justify-content: center;
  }
  
  .ap-col-variant {
    min-width: 110px;
  }
  
  .ap-col-qty {
    min-width: 110px;
  }
}

/* Global rule to hide native product variants when enabled */
body.ap-hide-native-variants .product-variants,
body.ap-hide-native-variants .js-product-variants,
body.ap-hide-native-variants .product-actions .product-variants,
body.ap-hide-native-variants .product-add-to-cart .add {
  display: none !important;
}