/* =============================================
   Multi-Step Checkout Form — Mobile-First CSS
   ============================================= */

/* ---- RESET / BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-primary-light: #dbeafe;
  --c-success: #16a34a;
  --c-success-bg: #dcfce7;
  --c-border: #e2e8f0;
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-text: #1e293b;
  --c-text-muted: #64748b;
  --c-danger: #dc2626;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --max-w: 520px;
  --gap: 1rem;
  --header-h: 140px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

/* ---- LAYOUT ---- */
.checkout-container {
  width: 100%;
  max-width: var(--max-w);
  padding: 0 var(--gap) var(--gap);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.checkout-header {
  padding: 1.25rem 0 .75rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--c-bg);
}

.checkout-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .75rem;
}

/* ---- PROGRESS BAR ---- */
.progress { margin-bottom: .25rem; }

.progress-track {
  height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  margin-bottom: .5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: calc(100% / 6);
  background: var(--c-primary);
  border-radius: 2px;
  transition: width .4s ease;
}

.steps {
  display: flex;
  justify-content: space-between;
  list-style: none;
  gap: 2px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: .6rem;
  color: var(--c-text-muted);
  flex: 1;
  text-align: center;
  transition: color .3s;
  line-height: 1.2;
}

.step .step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-border);
  color: var(--c-text-muted);
  font-size: .65rem;
  font-weight: 600;
  transition: all .3s;
}

.step.is-active .step-num {
  background: var(--c-primary);
  color: #fff;
}

.step.is-done .step-num {
  background: var(--c-success);
  color: #fff;
}

.step.is-done { color: var(--c-success); }
.step.is-active { color: var(--c-primary); font-weight: 600; }

/* ---- STEP PANELS ---- */
.step-panel {
  flex: 1;
  animation: fadeIn .3s ease;
}

.step-panel.is-hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* ---- PRODUCT GRID ---- */
.product-grid {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.product-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.product-card:active { transform: scale(.98); }

.product-card.is-selected {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
  box-shadow: var(--shadow-md);
}

.product-card .product-info { flex: 1; }
.product-card .product-name { font-weight: 600; font-size: .95rem; }
.product-card .product-price { color: var(--c-primary); font-weight: 700; font-size: .95rem; }
.product-card .product-desc { font-size: .8rem; color: var(--c-text-muted); margin-top: 1px; }

.product-card .product-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.product-card .qty-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  background: var(--c-surface);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text);
  transition: background .15s;
}

.product-card .qty-btn:active { background: var(--c-border); }

.product-card .qty-num {
  min-width: 20px;
  text-align: center;
  font-weight: 700;
  font-size: .95rem;
}

/* ---- FORM FIELDS ---- */
.form {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span { font-size: .85rem; font-weight: 500; color: var(--c-text); }
.field .r { color: var(--c-danger); }

.field input,
.field textarea {
  padding: .7rem .85rem;
  border: 1.5px solid var(--c-border);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  background: var(--c-surface);
  transition: border-color .2s;
  outline: none;
  -webkit-appearance: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.field input.input-error,
.field textarea.input-error {
  border-color: var(--c-danger);
}

.field-err {
  font-size: .75rem;
  color: var(--c-danger);
  min-height: 0;
  display: none;
}

.field-err.is-visible { display: block; }

/* ---- RADIO CARDS ---- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.radio-card:active { transform: scale(.98); }

.radio-card:has(input:checked) {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
  box-shadow: var(--shadow-md);
}

.radio-card input { display: none; }
.radio-icon { font-size: 1.5rem; }
.radio-label { font-weight: 600; font-size: .9rem; flex: 1; }
.radio-sub { font-size: .78rem; color: var(--c-text-muted); display: block; }

.delivery-note,
.payment-info {
  margin-top: .5rem;
  font-size: .8rem;
  color: var(--c-text-muted);
  background: var(--c-surface);
  padding: .65rem .85rem;
  border-radius: 8px;
  border: 1px solid var(--c-border);
}

/* ---- REVIEW ---- */
.review { display: flex; flex-direction: column; gap: .75rem; }

.review-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.review-section h3 {
  font-size: .85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .4rem;
}

.review-section p { font-size: .9rem; line-height: 1.5; }

.review-items { list-style: none; }

.review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem 0;
  font-size: .88rem;
  border-bottom: 1px solid var(--c-border);
}

.review-item:last-child { border-bottom: none; }

.review-total {
  display: flex;
  justify-content: space-between;
  padding-top: .5rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-top: 2px solid var(--c-text);
}

/* ---- SUCCESS PAGE ---- */
.success-page {
  text-align: center;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  align-items: center;
}

.success-icon {
  font-size: 3.5rem;
  animation: popIn .4s cubic-bezier(.68,-.55,.27,1.55);
}

@keyframes popIn {
  0% { transform: scale(0); }
  80% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.success-id {
  font-size: .85rem;
  color: var(--c-text-muted);
  background: var(--c-success-bg);
  padding: .4rem .85rem;
  border-radius: 20px;
  display: inline-block;
  font-weight: 600;
  color: var(--c-success);
}

.success-details {
  width: 100%;
  text-align: left;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  font-size: .85rem;
  box-shadow: var(--shadow-sm);
}

.success-details p { margin-bottom: .3rem; }

/* ---- BUTTONS ---- */
.wa-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: .75rem 1.5rem;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:active { transform: scale(.96); }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:active { background: var(--c-primary-dark); }

.btn-outline {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
}

.btn-outline:active { background: var(--c-border); }

.wa-btn {
  background: #25D366;
  color: #fff;
  width: 100%;
  font-size: 1rem;
  padding: .85rem;
}

.wa-btn:active { filter: brightness(.9); }

/* ---- FOOTER NAV ---- */
.checkout-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: .5rem;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--c-bg);
}

.step-counter {
  font-size: .78rem;
  color: var(--c-text-muted);
  white-space: nowrap;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 600px) {
  .checkout-container { padding: 0 1.5rem 1rem; }
  .product-grid { flex-direction: row; flex-wrap: wrap; }
  .product-card { flex: 1 1 calc(50% - .375rem); min-width: 180px; flex-direction: column; align-items: flex-start; }
  .product-card .product-qty { align-self: flex-end; margin-top: .25rem; }
  .radio-group { flex-direction: row; flex-wrap: wrap; }
  .radio-card { flex: 1; min-width: 140px; flex-direction: column; text-align: center; }
}

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(255,255,255,.9);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .75rem;
  backdrop-filter: blur(2px);
}
.loading-overlay.is-hidden { display: none; }
.loading-overlay p { font-size: .95rem; color: var(--c-primary); font-weight: 600; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- PAYMENT SUCCESS ---- */
.payment-success-page {
  text-align: center; padding: 2rem 0;
  display: flex; flex-direction: column; gap: 1rem;
  align-items: center;
}
.payment-success-page .success-icon { font-size: 4rem; }
.payment-success-page h2 { font-size: 1.3rem; }
.payment-success-page .order-ref {
  background: var(--c-success-bg);
  color: var(--c-success); padding: .5rem 1rem;
  border-radius: 20px; font-weight: 700;
}
