/* Ccoins Checkout · demo
   Dos capas: el "shell" de la demo (gris neutro) y el checkout (.checkout), que
   toma todo su aspecto de variables --co-* que fija el tema del comercio. */

:root {
  --bg: #f6f8f2;
  --surface: #ffffff;
  --ink: #17201a;
  --ink-2: #52604f;
  --line: #e2e8da;
  --accent: #5a9a00;
  --accent-dark: #2b4005;
  --accent-lime: #aae852;
  --accent-soft: #eef6dc;
  --ok: #2f7d12;
  --warn: #b45309;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3, p { margin: 0; }

code, pre, .mono { font-family: var(--mono); }

button, input, select { font: inherit; color: inherit; }

/* ---------- barra superior ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 650; }
.brand-logo { height: 28px; width: auto; display: block; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-dark);
  color: var(--accent-lime);
  font-weight: 700;
}

.pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.topbar-note { color: var(--warn); font-size: 13px; text-align: right; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stage-head h1 { font-size: 22px; letter-spacing: -0.01em; }
.lead { color: var(--ink-2); margin-top: 2px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 550;
  transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover:not(:disabled) { border-color: #c5d0b6; background: #fafcf6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .segmented button:focus-visible,
.btn-link:focus-visible, .chip:focus-visible, .co-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a8000; border-color: #4a8000; }

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

/* ---------- stepper ---------- */

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.stepper li {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 10px 12px 10px 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
}

.stepper .dot {
  position: absolute;
  left: 12px;
  top: 15px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #c3cdb6;
  background: var(--surface);
}

.step-name { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.step-hint { font-size: 12px; }

.stepper li.is-done .dot { border-color: var(--ok); background: var(--ok); }
.stepper li.is-current[data-step="paid"] { border-color: var(--ok); background: var(--accent-soft); }
.stepper li.is-current[data-step="paid"] .dot { border-color: var(--ok); background: var(--ok); }
.stepper li.is-current { border-color: var(--accent); background: var(--accent-soft); }
.stepper li.is-current .dot { border-color: var(--accent); background: var(--accent); }
.stepper.is-expired li.is-current { border-color: #d14343; background: #fdeeee; }
.stepper.is-expired li.is-current .dot { border-color: #d14343; background: #d14343; }

/* ---------- el dispositivo donde se ve el checkout ---------- */

.device {
  display: flex;
  justify-content: center;
  padding: 32px 16px;
  border: 1px dashed #c9d4b8;
  border-radius: 24px;
  background:
    linear-gradient(#fafcf6, #f0f4e6);
}

/* ---------- checkout (themable) ---------- */

.checkout {
  --co-primary: #5a9a00;
  --co-bg: #ffffff;
  --co-text: #17201a;
  --co-radius: 18px;
  --co-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --co-on-primary: #ffffff;
  --co-muted: color-mix(in srgb, var(--co-text) 62%, var(--co-bg));
  --co-line: color-mix(in srgb, var(--co-text) 14%, var(--co-bg));
  --co-soft: color-mix(in srgb, var(--co-primary) 10%, var(--co-bg));

  width: 100%;
  max-width: 460px;
  padding: 22px;
  border: 1px solid var(--co-line);
  border-radius: calc(var(--co-radius) + 4px);
  background: var(--co-bg);
  color: var(--co-text);
  font-family: var(--co-font);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px rgba(15, 23, 42, .08);
  transition: background .2s, color .2s;
}

.checkout .mono, .checkout code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.co-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }

.co-logo {
  width: 44px;
  height: 44px;
  flex: none;
  object-fit: contain;
  border-radius: var(--co-radius);
  background: var(--co-soft);
}

.co-name { font-size: 17px; font-weight: 650; line-height: 1.2; }
.co-message { margin-top: 2px; color: var(--co-muted); font-size: 13px; }

.co-body { display: grid; gap: 14px; }
.co-summary, .co-payment { display: grid; gap: 14px; align-content: start; }

.co-block {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--co-line);
  border-radius: var(--co-radius);
}

.co-block.fixed { background: color-mix(in srgb, var(--co-text) 3%, var(--co-bg)); }
.co-block[hidden] { display: none; }

.co-label { color: var(--co-muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.co-total { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.co-sub { color: var(--co-muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: grid;
  gap: 1px;
  min-width: 118px;
  padding: 9px 12px;
  border: 1px solid var(--co-line);
  border-radius: var(--co-radius);
  background: var(--co-bg);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.chip b { font-size: 14px; }
.chip span { color: var(--co-muted); font-size: 12px; }
.chip:hover:not(:disabled) { border-color: var(--co-primary); }
.chip[aria-checked="true"] { border-color: var(--co-primary); background: var(--co-soft); box-shadow: inset 0 0 0 1px var(--co-primary); }
.chip:disabled { opacity: .5; cursor: default; }

.co-qr-wrap { position: relative; justify-self: center; }

.co-qr {
  width: 172px;
  height: 172px;
  padding: 8px;
  border-radius: calc(var(--co-radius) - 2px);
  background: #fff;
  line-height: 0;
}

.co-qr svg { width: 100%; height: 100%; }

.co-demo-tag {
  position: absolute;
  right: -6px;
  top: -8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d14343;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
}

.co-data { display: grid; gap: 10px; margin: 6px 0 0; }
.co-data div { display: grid; gap: 1px; }
.co-data dt { color: var(--co-muted); font-size: 12px; }
.co-data dd { margin: 0; word-break: break-all; }
.strong { font-size: 17px; font-weight: 650; }
.addr-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; }
.addr-row .btn-link { white-space: nowrap; }
.addr-row code { font-size: 12.5px; }
.checkout .btn-link { color: var(--co-primary); }

.co-status { display: grid; gap: 8px; }
.co-status-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }

.co-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--co-line);
  border-top-color: var(--co-primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.co-check {
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--co-primary);
  color: var(--co-on-primary);
  font-size: 13px;
}

.co-progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--co-line); }
.co-progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--co-primary); transition: width .5s ease; }
.co-progress[hidden] { display: none; }

.co-button {
  width: 100%;
  margin-top: 4px;
  padding: 13px 16px;
  border: 0;
  border-radius: var(--co-radius);
  background: var(--co-primary);
  color: var(--co-on-primary);
  font-weight: 650;
  cursor: pointer;
}

.co-button[hidden] { display: none; }

.co-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--co-line);
  color: var(--co-muted);
  font-size: 12px;
}

/* estados del checkout */
.checkout[data-state="created"] .co-spinner,
.checkout[data-state="created"] .co-progress { display: none; }
.checkout[data-state="paid"] .co-spinner,
.checkout[data-state="expired"] .co-spinner { display: none; }
.checkout[data-state="paid"] .co-check { display: grid; }
.checkout[data-state="expired"] .co-status-line { color: #c24141; }
.checkout[data-state="expired"] .co-qr { opacity: .25; filter: grayscale(1); }

/* ---------- plantillas ---------- */

.checkout[data-template="minimal"] {
  max-width: 400px;
  border-color: transparent;
  box-shadow: none;
  padding: 10px 6px;
}

.checkout[data-template="minimal"] .co-head { flex-direction: column; text-align: center; }
.checkout[data-template="minimal"] .co-block { border: 0; padding: 8px 0; text-align: center; }
.checkout[data-template="minimal"] .co-block.fixed { background: none; }
.checkout[data-template="minimal"] .chips { justify-content: center; }
.checkout[data-template="minimal"] .co-data { text-align: center; }
.checkout[data-template="minimal"] .addr-row { justify-content: center; flex-wrap: wrap; }
.checkout[data-template="minimal"] .co-status-line { justify-content: center; }
.checkout[data-template="minimal"] .co-foot { justify-content: center; }
.checkout[data-template="minimal"] .co-foot-note { display: none; }

.checkout[data-template="compact"] { max-width: 640px; }

.checkout[data-template="compact"] .co-body {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.checkout[data-template="compact"] .co-summary { display: grid; gap: 14px; }
.checkout[data-template="compact"] .co-payment { display: grid; gap: 14px; }
.checkout[data-template="compact"] .co-total { font-size: 26px; }

/* ---------- panel del comercio ---------- */

.panel {
  position: sticky;
  top: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  overflow: hidden;
}

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); background: #fafcf6; }

.tab {
  padding: 12px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] { border-bottom-color: var(--accent); background: var(--surface); color: var(--ink); }

.tabpanel { display: grid; gap: 14px; padding: 18px; max-height: calc(100vh - 120px); overflow: auto; }
.tabpanel[hidden] { display: none; }
.panel-title { font-size: 16px; }
.hint { color: var(--ink-2); font-size: 13px; }

.field { display: grid; gap: 6px; }
.field-label { color: var(--ink-2); font-size: 12px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

input[type="text"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

input[type="text"]:focus-visible, select:focus-visible, input[type="color"]:focus-visible, input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="color"] { width: 100%; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
output { color: var(--ink); font-family: var(--mono); text-transform: none; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button { padding: 8px; border: 0; border-right: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); }

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

.preset {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.preset:hover { border-color: #c5d0b6; }
.preset-swatch { display: flex; height: 22px; overflow: hidden; border-radius: 6px; border: 1px solid var(--line); }
.preset-swatch i { flex: 1; }
.preset b { font-size: 13px; }

.logo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-preview { width: 40px; height: 40px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.check { padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.check.ok { background: var(--accent-soft); color: #2f6b0a; }
.check.bad { background: #fdeeee; color: #a02929; }

.code {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 14px;
  background: #14231a;
  color: #dbe8d2;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.badge { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: #2f6b0a; font-size: 12px; text-transform: none; letter-spacing: 0; }

.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th, .log td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.log th { color: var(--ink-2); font-size: 12px; }
.log td:last-child { color: var(--ok); font-family: var(--mono); }
.log .empty td { color: var(--ink-2); font-family: inherit; }

.sitefoot { max-width: 1280px; margin: 0 auto; padding: 8px 24px 32px; color: var(--ink-2); font-size: 13px; }

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

@media (prefers-reduced-motion: reduce) {
  .co-spinner { animation: none; }
  .co-progress-bar, .checkout { transition: none; }
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .tabpanel { max-height: none; }
}

@media (max-width: 640px) {
  .layout { padding: 16px; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  .topbar-note { text-align: left; }
  .stepper { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .presets { grid-template-columns: 1fr; }
  .checkout[data-template="compact"] .co-body { grid-template-columns: 1fr; }
  .device { padding: 16px 8px; }
}
