/**
 * Solera Checkout - Coupon / Discount Code Styles
 *
 * Covers the coupon input, apply button, feedback messages, and the discount
 * row in the order summary totals. Loaded on the checkout page only.
 *
 * Depends on: main.css (CSS variables).
 */

/* ==========================================================================
   Local colour tokens — values not yet in main.css.
   Centralised here so a single edit covers all coupon states.
   ========================================================================== */
:root {
  --coupon-btn-hover:      #143f81; /* --solera-blue darkened ~15% */
  --coupon-error:          #dc2626; /* input error ring */
  --coupon-error-text:     #b91c1c;
  --coupon-error-bg:       #fef2f2;
  --coupon-error-border:   #fca5a5;
  --coupon-success-text:   #15803d;
  --coupon-success-bg:     #f0fdf4;
  --coupon-success-border: #86efac;
}

/* ==========================================================================
   Coupon section wrapper (checkout only)
   ========================================================================== */

.solera-coupon-section {
  margin-top: 0.75rem;
  margin-bottom: var(--space-xs);
}

/* ==========================================================================
   Input row: text field + apply button
   ========================================================================== */

.solera-coupon-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: stretch;
}

.solera-coupon-input {
  flex: 1 1 0%;
  padding: 0.625rem 0.75rem;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-base);
  color: var(--solera-shark);
  background-color: var(--solera-white);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.solera-coupon-input::placeholder {
  color: var(--solera-silver);
}

.solera-coupon-input:focus {
  border-color: var(--solera-jacarta);
  box-shadow: 0 0 0 0.1875rem rgba(50, 36, 94, 0.15);
}

.solera-coupon-input.is-error {
  border-color: var(--coupon-error);
  box-shadow: 0 0 0 0.1875rem rgba(220, 38, 38, 0.1);
}

/* ==========================================================================
   Apply button
   ========================================================================== */

.solera-coupon-btn {
  flex-shrink: 0;
  padding: 0.625rem var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: var(--line-height-base);
  color: var(--solera-white);
  background-color: var(--solera-blue);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.solera-coupon-btn:hover:not(:disabled) {
  background-color: var(--coupon-btn-hover);
}

.solera-coupon-btn:active:not(:disabled) {
  background-color: var(--coupon-btn-hover);
}

.solera-coupon-btn:focus {
  background-color: var(--solera-blue);
  outline: none;
}

.solera-coupon-btn:focus-visible {
  outline: 0.1875rem solid rgba(25, 79, 161, 0.4);
  outline-offset: 0.125rem;
}

.solera-coupon-btn:disabled,
.solera-coupon-btn.is-loading {
  opacity: 0.55;
  cursor: not-allowed;
}

.solera-coupon-btn.is-loading {
  position: relative;
  color: transparent;
}

.solera-coupon-btn.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.875rem;
  height: 0.875rem;
  margin: -0.4375rem 0 0 -0.4375rem;
  border: 0.125rem solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--solera-white);
  border-radius: 50%;
  animation: solera-coupon-spin 0.7s linear infinite;
}

@keyframes solera-coupon-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Discount row: coupon label with inline × remove button (checkout summary)
   Extends .solera-summary-label / .solera-summary-value from components.css.
   ========================================================================== */

#solera-discount-row .solera-summary-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.solera-discount-coupon-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Multi-coupon: each item is its own full-width row with name left, amount right */
.solera-discount-coupon-item--has-amount {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: var(--space-xs);
}

.solera-discount-coupon-item__name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.solera-discount-coupon-item__amount {
  font-weight: 600;
  color: var(--solera-base);
  white-space: nowrap;
}

.solera-coupon-remove-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  font-size: var(--font-size-sm);
  line-height: 1;
  color: var(--solera-mako-base);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.1s ease, background-color 0.1s ease;
}

.solera-coupon-remove-inline:hover {
  opacity: 1;
  background-color: rgba(68, 72, 84, 0.12);
}

.solera-coupon-remove-inline:focus-visible {
  outline: 0.125rem solid var(--solera-mako-base);
  outline-offset: 0.0625rem;
}
