/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-900: #1E3A5F;
  --blue-800: #1E40AF;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-100: #DBEAFE;
  --blue-50:  #EFF6FF;

  --green-600: #16A34A;
  --green-500: #22C55E;
  --green-100: #DCFCE7;

  --red-600:  #DC2626;
  --red-100:  #FEE2E2;
  --red-50:   #FFF5F5;

  --orange-500: #F59E0B;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6B7280;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50:  #F9FAFB;
  --white:    #FFFFFF;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  --transition: 200ms ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--blue-800);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

.header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px 10px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

/* ── Steps Bar ───────────────────────────────────────────────────────────── */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  opacity: .45;
  transition: opacity var(--transition);
}

.step-item.active  { opacity: 1; }
.step-item.done    { opacity: .75; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  border: 2px solid rgba(255,255,255,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  transition: background var(--transition), border-color var(--transition);
}

.step-item.active .step-num {
  background: var(--white);
  border-color: var(--white);
  color: var(--blue-800);
}

.step-item.done .step-num {
  background: var(--green-500);
  border-color: var(--green-500);
  color: var(--white);
}

.step-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.step-divider {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,.25);
  margin: 0 6px;
  margin-bottom: 14px;
  min-width: 20px;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 12px 40px;
}

/* ── Step Screens ────────────────────────────────────────────────────────── */
.step-screen {
  display: none;
  animation: fadeSlideIn .25s ease;
}

.step-screen.active { display: block; }

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

/* ── Card ────────────────────────────────────────────────────────────────── */
.screen-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 20px;
}

.screen-card.screen-centered {
  text-align: center;
  padding: 40px 24px;
}

.screen-title { margin-bottom: 22px; }
.screen-title h2 { font-size: 1.2rem; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.screen-title p  { font-size: .9rem; color: var(--gray-500); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.required { color: var(--red-600); }
.optional  { font-weight: 400; color: var(--gray-500); font-size: .8rem; }

input[type="text"],
input[type="tel"],
input[type="email"],
select {
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--gray-900);
  background: var(--white);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' 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");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

input.error { border-color: var(--red-600); }

.field-error {
  font-size: .78rem;
  color: var(--red-600);
  min-height: 1em;
}

.section-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 50px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition), transform 80ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-lg  { height: 56px; font-size: 1.05rem; border-radius: var(--radius-md); }
.btn-full { width: 100%; }

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) { background: var(--blue-800); }

.btn-success {
  background: var(--green-600);
  color: var(--white);
}
.btn-success:hover:not(:disabled) { background: #15803D; }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }

.form-actions       { margin-top: 20px; }
.form-actions-split { display: flex; gap: 10px; justify-content: space-between; }
.form-actions-split .btn-primary { flex: 1; }

/* ── Weight Selector ─────────────────────────────────────────────────────── */
.weight-section { margin-bottom: 22px; }

.weight-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.weight-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-family: inherit;
}

.weight-btn:hover { border-color: var(--blue-500); background: var(--blue-50); }
.weight-btn.active {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.weight-icon { font-size: 1.4rem; line-height: 1; }
.weight-name { font-size: .8rem; font-weight: 700; color: var(--gray-900); }
.weight-desc { font-size: .72rem; color: var(--gray-500); }

/* ── Shipping Methods ────────────────────────────────────────────────────── */
.shipping-section { margin-bottom: 10px; }

.shipping-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shipping-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: left;
  font-family: inherit;
  width: 100%;
}

.shipping-card:hover { border-color: var(--blue-500); background: var(--blue-50); }
.shipping-card.selected {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.carrier-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--gray-700);
  flex-shrink: 0;
}

.carrier-postnl { background: #FF6200; color: white; }
.carrier-dhl    { background: #FFCC00; color: #D40511; }
.carrier-dpd    { background: #DC0032; color: white; }
.carrier-gls    { background: #0066B2; color: white; }
.carrier-ups    { background: #351C15; color: #FFB500; }

.shipping-info { flex: 1; min-width: 0; }
.shipping-name { font-weight: 700; font-size: .95rem; color: var(--gray-900); }
.shipping-sub  { font-size: .8rem; color: var(--gray-500); margin-top: 1px; }

.shipping-price {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--blue-800);
  flex-shrink: 0;
}

.shipping-selected-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue-600);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shipping-selected-mark svg { stroke: white; }
.shipping-card.selected .shipping-selected-mark { display: flex; }

.no-methods {
  text-align: center;
  padding: 24px;
  color: var(--gray-500);
  font-size: .9rem;
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius-md);
}

/* ── Order Summary ───────────────────────────────────────────────────────── */
.order-summary {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 22px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: .9rem;
}
.summary-row:last-child { border-bottom: none; }

.summary-label { color: var(--gray-500); font-weight: 500; white-space: nowrap; }
.summary-value { color: var(--gray-900); font-weight: 600; text-align: right; }

.summary-total {
  background: var(--blue-50);
  padding: 14px 16px;
}
.summary-total .summary-label { font-weight: 700; color: var(--gray-700); }
.summary-total .summary-value { font-size: 1.15rem; font-weight: 800; color: var(--blue-800); }

/* ── Payment Buttons ─────────────────────────────────────────────────────── */
.payment-section { margin-bottom: 16px; }

.payment-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 10px;
  transition: border-color var(--transition), background var(--transition), transform 80ms ease;
  text-align: left;
}

.payment-btn:active { transform: scale(.98); }

.payment-ideal {
  border-color: #CC0066;
}
.payment-ideal:hover {
  background: #FFF5FA;
  border-color: #CC0066;
}

.payment-cash:hover {
  border-color: var(--blue-500);
  background: var(--blue-50);
}

.payment-logo {
  height: 28px;
  width: auto;
}

.payment-logo-text {
  font-size: 1rem;
  font-weight: 900;
  color: #CC0066;
  font-style: italic;
}

.payment-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.payment-info {
  flex: 1;
}
.payment-info strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-900);
}
.payment-info span {
  font-size: .82rem;
  color: var(--gray-500);
}

/* ── Kassa Screen ────────────────────────────────────────────────────────── */
.kassa-card {
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-900) 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 16px;
}

.kassa-order-id {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: .12em;
  font-family: 'Courier New', monospace;
  margin-bottom: 4px;
}

.kassa-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .7;
  margin-bottom: 16px;
}

.kassa-divider {
  height: 1px;
  background: rgba(255,255,255,.2);
  margin-bottom: 16px;
}

.kassa-amount-label {
  font-size: .85rem;
  opacity: .8;
  margin-bottom: 4px;
}

.kassa-amount {
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 16px;
}

.kassa-details {
  font-size: .82rem;
  opacity: .85;
  line-height: 1.6;
}

.kassa-instructions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--blue-50);
  border-radius: var(--radius-md);
  font-size: .85rem;
  color: var(--blue-800);
  margin-bottom: 20px;
}

.kassa-instructions svg { flex-shrink: 0; margin-top: 2px; stroke: var(--blue-600); }

/* ── Success screen ──────────────────────────────────────────────────────── */
.success-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.success-header .result-icon { margin: 0; flex-shrink: 0; }
.success-header h2 { font-size: 1.2rem; margin-bottom: 4px; }
.success-header p  { color: var(--gray-500); font-size: .9rem; }

.label-preview-wrap {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--gray-100);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-iframe {
  width: 100%;
  height: 520px;
  border: none;
  display: block;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Processing & Result screens ─────────────────────────────────────────── */
.processing-animation {
  margin: 0 auto 20px;
  width: 64px;
  height: 64px;
}

.result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.result-success {
  background: var(--green-100);
  color: var(--green-600);
}

.result-error {
  background: var(--red-100);
  color: var(--red-600);
}

.screen-centered h2 { font-size: 1.3rem; margin-bottom: 8px; }
.screen-centered p  { color: var(--gray-500); margin-bottom: 8px; }
.screen-centered .hint { font-size: .82rem; margin-bottom: 24px; }
.screen-centered .btn { margin-top: 16px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

.spinner-lg {
  width: 56px;
  height: 56px;
  border-width: 5px;
}

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

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  color: var(--gray-500);
  font-size: .9rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.alert-error {
  background: var(--red-50);
  color: var(--red-600);
  border: 1px solid #FCA5A5;
}

.hidden { display: none !important; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  pointer-events: auto;
}

.toast.toast-error   { background: var(--red-600); }
.toast.toast-success { background: var(--green-600); }

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

/* ── Demo Banner ─────────────────────────────────────────────────────────── */
.demo-banner {
  background: var(--orange-500);
  color: var(--white);
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 12px;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .header-inner   { padding: 12px 12px 8px; }
  .screen-card    { padding: 20px 16px; }
  .weight-options { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .weight-btn     { padding: 10px 4px; }
  .weight-icon    { font-size: 1.2rem; }
  .weight-name    { font-size: .72rem; }
  .weight-desc    { font-size: .65rem; }
  .kassa-amount   { font-size: 2.4rem; }
  .kassa-order-id { font-size: 1.8rem; }
}

/* ── Kassa waiting indicator ────────────────────────────────────────────── */
.kassa-waiting {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; background: #F0FDF4; border: 1px solid #86EFAC;
  border-radius: 10px; color: #16A34A; font-weight: 600;
  margin-bottom: 12px;
}
.spinner-sm {
  width: 18px; height: 18px; border: 2px solid #86EFAC;
  border-top-color: #16A34A; border-radius: 50%;
  animation: spin .8s linear infinite; flex-shrink: 0;
}

/* ── Cash print hint ────────────────────────────────────────────────────── */
.cash-print-hint {
  display: flex; align-items: center; gap: 10px;
  background: #EFF6FF; border: 1px solid #BFDBFE;
  color: #1E40AF; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
  font-size: .9rem; font-weight: 500;
}

/* ── BETAALD knop ───────────────────────────────────────────────────────── */
.btn-betaald {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 22px 24px;
  background: #16A34A; color: #fff;
  border: none; border-radius: 16px;
  font-size: 1.3rem; font-weight: 800; letter-spacing: .04em;
  cursor: pointer; transition: background .15s, transform .1s;
  box-shadow: 0 4px 16px rgba(22,163,74,.35);
}
.btn-betaald:hover  { background: #15803d; }
.btn-betaald:active { transform: scale(.98); }
.btn-betaald:disabled { background: #86efac; cursor: not-allowed; box-shadow: none; }

@media (min-width: 560px) {
  .app-main { padding: 24px 16px 60px; }
  .screen-card { padding: 32px 28px; }
}
