/* ============================================================
   Motor de Cobranza — Checkout (SyServ)
   Página pública de pago. Todas las clases usan el prefijo "co-"
   y son independientes de cualquier framework CSS.
   ============================================================ */

:root {
  color-scheme: light;
  --co-purple-900: #3b1671;
  --co-purple-700: #5b21b6;
  --co-purple-600: #6d28d9;
  --co-purple-500: #7c3aed;
  --co-purple-100: #ede9fe;
  --co-purple-50: #f5f3ff;
  --co-text-dark: #1f2333;
  --co-text-gray: #6b7280;
  --co-border: #e6e4f0;
  --co-bg-page: #f8f7fc;
  --co-radius-lg: 18px;
  --co-radius-md: 12px;
  --co-radius-sm: 8px;
  /* Para cifras/folios (monto, tarjeta, IDs) — los dígitos alinean mejor en
     monoespaciada. Pila del sistema, sin cargar ninguna fuente externa
     nueva (misma filosofía que el resto del proyecto: cero dependencias
     nuevas en una página pública de pago). */
  --co-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--co-bg-page);
  color: var(--co-text-dark);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.co-page {
  max-width: 620px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------------------------------------------------- Encabezado */

.co-header {
  text-align: center;
  margin-bottom: 28px;
}

.co-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.co-brand-logo {
  height: 46px;
  width: auto;
}

.co-badge-title {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}

.co-badge-icon {
  width: 44px;
  height: 44px;
  padding: 11px;
  border-radius: 50%;
  background: var(--co-purple-100);
  color: var(--co-purple-600);
  flex: 0 0 auto;
}

.co-badge-title h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0;
  color: var(--co-text-dark);
  overflow-wrap: break-word;
}

.co-subtitle {
  margin: 0 0 22px;
  color: var(--co-text-gray);
  font-size: 1.05rem;
}

.co-processed-by {
  margin: 0;
  color: var(--co-text-gray);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.co-openpay-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}

.co-op-open {
  color: #142a5b;
  font-weight: 800;
  font-size: 1.15rem;
}
.co-op-pay {
  color: #2f80ed;
  font-weight: 800;
  font-size: 1.15rem;
}

.co-op-caption {
  margin-top: 3px;
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--co-text-gray);
  white-space: nowrap;
}

/* ---------------------------------------------------------- Tarjeta principal */

.co-card {
  background: #fff;
  border: 1px solid var(--co-border);
  border-radius: var(--co-radius-lg);
  box-shadow: 0 10px 30px rgba(76, 29, 149, 0.06);
  padding: 36px 40px 32px;
}

.co-section + .co-section {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--co-border);
}

.co-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.co-section-icon {
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: 10px;
  color: var(--co-text-dark);
  flex: 0 0 auto;
}

.co-section-icon-fill {
  background: var(--co-purple-600);
  color: #fff;
  border-radius: 50%;
}

.co-section-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.co-grid-2 {
  display: grid;
  /* minmax(0,1fr), no "1fr" a secas — sin el mínimo en 0, una celda con
     texto largo sin espacios (referencia, ID de OpenPay) impedía que la
     columna encogiera y desbordaba la tarjeta en vez de ajustarse. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px 24px;
}

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

.co-field-right {
  text-align: right;
}

.co-label {
  font-size: 0.82rem;
  color: var(--co-text-gray);
  font-weight: 600;
}

.co-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--co-text-dark);
  /* Textos largos (concepto, referencia, ID de OpenPay) nunca deben
     desbordar su celda — que salten de línea/corten dentro de su propio
     espacio en vez de romper la tarjeta. */
  overflow-wrap: anywhere;
}

.co-value-mono {
  font-family: var(--co-mono);
  font-variant-numeric: tabular-nums;
}

.co-total-box {
  /* Un solo campo ("Total a pagar") desde que se quitó la fecha límite en la
     Fase 4 — ya no hace falta la rejilla de 2 columnas de cuando había 2. */
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
  background: var(--co-purple-50);
  border-radius: var(--co-radius-md);
  padding: 18px 22px;
}

.co-total-amount {
  font-family: var(--co-mono);
  font-variant-numeric: tabular-nums;
  /* clamp() en vez de un tamaño fijo: un monto largo ($18,450.00 MXN) ya no
     se va a 2 líneas en pantallas angostas, se achica un poco en vez de
     romper — y en pantallas anchas conserva el tamaño grande de antes. */
  font-size: clamp(1.25rem, 1rem + 2vw, 1.6rem);
  font-weight: 800;
  color: var(--co-purple-600);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------- Formulario */

.co-form {
  margin-top: 4px;
}

.co-field {
  margin-bottom: 18px;
}

.co-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--co-text-dark);
  margin-bottom: 7px;
}

.co-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.co-input-icon {
  position: absolute;
  left: 14px;
  width: 19px;
  height: 19px;
  color: #9aa0b4;
  pointer-events: none;
}

.co-input-icon-right {
  left: auto;
  right: 14px;
  cursor: help;
  pointer-events: auto;
}

/* Ícono de marca dentro del campo de número de tarjeta: arranca como el
   ícono genérico y cambia a la marca real (Visa/Mastercard/Amex) en cuanto
   OpenPay.card.cardType() la identifica — a un costado, nunca sobre los
   dígitos (ancho acotado + padding-left del input con margen real de
   sobra). */
.co-input-icon-brand {
  width: auto;
  max-width: 32px;
  min-width: 19px;
  height: 22px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.co-input-icon-brand > span:first-child {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}
.co-field-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.co-field-mark-visa {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1a1f71;
  letter-spacing: -0.02em;
}
.co-field-mark-mc {
  position: relative;
  width: 24px;
  height: 15px;
}
.co-mc-circle-sm {
  position: absolute;
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.co-mc-circle-sm.co-mc-red {
  left: 0;
  background: #eb001b;
}
.co-mc-circle-sm.co-mc-orange {
  left: 8px;
  background: #f79e1b;
  mix-blend-mode: multiply;
}
.co-field-mark-amex {
  background: #2e77bc;
  color: #fff;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 3px 5px;
  border-radius: 3px;
}
.co-input-wrap-brand input {
  /* 14px de left del ícono + hasta 32px de ancho + margen real antes del
     texto — el ícono nunca debe traslaparse con los dígitos. */
  padding-left: 58px !important;
}

.co-input-wrap input {
  width: 100%;
  /* Sin esto, dentro del flex de .co-input-wrap el input no encogía más
     allá del ancho de su propio contenido — en pantallas angostas eso hacía
     que el campo (y su valor, ej. el número de tarjeta) se desbordara del
     contenedor en vez de ajustarse al 100% real disponible. */
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--co-border);
  border-radius: var(--co-radius-sm);
  font-size: 0.98rem;
  color: var(--co-text-dark);
  background: #fff;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.co-input-mono {
  font-family: var(--co-mono);
  letter-spacing: 0.02em;
}

.co-input-wrap input::placeholder {
  color: #b3b7c6;
}

.co-input-wrap:has(.co-input-icon:not(.co-input-icon-right)) input {
  padding-left: 42px;
}

.co-input-wrap:has(.co-input-icon-right) input {
  padding-right: 42px;
}

.co-input-wrap input:focus {
  border-color: var(--co-purple-500);
  box-shadow: 0 0 0 3px var(--co-purple-100);
}

/* ---------------------------------------------------------- Aviso de seguridad */

.co-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--co-purple-50);
  border-radius: var(--co-radius-md);
  padding: 16px 18px;
  margin: 8px 0 22px;
}

.co-notice-icon {
  width: 20px;
  height: 20px;
  color: var(--co-purple-600);
  flex: 0 0 auto;
  margin-top: 2px;
}

.co-notice p {
  margin: 0;
  font-size: 0.88rem;
  color: #4b3f73;
  line-height: 1.5;
}

/* ---------------------------------------------------------- Botón de pago */

.co-pay-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--co-purple-600);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--co-radius-md);
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.co-pay-btn:hover {
  background: var(--co-purple-700);
}

.co-pay-btn-icon {
  width: 19px;
  height: 19px;
}

/* ---------------------------------------------------------- Marcas de tarjeta */

.co-card-brands {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 22px;
}

.co-brand-visa {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 1.3rem;
  color: #1a1f71;
  letter-spacing: -0.02em;
}

.co-brand-mc {
  display: inline-flex;
  width: 40px;
  height: 26px;
  position: relative;
}

.co-mc-circle {
  position: absolute;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.co-mc-red {
  left: 0;
  background: #eb001b;
}
.co-mc-orange {
  left: 14px;
  background: #f79e1b;
  mix-blend-mode: multiply;
}

.co-brand-amex {
  background: #2e77bc;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 6px 9px;
  border-radius: 4px;
}

/* ---------------------------------------------------------- Pie de página */

.co-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding: 0 4px;
  flex-wrap: wrap;
}

.co-footer-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.85rem;
}

.co-footer-item-right {
  text-align: right;
  margin-left: auto;
}

.co-footer-icon {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 50%;
  background: var(--co-purple-100);
  color: var(--co-purple-600);
  flex: 0 0 auto;
}

.co-footer-item strong {
  display: block;
  color: var(--co-text-dark);
  font-size: 0.9rem;
}

.co-footer-item span {
  color: var(--co-text-gray);
}

.co-footer-item a {
  color: var(--co-purple-600);
  font-weight: 700;
  text-decoration: none;
}

.co-footer-item a:hover {
  text-decoration: underline;
}

.co-copyright {
  text-align: center;
  color: #9aa0b4;
  font-size: 0.8rem;
  margin: 28px 0 0;
}

/* ---------------------------------------------------------- Responsive */

@media (max-width: 560px) {
  .co-card {
    padding: 28px 22px 26px;
  }
  .co-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .co-field-right {
    text-align: left;
  }
  .co-footer {
    flex-direction: column;
  }
  .co-footer-item-right {
    text-align: left;
    margin-left: 0;
  }
  .co-brand-logo {
    height: 36px;
  }
  .co-badge-title h1 {
    font-size: 1.35rem;
  }
  .co-badge-icon {
    width: 38px;
    height: 38px;
    padding: 9px;
  }
  .co-processed-by {
    font-size: 0.85rem;
  }
}

@media (max-width: 400px) {
  /* "4111 1111 1111 1111" con el ícono/padding normales ya no cabía
     completo de un vistazo en un teléfono angosto — el input hace scroll
     interno pero no se notaba que había más. Achicar ícono/padding/tamaño
     de fuente solo aquí, sin tocar tablet/escritorio. */
  .co-input-icon-brand {
    max-width: 26px;
    min-width: 17px;
    height: 20px;
  }
  .co-input-wrap-brand input {
    padding-left: 48px !important;
  }
  #coCardNumber {
    font-size: 0.88rem;
  }
}

/* ---------------------------------------------------------- Resultado del pago (demo) */

.co-resultado {
  border-radius: var(--co-radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.co-resultado-exito {
  background: #ecfdf3;
  border: 1px solid #86e8ab;
  color: #087443;
}

.co-resultado-error {
  background: #fef2f2;
  border: 1px solid #f3aeae;
  color: #b42318;
}

/* ---------------------------------------------------------- Confirmación de pago exitoso */

.co-exito-header {
  text-align: center;
  margin-bottom: 20px;
}

.co-exito-icon {
  display: inline-flex;
  width: 56px;
  height: 56px;
  padding: 12px;
  border-radius: 50%;
  background: #ecfdf3;
  color: #087443;
  margin-bottom: 12px;
}

.co-exito-header h2 {
  margin: 0 0 4px;
  color: var(--co-text-dark);
}

.co-exito-sub {
  margin: 0;
  color: var(--co-text-gray);
  font-size: 0.92rem;
}

/* ---------------------------------------------------------- Botón de tarjeta de prueba (sandbox, temporal) */

.co-btn-prueba {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px dashed var(--co-purple-500);
  border-radius: var(--co-radius-sm);
  background: var(--co-purple-50);
  color: var(--co-purple-700);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.co-btn-prueba:hover {
  background: var(--co-purple-100);
}

/* ---------------------------------------------------------- Detección de tipo de tarjeta en vivo */

.co-brand-visa,
.co-brand-mc,
.co-brand-amex {
  transition: opacity 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}

.co-brand-inactiva {
  opacity: 0.25;
  filter: grayscale(70%);
}

.co-brand-activa {
  opacity: 1;
  transform: scale(1.1);
}
