/**
 * Product Card & Drupal Commerce Add-to-Cart Form Styles
 * Layout hierarchy:
 * 1. Variation Dropdown (Top - order: 1)
 * 2. Quantity Selector [ - 1 + ] (Middle - order: 2)
 * 3. Add to Cart Submit Button (Bottom - order: 3)
 */

.product-card__commerce-cart-form {
  margin-top: 10px;
  width: 100%;
}

/* Drupal Commerce Add to Cart Form Container */
.product-card__commerce-cart-form form,
.product-card__commerce-cart-form form.commerce-order-item-add-to-cart-form {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  width: 100% !important;
}

/* Reset Drupal form wrappers */
.product-card__commerce-cart-form .form-wrapper,
.product-card__commerce-cart-form .form-item,
.product-card__commerce-cart-form .js-form-wrapper,
.product-card__commerce-cart-form .js-form-item {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  width: 100% !important;
}

/* Hide bulky labels on product cards */
.product-card__commerce-cart-form label {
  display: none !important;
}

/* 1. Variation Attribute Widget (Weight / Size Dropdown) - ALWAYS ORDER 1 */
.product-card__commerce-cart-form .field--widget-commerce-product-variation-attributes,
.product-card__commerce-cart-form .attribute-widgets,
.product-card__commerce-cart-form [class*="purchased-entity"],
.product-card__commerce-cart-form [id*="edit-purchased-entity"] {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  order: 1 !important;
}

.product-card__commerce-cart-form select,
.product-card__commerce-cart-form .attribute-widgets select.form-select,
.product-card__commerce-cart-form select.form-select {
  width: 100% !important;
  height: 34px !important;
  padding: 4px 28px 4px 10px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  font-family: inherit !important;
  color: var(--text-primary, #1e293b) !important;
  background-color: var(--bg-surface, #f8fafc) !important;
  border: 1.5px solid var(--border-color, #e2e8f0) !important;
  border-radius: var(--radius-sm, 6px) !important;
  cursor: pointer !important;
  outline: none !important;
  transition: all var(--transition-fast, 0.2s) ease !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 14px !important;
  display: block !important;
  box-sizing: border-box !important;
}

.product-card__commerce-cart-form select:hover,
.product-card__commerce-cart-form select.form-select:hover {
  border-color: var(--primary, #16a34a) !important;
  background-color: #ffffff !important;
}

.product-card__commerce-cart-form select:focus,
.product-card__commerce-cart-form select.form-select:focus {
  border-color: var(--primary, #16a34a) !important;
  box-shadow: 0 0 0 3px var(--primary-50, rgba(22, 163, 74, 0.12)) !important;
}

/* 2. Quantity Selector [ - 1 + ] (Middle) - ALWAYS ORDER 2 */
.product-card__commerce-cart-form .field--name-quantity,
.product-card__commerce-cart-form .form-item-quantity,
.product-card__commerce-cart-form .form-item-quantity-0-value,
.product-card__commerce-cart-form .product-card__qty-wrapper,
.product-card__commerce-cart-form [class*="quantity"],
.product-card__commerce-cart-form [id*="edit-quantity"] {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  order: 2 !important;
  display: block !important;
}

.product-card__qty-group {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  height: 38px !important;
  background: #ffffff !important;
  border: 1.5px solid var(--border-color, #cbd5e1) !important;
  border-radius: var(--radius-sm, 8px) !important;
  padding: 2px 4px !important;
  box-sizing: border-box !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  transition: border-color var(--transition-fast, 0.2s) ease !important;
}

.product-card__qty-group:hover,
.product-card__qty-group:focus-within {
  border-color: var(--primary, #0D7C66) !important;
}

/* MINUS BUTTON: Always Left (Order 1) */
.product-card__qty-step-btn--minus,
.product-card__qty-group > button:first-child,
.product-card__qty-group > .product-card__qty-step-btn:first-of-type {
  order: 1 !important;
  flex: 0 0 30px !important;
  width: 30px !important;
  height: 30px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 6px !important;
  color: #1e293b !important;
  cursor: pointer !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  padding: 0 !important;
  float: none !important;
  margin: 0 !important;
  transition: all var(--transition-fast, 0.15s) ease !important;
  user-select: none !important;
}

/* QUANTITY INPUT: Always Middle (Order 2) */
.product-card__qty-input,
.product-card__qty-group > input,
.product-card__qty-group input[type="number"],
.product-card__commerce-cart-form input[type="number"][name*="quantity"],
.product-card__commerce-cart-form input.product-card__qty-input,
.product-card__commerce-cart-form .form-item-quantity input {
  order: 2 !important;
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: 30px !important;
  text-align: center !important;
  border: none !important;
  background: transparent !important;
  font-family: inherit !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--text-primary, #0f172a) !important;
  padding: 0 !important;
  margin: 0 4px !important;
  outline: none !important;
  float: none !important;
  display: block !important;
  -moz-appearance: textfield !important;
}

/* PLUS BUTTON: Always Right (Order 3) */
.product-card__qty-step-btn--plus,
.product-card__qty-group > button:last-child,
.product-card__qty-group > .product-card__qty-step-btn:last-of-type {
  order: 3 !important;
  flex: 0 0 30px !important;
  width: 30px !important;
  height: 30px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 6px !important;
  color: #1e293b !important;
  cursor: pointer !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  padding: 0 !important;
  float: none !important;
  margin: 0 !important;
  transition: all var(--transition-fast, 0.15s) ease !important;
  user-select: none !important;
}

.product-card__qty-step-btn:hover {
  background: var(--primary, #0D7C66) !important;
  color: #ffffff !important;
  border-color: var(--primary, #0D7C66) !important;
}

.product-card__qty-step-btn:active {
  transform: scale(0.92) !important;
}

.product-card__qty-input::-webkit-outer-spin-button,
.product-card__qty-input::-webkit-inner-spin-button,
.product-card__commerce-cart-form input[type="number"]::-webkit-outer-spin-button,
.product-card__commerce-cart-form input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

/* 3. Add to Cart Button (Bottom) - ALWAYS ORDER 3 */
.product-card__commerce-cart-form .form-actions,
.product-card__commerce-cart-form #edit-actions,
.product-card__commerce-cart-form [id*="edit-actions"] {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  order: 3 !important;
}

.product-card__commerce-cart-form input[type="submit"].button--add-to-cart,
.product-card__commerce-cart-form input[type="submit"].form-submit,
.product-card__commerce-cart-form input[type="submit"] {
  width: 100% !important;
  height: 38px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 16px !important;
  background: var(--primary-50, #f0fdf4) !important;
  color: var(--primary, #16a34a) !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  border-radius: var(--radius, 8px) !important;
  border: 1.5px solid var(--primary-lighter, #bbf7d0) !important;
  cursor: pointer !important;
  transition: all var(--transition-fast, 0.2s) ease !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
}

.product-card__commerce-cart-form input[type="submit"]:hover {
  background: var(--primary, #16a34a) !important;
  color: #ffffff !important;
  border-color: var(--primary, #16a34a) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25) !important;
}

.product-card__commerce-cart-form input[type="submit"]:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.2) !important;
}

/* Drupal AJAX Throbber / Spinner Alignment */
.product-card__commerce-cart-form .ajax-progress,
.product-card__commerce-cart-form .ajax-progress-throbber {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-top: 4px !important;
  font-size: 11px !important;
  color: var(--text-muted, #94a3b8) !important;
}
