/* Login ÚNICO del ecosistema SITI — tres pestañas: Negocios, Salud y Vet.
 *
 * Antes había una puerta por portal. Ahora es una sola con pestañas: cada una
 * cambia el color de acento, el icono del fondo y el destino.
 *
 * Dos cosas gobiernan el aspecto, las dos sobre <html>/<body>:
 *   --accent / --accent2   color de la pestaña, lo fija `auth/login.js`
 *   data-theme="light|dark" modo claro u oscuro, lo fija el interruptor
 * Todo lo demás sale de esas variables; no hay colores sueltos en las reglas.
 *
 * NADA cambia de alto al cambiar de pestaña: la frase de la marca, la nota del
 * pie y el renglón de "¿No tienes cuenta?" tienen su espacio reservado, y la
 * animación de cambio es solo un fundido (sin desplazamiento vertical). Ver el
 * bloque "Alturas fijas".
 *
 * Esta hoja la comparte `auth_callback.html`, así que las clases de la tarjeta
 * (.login-container, .form-panel, .form-card, .brand-header, .alert…) no se
 * renombran.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens: modo CLARO (el de por defecto) ──
 * Va en `:root` a propósito: si el JS no corre o localStorage está bloqueado,
 * la página igual sale clara. El oscuro es el que se pide explícitamente. */
:root {
  --accent: #ff7a22;
  --accent2: #fb923c;

  --bg: #f4f6f8;
  --bg-glow: rgba(255, 255, 255, .9);
  --orb-opacity: .20;

  --panel: #ffffff;
  --panel-border: #e5e8ee;
  --panel-shadow: 0 18px 45px -22px rgba(15, 23, 42, .22);

  --text: #0f172a;
  --text-dim: #5b6577;
  --text-faint: #8a93a4;

  --soft: #f1f4f8;
  --soft-hover: #e7ecf3;
  --line: #e5e8ee;

  --field-bg: #f8fafc;
  --field-border: #dfe4ec;
  --field-bg-focus: #ffffff;
  --placeholder: #a8b1c0;

  --tab-idle: #5b6577;
  --tab-hover: #0f172a;
  --tab-on: #ffffff;

  --icon-bg-opacity: .13;
  --oauth-google-border: #dfe4ec;
  --oauth-apple-bg: #16181d;
  --oauth-apple-fg: #fff;
}

/* ── Tokens: modo oscuro ── */
:root[data-theme="dark"] {
  --bg: #0a0d0c;
  --bg-glow: rgba(255, 255, 255, .05);
  --orb-opacity: .36;

  --panel: rgba(255, 255, 255, .04);
  --panel-border: rgba(255, 255, 255, .08);
  --panel-shadow: none;

  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, .45);
  --text-faint: rgba(255, 255, 255, .3);

  --soft: rgba(255, 255, 255, .06);
  --soft-hover: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .1);

  --field-bg: rgba(255, 255, 255, .06);
  --field-border: rgba(255, 255, 255, .08);
  --field-bg-focus: rgba(255, 255, 255, .08);
  --placeholder: rgba(255, 255, 255, .2);

  --tab-idle: rgba(255, 255, 255, .5);
  --tab-hover: rgba(255, 255, 255, .8);
  --tab-on: #ffffff;

  --icon-bg-opacity: .10;
  --oauth-google-border: rgba(255, 255, 255, .12);
  --oauth-apple-bg: #000;
  --oauth-apple-fg: #fff;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}

/* ── Antiparpadeo del arranque ──
 * El HTML de esta página trae el encabezado GENÉRICO ("Portal SITI", naranja,
 * pestaña Negocios): el nombre, el icono, la frase y el color del portal los
 * pone `auth/login.js` hasta el final. Si el navegador pinta antes de que ese
 * archivo corra, se ve un instante un login que no es el tuyo —el de antes de
 * las pestañas— y luego cambia solo.
 *
 * Mientras <html> tenga `siti-hydrating` no se pinta nada de lo que va a
 * cambiar; el fondo plano de `body` sí, para que no se vea un hueco blanco. La
 * clase la pone un script en línea del <head> de login.html y la quita
 * `login.js` ya con la pestaña puesta. Si `login.js` no llegara a cargar, un
 * temporizador del mismo script la quita igual: nunca se queda en blanco.
 *
 * `siti-entering` es el otro parpadeo: si ya había sesión guardada, esta página
 * es solo un paso hacia el portal, y el formulario completo se alcanzaba a ver
 * mientras el servidor contestaba cuál es tu negocio. Ahora en su lugar se
 * muestra "Entrando…". */
:root.siti-hydrating .theme-toggle,
:root.siti-hydrating .bg-scene,
:root.siti-hydrating .bg-icons,
:root.siti-hydrating .login-container { visibility: hidden; }

:root.siti-entering .theme-toggle,
:root.siti-entering .login-container { visibility: hidden; }

/* Neutro a propósito (nada de acento): se muestra ANTES de saber a qué portal
 * entras, que es justo lo que este bloque evita adivinar. */
.entering {
  position: fixed; inset: 0; z-index: 2;
  display: none; align-items: center; justify-content: center; gap: 10px;
  font-size: 14px; font-weight: 600; color: var(--text-dim);
}
:root.siti-entering .entering { display: flex; }
.entering .spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--text-faint);
  animation: enteringSpin .7s linear infinite;
}
@keyframes enteringSpin { to { transform: rotate(360deg); } }

/* ── Fondo: gradiente + dos orbes que toman el color de la pestaña ── */
.bg-scene {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  transition: background .35s ease;
}
.bg-scene .orb {
  position: absolute; border-radius: 50%; filter: blur(80px);
  opacity: var(--orb-opacity);
  animation: orbFloat 14s ease-in-out infinite alternate;
  transition: background .7s ease, opacity .35s ease;
}
.bg-scene .orb-1 { width: 520px; height: 520px; background: var(--accent); top: -12%; left: -10%; }
.bg-scene .orb-2 { width: 430px; height: 430px; background: var(--accent2); bottom: -15%; right: -10%; animation-delay: -4s; }
@keyframes orbFloat { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(60px,-40px) scale(1.15); } }

/* Iconos de la pestaña flotando en el fondo (SVG: toman el color del acento). */
.bg-icons { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-icons span {
  position: absolute; display: block;
  width: 40px; height: 40px;
  color: var(--accent); opacity: var(--icon-bg-opacity);
  animation: iconDrift 9s ease-in-out infinite alternate;
  transition: opacity .3s ease, color .5s ease;
}
.bg-icons span svg { width: 100%; height: 100%; }
.bg-icons.is-swapping span { opacity: 0; }
.bg-icons span:nth-child(1) { top: 14%; left: 11%; rotate: -18deg; }
.bg-icons span:nth-child(2) { top: 30%; right: 13%; width: 64px; height: 64px; animation-delay: -2s; }
.bg-icons span:nth-child(3) { bottom: 17%; left: 19%; width: 52px; height: 52px; animation-delay: -4s; }
.bg-icons span:nth-child(4) { bottom: 27%; right: 21%; rotate: 14deg; animation-delay: -6s; }
@keyframes iconDrift { 0% { translate: 0 0; } 100% { translate: 0 -18px; } }

/* ── Interruptor de modo claro / oscuro (esquina) ── */
.theme-toggle {
  position: fixed; top: 18px; right: 18px; z-index: 3;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--panel-border); border-radius: 12px;
  background: var(--panel); color: var(--text-dim);
  cursor: pointer; transition: color .2s, background .2s, border-color .2s, transform .15s;
  backdrop-filter: blur(20px);
}
.theme-toggle:hover { color: var(--text); background: var(--soft-hover); transform: translateY(-1px); }
.theme-toggle svg { width: 19px; height: 19px; }
/* Solo se ve el icono del modo al que vas a cambiar: en claro la luna, en
   oscuro el sol. */
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }

.login-container {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 100vh; padding: 32px 24px;
}

/* ── Marca ── */
.brand-header { text-align: center; margin-bottom: 22px; }
/* Icono de marca: hereda el acento de la pestaña. */
.brand-header .brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; margin: 0 auto;
  color: var(--accent); transition: color .35s ease;
}
.brand-header .brand-icon svg { width: 100%; height: 100%; }
.brand-header h1 { font-weight: 800; font-size: clamp(24px, 4vw, 34px); line-height: 1.15; letter-spacing: -.03em; margin: 10px 0 8px; }
.brand-header h1 .accent { color: var(--accent); transition: color .35s ease; }
.brand-header .tagline { font-size: 14px; color: var(--text-dim); max-width: 400px; margin: 0 auto; line-height: 1.5; }

/* ── Pestañas de portal ── */
.portal-tabs {
  position: relative; z-index: 1;
  display: flex; gap: 4px; padding: 5px;
  background: var(--soft);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  margin-bottom: 18px;
  width: 100%; max-width: 420px;
  transition: background .35s ease, border-color .35s ease;
}
.portal-tab {
  flex: 1; position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 8px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--tab-idle); border-radius: 12px;
  transition: color .25s ease;
  white-space: nowrap;
}
.portal-tab .tab-ic { display: inline-flex; width: 17px; height: 17px; flex-shrink: 0; }
.portal-tab .tab-ic svg { width: 100%; height: 100%; }
.portal-tab:hover { color: var(--tab-hover); }
.portal-tab.is-active { color: var(--tab-on); }
/* Pastilla que se desliza detrás de la pestaña activa. */
.portal-tabs::after {
  content: ''; position: absolute; z-index: 0;
  top: 5px; bottom: 5px; left: 5px;
  width: calc((100% - 10px) / 3 - 2.67px);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 18px -6px var(--accent);
  transform: translateX(calc(var(--tab-index, 0) * (100% + 4px)));
  transition: transform .38s cubic-bezier(.5,.05,.2,1), background .45s ease, box-shadow .45s ease;
}

/* ── Tarjeta ── */
.form-panel { width: 100%; max-width: 420px; }
.form-card {
  background: var(--panel); backdrop-filter: blur(40px);
  border: 1px solid var(--panel-border); border-radius: 24px; padding: 32px;
  box-shadow: var(--panel-shadow);
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.form-card h2 { font-weight: 800; font-size: 22px; margin-bottom: 4px; }
.form-card .sub { font-size: 14px; color: var(--text-dim); margin-bottom: 24px; }

/* ── Alturas fijas ──────────────────────────────────────────────────────
 * Al cambiar de pestaña cambian los textos, y con ellos el número de
 * renglones. Sin esto la tarjeta crecía/encogía y el login "saltaba".
 * Se reserva el alto de DOS renglones para la frase de la marca y la nota, y
 * el renglón de "¿No tienes cuenta?" se oculta con visibility (sigue
 * ocupando su lugar) en vez de display:none. */
.brand-header .tagline { min-height: calc(1.5em * 2); }
.muted-note { min-height: calc(1.6em * 2); }
.toggle-row.is-reserved { visibility: hidden; }

/* Cambio de pestaña: la TARJETA no se anima. Antes se le hacía un fundido de
 * opacidad 0→1 y, como es el bloque más grande de la pantalla, se veía como un
 * parpadeo. Lo que cambia son unas cuantas palabras: el acento, la pastilla y
 * el icono ya dan el aviso visual de sobra. */
.brand-header .brand-icon.is-swapping { animation: iconPop .34s cubic-bezier(.2,.8,.3,1); }
@keyframes iconPop {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-header .brand-icon.is-swapping { animation: none; }
  .bg-scene .orb, .bg-icons span { animation: none; }
  .portal-tabs::after { transition: background .2s ease; }
}

/* OAuth */
.btn-oauth { width: 100%; padding: 14px; border-radius: 14px; font-weight: 700; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: all .2s; }
.btn-oauth + .btn-oauth { margin-top: 10px; }
.btn-oauth:hover { transform: translateY(-1px); box-shadow: 0 8px 25px rgba(0,0,0,.18); }
.btn-oauth img { width: 18px; height: 18px; }
.btn-google { border: 1.5px solid var(--oauth-google-border); background: #fff; color: #1f2937; }
.btn-apple { border: 1.5px solid var(--oauth-apple-bg); background: var(--oauth-apple-bg); color: var(--oauth-apple-fg); }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-faint); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Campos */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 14px 16px; background: var(--field-bg);
  border: 1.5px solid var(--field-border); border-radius: 12px;
  color: var(--text); font-family: inherit; font-size: 15px; outline: none; transition: all .25s;
}
.field input::placeholder { color: var(--placeholder); }
.field input:focus {
  border-color: var(--accent); background: var(--field-bg-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.submit-btn {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: all .25s; margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 25px -6px var(--accent); }
.submit-btn:active { transform: scale(.98); }
.submit-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.toggle-row { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-dim); }
.toggle-row a { color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: none; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 18px; display: none; line-height: 1.45; }
.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #d64545; }
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #1f9d55; }
:root[data-theme="dark"] .alert-error { color: #fca5a5; }
:root[data-theme="dark"] .alert-success { color: #86efac; }
.alert a { color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }

.email-toggle { width: 100%; padding: 13px; border: none; border-radius: 12px; background: var(--soft); color: var(--text-dim); font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .2s, color .2s; }
.email-toggle:hover { background: var(--soft-hover); color: var(--text); }
.hidden { display: none; }

/* ── Pantalla de "Entrando…" (auth_callback.html) ──
 * Comparte la tarjeta del login, pero con la marca del portal al que entras
 * en vez del logo genérico de SITI. */
.cb-card { text-align: center; }
.cb-brand { margin-bottom: 14px; }
.cb-brand h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 0; }
.cb-brand .brand-icon { width: 46px; height: 46px; }
.cb-card #cb-title { font-size: 19px; margin-top: 14px; }
.cb-card .sub { margin-bottom: 0; }
.cb-card .alert { margin-top: 16px; margin-bottom: 0; text-align: left; }
.cb-card .submit-btn { margin-top: 18px; }

.muted-note { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 22px; line-height: 1.6; }
.muted-note a { color: var(--text-dim); font-weight: 700; text-decoration: none; }
.muted-note a:hover { text-decoration: underline; }

/* ── Términos y privacidad ──
 * Debajo de la tarjeta, igual en las tres pestañas. */
.legal-note {
  width: 100%; max-width: 420px;
  text-align: center; font-size: 12px; line-height: 1.6;
  color: var(--text-faint); margin: 18px auto 0;
}
.legal-note a { color: var(--text-dim); font-weight: 700; text-decoration: none; }
.legal-note a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 400px) {
  .portal-tab { font-size: 12px; padding: 10px 4px; gap: 5px; }
  .portal-tab .tab-ic { width: 15px; height: 15px; }
  /* En pantallas chicas los textos toman tres renglones. */
  .brand-header .tagline { min-height: calc(1.5em * 3); }
}
