/* Design tokens — paleta oficial de la app SME (bkly-sme/src/app/globals.css):
   cream + naranja #ff4715. Primary text en Fraunces serif, body en Sora sans. */
:root {
  --bkly-bg: #fff1e1;
  --bkly-surface: #fff9f2;
  --bkly-border: rgba(35, 22, 13, 0.10);
  --bkly-text: #23160d;
  --bkly-text-muted: #5e4b3e;
  --bkly-text-faint: #9a8879;
  --bkly-primary: #ff4715;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Sora', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--bkly-text);
}

/* Flex column: banner → iframe-stage. El stack del stage es un sub-layout
   absoluto donde el iframe y el loader se superponen. */
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Banner — branding bar minimal ──────────────────────────────────
   Versión compacta: el logo Heynow vive en el iframe (no duplicar acá).
   Brand text centrado en una sola línea, chip absolute a la derecha así
   no rompe el centrado. Altura ~32px para no comer mucho del viewport.
*/
.hn-banner {
  flex: 0 0 auto;
  position: relative;
  height: 32px;
  background: var(--bkly-surface);
  border-bottom: 1px solid var(--bkly-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hn-banner__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--bkly-text);
  line-height: 1;
}

.hn-banner__title {
  font-family: 'Fraunces', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bkly-text);
}

.hn-banner__sep {
  color: var(--bkly-text-faint);
  font-size: 0.7rem;
}

.hn-banner__subtitle {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--bkly-text-faint);
  letter-spacing: 0.04em;
}

.hn-banner__chip {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.66rem;
  font-weight: 500;
  color: #e03a0c;
  background: #fff0ec;
  border: 1px solid rgba(255, 71, 21, 0.18);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.hn-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

.hn-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

/* body.hn-ready → fade in iframe, hide loader.
   body.hn-error → loader queda visible con mensaje de error y el iframe
   sigue en opacity:0. El loader cubre el iframe (z-index + tamaño completo)
   y NO tiene pointer-events:none, así que cualquier intento de clickear cae
   en el loader. Esto bloquea login manual cuando el flow automático falla
   — sin esto, un cliente podría meterse con sus propias credenciales. */
body.hn-ready .hn-frame {
  opacity: 1;
}

body.hn-ready .hn-loader {
  opacity: 0;
  pointer-events: none;
  /* delay el display:none hasta que termine la transición, sino corta el fade */
  transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
  visibility: hidden;
}

body.hn-error .hn-loader {
  background: #fef2f2;
  color: #dc2626;
}
body.hn-error .hn-loader__spinner {
  display: none;
}
body.hn-error .hn-loader__status {
  color: #dc2626;
  font-weight: 500;
}
body.hn-error .hn-loader__status::before {
  content: "⚠️ ";
}

/* Loader: mismo visual language que el banner. Background con el gradient
   radial de bkly-pocs (cream con tinte naranja arriba), spinner orange,
   tipografía Fraunces para el "branding" arriba si quisiéramos sumar uno,
   pero por ahora solo el status text en Sora. */
.hn-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bkly-bg);
  background-image: radial-gradient(ellipse at 50% 0%, #ffd3c4 0%, var(--bkly-bg) 60%);
  color: var(--bkly-text);
  font-family: 'Sora', ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  z-index: 10;
  transition: opacity 0.3s ease-out;
}

.hn-loader__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bkly-border);
  border-top-color: var(--bkly-primary);
  border-radius: 50%;
  animation: hn-spin 0.9s linear infinite;
  margin-top: 8px; /* extra space después de la marca */
}

.hn-loader__status {
  max-width: 480px;
  text-align: center;
  padding: 0 16px;
  color: var(--bkly-text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

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

@media (prefers-reduced-motion: reduce) {
  .hn-loader__spinner { animation: none; }
  .hn-frame { transition: none; }
}

/* El botón "Tour" ahora vive dentro del iframe, en el sidebar (donde estaba
   "Salir"). Lo inyecta tour.js clonando el elemento de Salir para heredar
   los estilos nativos del sidebar de Material. */
