/* ═══════════════════════════════════════════════════════════
   FUCEREP — Solicitud de préstamos dentro del sitio
   Ventana (<dialog>) con el portal prestamos.fucerep.com.uy en un iframe.
   La arma assets/js/prestamos-embed.js; hoy se usa en prestamos_online.html.
   ═══════════════════════════════════════════════════════════ */

.loan-embed {
  --le-ink: #0e0e0e;
  --le-text: #3a3731;
  --le-muted: #6b665c;
  --le-line: rgba(14, 14, 14, .10);
  --le-grad: linear-gradient(135deg, #ffb200 0%, #ff8000 100%);

  width: min(1600px, calc(100vw - 48px));
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-width: none; max-height: none;
  margin: auto; padding: 0; border: 0;
  border-radius: 28px;
  background: #fff; color: var(--le-ink);
  box-shadow: 0 40px 120px -24px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.loan-embed[open] { display: flex; flex-direction: column; }
.loan-embed::backdrop {
  background: rgba(12, 10, 4, .62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.loan-embed svg {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Barra superior: marca + producto + acciones */
.loan-embed__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--le-line);
  background: linear-gradient(90deg, #fff8e6 0%, #ffffff 60%);
}
.loan-embed__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.loan-embed__logo { display: block; width: 40px; height: 40px; object-fit: contain; flex: none; }
.loan-embed__heading { min-width: 0; }
.loan-embed__kicker {
  margin: 0;
  font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: #b85400;
}
.loan-embed__title {
  margin: 2px 0 0;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.loan-embed__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.loan-embed__newtab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid rgba(14, 14, 14, .16); background: #fff;
  color: var(--le-ink); font-size: .86rem; font-weight: 600; text-decoration: none;
  transition: border-color .2s, background-color .2s;
}
.loan-embed__newtab:hover { border-color: var(--le-ink); background: #fffaf0; }
.loan-embed__close {
  display: grid; place-items: center;
  width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  background: var(--le-ink); color: #fff; cursor: pointer;
  transition: transform .2s, background-color .2s;
}
.loan-embed__close:hover { background: #2a2620; transform: rotate(90deg); }
.loan-embed__close svg { width: 20px; height: 20px; }
.loan-embed :focus-visible { outline: 3px solid rgba(255, 128, 0, .7); outline-offset: 2px; }

/* Cuerpo: iframe + aviso de carga */
.loan-embed__body { position: relative; flex: 1 1 auto; min-height: 0; background: #fff; }
.loan-embed__frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.loan-embed__loading {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 24px; text-align: center;
  background: #fff; color: var(--le-text); font-size: .95rem;
  transition: opacity .3s ease, visibility .3s;
}
.loan-embed__loading p { margin: 0; max-width: 34ch; }
.loan-embed__spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(255, 178, 0, .28); border-top-color: #ff8000;
  animation: le-spin .8s linear infinite;
}
.loan-embed__slow { display: none; font-size: .88rem; color: var(--le-muted); }
.loan-embed.is-slow .loan-embed__slow { display: block; }
.loan-embed.is-loaded .loan-embed__loading { opacity: 0; visibility: hidden; }
@keyframes le-spin { to { transform: rotate(360deg); } }

/* Mientras la ventana está abierta, la página de fondo no se desplaza */
html.loan-embed-lock { overflow: hidden; scrollbar-gutter: stable; }

@media (prefers-reduced-motion: no-preference) {
  .loan-embed[open] { animation: le-in .38s cubic-bezier(.16, 1, .3, 1); }
  .loan-embed[open]::backdrop { animation: le-fade .3s ease; }
}
@keyframes le-in { from { opacity: 0; transform: translateY(16px) scale(.985); } }
@keyframes le-fade { from { opacity: 0; } }

/* Celular (también acostado) o ventana muy baja: ocupa toda la pantalla */
@media (max-width: 640px), (max-height: 560px) {
  .loan-embed {
    width: 100vw; height: 100vh; height: 100dvh;
    border-radius: 0;
  }
  .loan-embed__bar { padding: 10px 10px 10px 14px; gap: 10px; }
  .loan-embed__logo { width: 34px; height: 34px; }
  .loan-embed__title { font-size: .98rem; }
  .loan-embed__newtab { width: 42px; padding: 0; justify-content: center; }
  .loan-embed__newtab span { display: none; }
}
