/* ==========================================================================
   EU Withdrawal Button — storefront styles
   Button visuals are driven by CSS custom properties set inline by the Liquid
   block (zero-flash). The modal derives from a few brand tokens applied by the
   JS, with premium defaults below so an unconfigured modal still looks polished.
   ========================================================================== */

/* ----- Storefront trigger button ----- */
.eu-withdrawal-button-block { margin: 1rem 0; }

.eu-withdrawal-button {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  box-sizing: border-box;
  width: var(--ewb-btn-width, auto);
  max-width: 100%;
  font: inherit;
  font-size: var(--ewb-btn-fs, 15px);
  font-weight: var(--ewb-btn-fw, 600);
  letter-spacing: var(--ewb-btn-ls, 0);
  line-height: 1.2;
  text-transform: var(--ewb-btn-tt, none);
  text-decoration: none;
  padding: var(--ewb-btn-py, 14px) var(--ewb-btn-px, 20px);
  border-radius: var(--ewb-btn-radius, 8px);
  border-style: solid;
  border-width: var(--ewb-btn-border-w, var(--ewb-preset-border-w, 0px));
  border-color: var(--ewb-btn-border, var(--ewb-preset-border, transparent));
  background: var(--ewb-btn-bg, var(--ewb-preset-bg, var(--ewb-accent, #111827)));
  color: var(--ewb-btn-fg, var(--ewb-preset-fg, #ffffff));
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}
.eu-withdrawal-button:hover {
  background: var(--ewb-btn-bg-hover, var(--ewb-btn-bg, var(--ewb-preset-bg, var(--ewb-accent, #111827))));
  color: var(--ewb-btn-fg-hover, var(--ewb-btn-fg, var(--ewb-preset-fg, #ffffff)));
  opacity: .9;
}
.eu-withdrawal-button:focus-visible {
  outline: 2px solid var(--ewb-accent, #111827);
  outline-offset: 2px;
}

/* Preset fallbacks (used unless a per-property override is set on the element) */
.eu-withdrawal-button.ewb-minimal {
  --ewb-preset-bg: transparent;
  --ewb-preset-fg: var(--ewb-accent, #111827);
  --ewb-preset-border: transparent;
  --ewb-preset-border-w: 0px;
}
.eu-withdrawal-button.ewb-minimal:hover { text-decoration: underline; opacity: 1; }
.eu-withdrawal-button.ewb-solid {
  --ewb-preset-bg: var(--ewb-accent, #111827);
  --ewb-preset-fg: #ffffff;
  --ewb-preset-border: transparent;
  --ewb-preset-border-w: 0px;
}
.eu-withdrawal-button.ewb-outline {
  --ewb-preset-bg: transparent;
  --ewb-preset-fg: var(--ewb-accent, #111827);
  --ewb-preset-border: var(--ewb-accent, #111827);
  --ewb-preset-border-w: 1px;
}

/* ----- Modal ----- */
.ewb-backdrop {
  --ewb-accent: #111827;
  --ewb-surface: #ffffff;
  --ewb-ink: #1a1a1a;
  --ewb-muted: #6b7280;
  --ewb-hairline: #e5e7eb;
  --ewb-subtle: #f7f7f8;
  --ewb-danger: #b42318;
  --ewb-danger-bg: #fef3f2;
  --ewb-radius: 12px;

  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, .5);
  font-family: inherit;
  animation: ewb-fade .18s ease;
}

.ewb-modal {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
  padding: 32px;
  background: var(--ewb-surface, #fff);
  color: var(--ewb-ink, #1a1a1a);
  border-radius: var(--ewb-radius, 12px);
  box-shadow: 0 24px 60px rgba(17, 24, 39, .22);
  font-size: 15px;
  line-height: 1.55;
  animation: ewb-rise .2s ease;
}

.ewb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ewb-muted, #6b7280);
  line-height: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ewb-close:hover { background: var(--ewb-subtle, #f7f7f8); color: var(--ewb-ink, #1a1a1a); }
.ewb-close:focus-visible { outline: 2px solid var(--ewb-accent); outline-offset: 2px; }

.ewb-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ewb-muted);
}
.ewb-title {
  margin: 0 0 4px;
  padding-right: 40px;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ewb-ink);
}
.ewb-step { margin: 0 0 16px; font-size: 13px; color: var(--ewb-muted); }
.ewb-progress {
  height: 2px;
  margin: 0 0 24px;
  background: var(--ewb-hairline);
  border-radius: 2px;
  overflow: hidden;
}
.ewb-progress__bar { height: 100%; background: var(--ewb-accent); border-radius: 2px; transition: width .25s ease; }

.ewb-field { margin: 0 0 14px; }
.ewb-label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ewb-ink); }
.ewb-help { margin: 6px 0 0; font-size: 12px; line-height: 1.4; color: var(--ewb-muted); }
.ewb-modal input,
.ewb-modal select,
.ewb-modal textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ewb-ink);
  background: var(--ewb-surface, #fff);
  border: 1px solid var(--ewb-hairline);
  border-radius: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ewb-modal textarea { min-height: 80px; resize: vertical; }
.ewb-modal input:focus,
.ewb-modal select:focus,
.ewb-modal textarea:focus {
  outline: none;
  border-color: var(--ewb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ewb-accent) 18%, transparent);
}
.ewb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.ewb-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 24px; }
.ewb-action {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}
.ewb-action--primary { background: var(--ewb-accent); color: #fff; }
.ewb-action--primary:hover { opacity: .9; }
.ewb-action--ghost { background: transparent; color: var(--ewb-ink); border-color: var(--ewb-hairline); }
.ewb-action--ghost:hover { background: var(--ewb-subtle); }
.ewb-action:focus-visible { outline: 2px solid var(--ewb-accent); outline-offset: 2px; }

.ewb-items { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 0; }
.ewb-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--ewb-hairline);
  border-radius: 10px;
  transition: border-color .15s ease;
}
.ewb-item:has(input[type="checkbox"]:checked) { border-color: var(--ewb-accent); }
.ewb-item--excluded { background: var(--ewb-subtle); }
/* Theme hardening: the modal is injected at <body> level, so the host theme's
   global form styles (especially aggressive `input[type="checkbox"]` rules, often
   `!important`) can bleed in and blow out this row. The `.ewb-backdrop` prefix
   out-specifies those rules; `!important` is used only on layout-critical props.
   The checkbox is fully self-drawn (appearance:none) so it renders identically on
   every theme and stays on-brand via --ewb-accent. */
.ewb-item__main {
  display: flex !important;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 12px;
}
.ewb-backdrop .ewb-item__check {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
  flex: none !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 0 !important;
  max-width: none !important;
  margin: 1px 0 0 !important;
  padding: 0 !important;
  border: 1.5px solid var(--ewb-hairline) !important;
  border-radius: 6px !important;
  background: var(--ewb-surface) !important;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.ewb-backdrop .ewb-item__check:checked {
  border-color: var(--ewb-accent) !important;
  background: var(--ewb-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M5 13l4 4L19 7' stroke='%23ffffff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px 13px no-repeat !important;
}
.ewb-backdrop .ewb-item__check:focus-visible { outline: 2px solid var(--ewb-accent); outline-offset: 2px; }
.ewb-backdrop .ewb-item__body {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}
.ewb-backdrop .ewb-item__title {
  display: block !important;
  float: none !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ewb-ink);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.ewb-item__sku { color: var(--ewb-muted); font-size: 13px; }
.ewb-pill {
  display: inline-block;
  margin-left: auto;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ewb-muted);
  background: var(--ewb-surface);
  border: 1px solid var(--ewb-hairline);
  border-radius: 999px;
  white-space: nowrap;
}
.ewb-reason { margin: 0; font-size: 13px; color: var(--ewb-muted); }
.ewb-qty { display: flex; align-items: center; gap: 8px; }
.ewb-qty label { font-size: 13px; color: var(--ewb-muted); }
.ewb-backdrop .ewb-qty input {
  box-sizing: border-box !important;
  width: 88px !important;
  max-width: 88px !important;
  min-height: 38px !important;
  margin: 0 !important;
}

.ewb-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ewb-danger, #b42318);
  background: var(--ewb-danger-bg, #fef3f2);
  border: 1px solid color-mix(in srgb, var(--ewb-danger) 25%, transparent);
  border-radius: 8px;
}
.ewb-error svg { flex: none; margin-top: 2px; }

.ewb-hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.ewb-success { text-align: center; padding: 8px 0; }
.ewb-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ewb-accent);
  background: color-mix(in srgb, var(--ewb-accent) 12%, transparent);
  border-radius: 50%;
}
.ewb-success__title { margin: 0 0 8px; font-size: 20px; font-weight: 600; color: var(--ewb-ink); }
.ewb-success__date { margin: 0 0 4px; font-weight: 600; color: var(--ewb-ink); }
.ewb-success__note { margin: 0 auto; max-width: 360px; font-size: 14px; color: var(--ewb-muted); }
.ewb-success .ewb-actions { justify-content: center; }

@keyframes ewb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ewb-rise { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .ewb-modal { padding: 22px; }
  .ewb-row { grid-template-columns: 1fr; }
  .ewb-actions { flex-direction: column-reverse; align-items: stretch; }
  .ewb-action { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ewb-backdrop, .ewb-modal { animation: none; }
  .eu-withdrawal-button,
  .ewb-action, .ewb-close,
  .ewb-modal input, .ewb-modal select, .ewb-modal textarea,
  .ewb-progress__bar { transition: none; }
}
