/* =====================================================================
   MODALES — capa oscura, diálogo, formularios (registro, login) y
   lector de guías. Abrir/cerrar: js/core/modal.js
   ===================================================================== */

/* ---------- Capa + diálogo ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200; padding: 20px;
  display: none; align-items: center; justify-content: center;
  background: var(--overlay); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.overlay.open { display: flex; animation: fadeIn .25s; }
.dialog {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 40px;
  background: var(--dialog); border: 1px solid var(--border-red); border-radius: 24px; backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--glow), var(--shadow-xl);
  animation: pop .3s cubic-bezier(.2,.9,.3,1.2);
}
.dialog.wide { max-width: 560px; }
@keyframes pop { from { transform: scale(.94) translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog h3 { font-size: 26px; letter-spacing: -.5px; margin-bottom: 6px; }
.dialog .sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 24px; }
.dialog .btn { width: 100%; margin-top: 8px; }
.close-x {
  float: right; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; line-height: 1;
  background: var(--tint-2); border: 1px solid var(--border); color: var(--muted);
}
.close-x:hover { color: var(--fg-strong); border-color: var(--border-red); }

/* ---------- Campos de formulario ---------- */
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .5px; color: var(--muted); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 13px 15px; outline: none; transition: .2s;
  background: var(--field); border: 1px solid var(--border); border-radius: 12px;
  color: var(--fg-strong); font-size: 14.5px; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,122,26,.18); }
.field select option { background: var(--menu-solid); color: var(--fg-strong); }
/* validación: .field.bad muestra el mensaje .err */
.field .err { font-size: 11.5px; color: #ff7a7a; margin-top: 5px; display: none; }
.field.bad input, .field.bad select { border-color: #ff5a5a; }
.field.bad .err { display: block; }
.form-err { display: none; color: #ff7b7b; font-size: 13px; margin: 10px 0 0; }
.honeypot { position: absolute; left: -9999px; top: -9999px; }

/* ---------- Registro / login ---------- */
.secure-note { margin-top: 14px; font-size: 12px; color: var(--faint); display: flex; gap: 8px; align-items: center; justify-content: center; }
.swap-auth { text-align: center; margin-top: 14px; font-size: 13px; color: #999; }
.swap-auth a { color: var(--red); font-weight: 600; }
.success { text-align: center; padding: 20px 0; }
.success .check {
  width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 20px; color: #3ddc84;
  display: flex; align-items: center; justify-content: center;
  background: rgba(61,220,132,.12); border: 1px solid rgba(61,220,132,.4); box-shadow: 0 0 30px rgba(61,220,132,.25);
}
.success h3 { margin-bottom: 10px; }
.success p { color: var(--muted); font-size: 14.5px; line-height: 1.7; }
.success .btn { margin-top: 22px; }

/* ---------- Lector de guías ---------- */
.doc-body { font-size: 14.5px; color: var(--soft); line-height: 1.85; }
.doc-body h4 { color: var(--fg-strong); font-size: 16px; margin: 20px 0 8px; }
.doc-body code { background: rgba(255,122,26,.12); border: 1px solid var(--border-red); border-radius: 6px; padding: 1px 7px; font-size: 13px; color: #ffd9ad; }
.doc-close { margin-top: 26px; }

@media (max-width: 680px) {
  .f-row { grid-template-columns: 1fr; }
}

/* ---------- Registro v2: prefijo telefónico, paso del código, Turnstile ---------- */
.phone-group { display: flex; gap: 8px; }
.phone-group select { flex: 0 0 118px; width: 118px; }
.phone-group input { flex: 1; min-width: 0; }
.verify-step .code-input { text-align: center; letter-spacing: 12px; font-family: 'Space Grotesk', sans-serif; font-size: 24px; }
.verify-step .sub b { color: var(--text); }
.swap-auth a.off { opacity: .45; pointer-events: none; }
.ts-box { display: flex; justify-content: center; margin: 4px 0 10px; min-height: 65px; }
/* ---------- Descarga no disponible (#dlOv, data-dl con sesión) ---------- */
.dl-warn { text-align: center; max-width: 460px; }
.dl-warn .ic {
  width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center; color: var(--red);
  background: rgba(255,122,26,.10); border: 1px solid var(--border-red);
  box-shadow: var(--glow);
}

@media (max-width: 420px) { .phone-group select { flex-basis: 100px; width: 100px; } }

/* ---------------- combo de países con banderas (flagcdn) ----------------
   La ventana nativa del navegador no dibuja los emoji de bandera en
   Windows (salen como letras), ni acepta imágenes en las <option>: por
   eso el select se peinta con este menú propio. El <select> real sigue
   guardando el .value y despachando 'change' — el combo solo lo decora. */
.combo { position: relative; display: block; }
.combo-hidden { position: absolute; width: 0; height: 0; opacity: 0; overflow: hidden; pointer-events: none; }
.combo-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 13px 15px; background: var(--field); border: 1px solid var(--border);
  border-radius: 12px; color: var(--fg-strong); font-size: 14.5px; font-family: inherit;
  cursor: pointer; text-align: left; transition: .2s;
}
.combo-btn:hover { border-color: var(--border-strong); }
.combo-btn:focus-visible, .combo.open .combo-btn { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,122,26,.18); }
.combo-btn .co-flag, .combo-opt .co-flag {
  width: 21px; height: 15px; border-radius: 3px; object-fit: cover; flex: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.combo-btn .co-flag.co-none, .combo-opt .co-flag.co-none { width: 21px; height: 15px; font-size: 12px; line-height: 15px; text-align: center; }
.combo-btn .co-name, .combo-opt .co-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-btn .co-chev { flex: none; border: 5px solid transparent; border-top-color: #8a8a98; border-bottom-width: 0; margin-top: 6px; transition: .2s; }
.combo.open .co-chev { transform: rotate(180deg); margin-top: 0; }
.combo-pop {
  position: absolute; z-index: 80; top: calc(100% + 6px); left: 0; min-width: 100%;
  width: max-content; max-width: min(320px, calc(100vw - 40px));
  display: none; padding: 6px;
  background: var(--menu-solid); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.combo.open .combo-pop { display: block; }
.combo-filter {
  width: 100%; padding: 10px 12px; margin-bottom: 4px; outline: none; font-family: inherit;
  background: var(--field); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg-strong); font-size: 13.5px;
}
.combo-filter:focus { border-color: rgba(255,122,26,.5); }
.combo-list { max-height: 236px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.combo-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left;
  color: #dcdce4; font-size: 14px; font-family: inherit;
}
.combo-opt:hover, .combo-opt.sel { background: rgba(255,122,26,.14); color: var(--fg-strong); }
.combo-opt .co-flag { width: 20px; height: 14px; border-radius: 2px; }
.combo-opt .co-extra { color: var(--muted); font-size: 12px; flex: none; }
.combo-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }