/* CTC — "Completá tu compra" · estilos
 * Los colores salen de las variables del tema Morelia (static/css/style-tokens.tpl):
 * --main-foreground, --main-background, --button-background, --button-foreground,
 * --main-foreground-opacity-NN, --success, --danger, --body-font.
 * Si alguna no existe, se usa el valor de respaldo.
 * Todas las clases llevan prefijo .ctc- para no chocar con el tema ni con otros módulos. */

.ctc {
  --ctc-font: var(--body-font, inherit);
  --ctc-text: var(--main-foreground, #2b2724);
  --ctc-muted: var(--main-foreground-opacity-50, #8a8279);
  --ctc-line: var(--main-foreground-opacity-10, #e8e2da);
  --ctc-bg: var(--main-background, #ffffff);
  --ctc-bg-soft: var(--main-foreground-opacity-03, #faf7f3);
  --ctc-accent: var(--button-background, #2b2724);   /* checkbox y botón */
  --ctc-accent-text: var(--button-foreground, #ffffff);
  --ctc-ok: var(--success, #3d6b4f);
  --ctc-error: var(--danger, #a8442f);
  --ctc-radius: 6px;
  --ctc-thumb: 64px;

  font-family: var(--ctc-font);
  color: var(--ctc-text);
  text-align: left;
  margin: 24px 0 32px;
  padding-top: 24px;
  border-top: 1px solid var(--ctc-line);
}

.ctc *, .ctc *::before, .ctc *::after { box-sizing: border-box; }

/* ---------- encabezado ---------- */
.ctc-head { margin-bottom: 16px; }
.ctc-title {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: .01em;
  margin: 0;
  color: var(--ctc-text);
}
.ctc-sub { margin: 4px 0 0; font-size: .875rem; color: var(--ctc-muted); }

/* ---------- lista ---------- */
.ctc-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ctc-line); }

.ctc-item {
  border-bottom: 1px solid var(--ctc-line);
  transition: background-color .2s ease;
}
.ctc-item.is-selected { background: var(--ctc-bg-soft); }

.ctc-row {
  display: grid;
  grid-template-columns: 20px var(--ctc-thumb) 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 12px 14px 4px;
  cursor: pointer;
  margin: 0;
}
.ctc-item.is-soldout .ctc-row { cursor: not-allowed; }

/* checkbox propio, accesible (el input real queda visualmente oculto) */
.ctc-check {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.ctc-box {
  width: 20px; height: 20px;
  border: 1.5px solid var(--ctc-muted);
  border-radius: 4px;
  display: grid; place-items: center;
  transition: background-color .15s, border-color .15s;
  background: var(--ctc-bg);
}
.ctc-box::after {
  content: '';
  width: 10px; height: 6px;
  border: 2px solid var(--ctc-accent-text);
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform .15s ease;
}
.ctc-check:checked + .ctc-box { background: var(--ctc-accent); border-color: var(--ctc-accent); }
.ctc-check:checked + .ctc-box::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.ctc-check:focus-visible + .ctc-box { outline: 2px solid var(--ctc-accent); outline-offset: 2px; }
.ctc-check:disabled + .ctc-box { border-color: var(--ctc-line); background: var(--ctc-bg-soft); }

.ctc-thumb {
  width: var(--ctc-thumb); height: var(--ctc-thumb);
  border-radius: var(--ctc-radius);
  overflow: hidden;
  background: var(--ctc-bg-soft);
}
.ctc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctc-item.is-soldout .ctc-thumb img { opacity: .45; filter: grayscale(.6); }

.ctc-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ctc-name { font-size: .9375rem; line-height: 1.35; }
.ctc-desc { font-size: .8125rem; color: var(--ctc-muted); }
.ctc-price { font-size: .9375rem; display: flex; gap: 8px; align-items: baseline; }
.ctc-price-now { font-weight: 500; }
.ctc-price-was { font-size: .8125rem; color: var(--ctc-muted); }
.ctc-price-was:empty { display: none; }
.ctc-soldout { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ctc-muted); }
.ctc-item.is-soldout .ctc-name { color: var(--ctc-muted); }

/* ---------- opciones (variantes / cantidad) ---------- */
.ctc-options {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 0 12px 16px calc(4px + 20px + 14px + var(--ctc-thumb) + 14px);
}
.ctc-options[hidden] { display: none; }
.ctc-field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.ctc-field-label { font-size: .75rem; color: var(--ctc-muted); letter-spacing: .02em; }

.ctc-select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-size: .875rem; color: var(--ctc-text);
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--ctc-line);
  border-radius: var(--ctc-radius);
  background: var(--ctc-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8279' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  min-height: 40px;
  cursor: pointer;
}
.ctc-select:focus { outline: none; border-color: var(--ctc-accent); }
.ctc-select:disabled { opacity: .5; cursor: not-allowed; }
.ctc-item.has-error .ctc-select:invalid,
.ctc-item.has-error .ctc-select { border-color: var(--ctc-error); }

.ctc-stepper {
  display: inline-flex; align-items: center;
  border: 1px solid var(--ctc-line); border-radius: var(--ctc-radius);
  height: 40px; background: var(--ctc-bg);
}
.ctc-stepper button {
  width: 36px; height: 100%; border: 0; background: none; font-size: 1rem; cursor: pointer; color: var(--ctc-text);
}
.ctc-stepper output { min-width: 28px; text-align: center; font-size: .875rem; }

.ctc-field-error { flex-basis: 100%; margin: 0; font-size: .8125rem; color: var(--ctc-error); }
.ctc-field-error[hidden] { display: none; }

/* ---------- ver más (solo mobile) ---------- */
.ctc-more {
  display: none;
  width: 100%;
  margin: 0; padding: 12px;
  border: 0; border-bottom: 1px solid var(--ctc-line);
  background: none; font: inherit; font-size: .875rem;
  color: var(--ctc-text); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- pie ---------- */
.ctc-foot {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px 20px;
  margin-top: 18px;
}
.ctc-summary { display: flex; flex-direction: column; gap: 2px; font-size: .8125rem; color: var(--ctc-muted); }
.ctc-total { font-size: 1.0625rem; font-weight: 500; color: var(--ctc-text); }
.ctc-total:empty { display: none; }

.ctc-submit {
  font: inherit; font-size: .9375rem; font-weight: 500; letter-spacing: .01em;
  padding: 14px 24px; min-height: 48px;
  border: 1px solid var(--ctc-accent);
  border-radius: var(--ctc-radius);
  background: var(--ctc-accent); color: var(--ctc-accent-text);
  cursor: pointer;
  transition: opacity .2s, background-color .2s;
}
.ctc-submit:hover:not(:disabled) { opacity: .88; }
.ctc-submit:disabled { background: transparent; color: var(--ctc-muted); border-color: var(--ctc-line); cursor: default; }
.ctc.is-loading .ctc-submit { opacity: .6; cursor: progress; }

.ctc-status { grid-column: 1 / -1; margin: 0; font-size: .875rem; }
.ctc-status:empty { display: none; }
.ctc-status.is-ok, .ctc-status.is-partial, .ctc-status.is-error {
  padding: 12px 14px; border-radius: var(--ctc-radius); background: var(--ctc-bg-soft);
}
.ctc-status.is-ok { border-left: 3px solid var(--ctc-ok); }
.ctc-status.is-partial { border-left: 3px solid #b8892f; }
.ctc-status.is-error { border-left: 3px solid var(--ctc-error); }
.ctc-status.is-loading { color: var(--ctc-muted); }
.ctc-status-title { margin: 0 0 4px; font-weight: 500; color: var(--ctc-ok); }
.ctc-status-fail { color: var(--ctc-error); margin-top: 8px; }
.ctc-status ul { margin: 0; padding-left: 18px; }
.ctc-status li { margin: 2px 0; }
.ctc-cart-link { display: inline-block; margin-top: 8px; color: var(--ctc-text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- panel de diagnóstico (data-ctc-debug) ---------- */
.ctc-debug { margin: 16px 0; border: 1px dashed #b8892f; border-radius: 6px; padding: 8px 12px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; background: #fffdf7; color: #333; }
.ctc-debug summary { cursor: pointer; font-weight: 600; }
.ctc-debug-help { margin: 8px 0; font-family: inherit; }
.ctc-debug-copy { font: inherit; padding: 6px 10px; border: 1px solid #b8892f; background: #fff; border-radius: 4px; cursor: pointer; }
.ctc-debug-log { max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid #eee; padding: 8px; margin: 8px 0 0; }
.ctc-debug-empty { font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; color: #8a5a00; background: #fffdf7; border: 1px dashed #b8892f; padding: 10px 12px; border-radius: 6px; }

/* ---------- skeleton de carga ---------- */
.ctc-skeleton { display: grid; gap: 10px; margin: 32px 0; padding-top: 24px; }
.ctc-skeleton span {
  height: 64px; border-radius: 6px;
  background: linear-gradient(90deg, var(--main-foreground-opacity-05, #f3efe9) 0%, var(--main-foreground-opacity-03, #faf7f3) 50%, var(--main-foreground-opacity-05, #f3efe9) 100%);
  background-size: 200% 100%;
  animation: ctc-shimmer 1.4s infinite linear;
}
@keyframes ctc-shimmer { to { background-position: -200% 0; } }

/* ---------- tablet ---------- */
@media (max-width: 1024px) {
  .ctc { --ctc-thumb: 56px; }
}

/* ---------- mobile ---------- */
@media (max-width: 767px) {
  .ctc { --ctc-thumb: 52px; margin: 24px 0; padding-top: 20px; }
  .ctc-row { gap: 12px; padding: 12px 4px; }
  .ctc-options { padding: 0 4px 14px; }
  .ctc-field { flex: 1 1 100%; min-width: 0; }
  .ctc-select { width: 100%; }

  .ctc.is-collapsible .ctc-more { display: block; }
  .ctc.is-collapsed .ctc-item.is-extra { display: none; }

  .ctc-foot { grid-template-columns: 1fr; }
  .ctc-summary { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .ctc-submit { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ctc *, .ctc-skeleton span { transition: none !important; animation: none !important; }
}
