/* =============================================================================
   FactuPOS · Login (acceso) — hoja NAVY reescrita DESDE 0 (Fase 1 migración)
   Reemplaza css/login.css legacy (1716 líneas / 262 !important) por una hoja
   tokenizada, sin overrides ni !important. Mismo contrato de clases/IDs que
   consume login.js → drop-in demostrable.
   Look: navy ecommerce #0a2540 + azul acento #0176d3, cards blancas.
   ========================================================================== */

:root {
  --navy:        #0a2540;   /* fondo / headers / hover del primario */
  --navy-soft:   #143d66;   /* navy medio (gradiente header) */
  --accent:      #0176d3;   /* azul acción principal */
  --accent-dark: #0162b3;   /* hover azul */
  --glow:        rgba(1, 118, 211, 0.18);

  --surface:     #ffffff;
  --surface-alt: #f1f5f9;   /* slate-100 */
  --line:        #d8e2ee;   /* borde card / separadores */
  --line-input:  #cbd9ea;   /* borde inputs */

  --text:        #0f172a;   /* slate-900 */
  --text-soft:   #475569;   /* slate-600 */
  --text-mute:   #64748b;   /* slate-500 */
  --text-light:  #94a3b8;   /* slate-400 */

  --success:     #15803d;
  --danger:      #dc2626;
  --warning:     #b45309;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --shadow: 0 10px 30px rgba(8, 20, 40, 0.18);
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Noto Sans', sans-serif;
  background: linear-gradient(170deg, var(--navy) 0%, var(--accent) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* Sidebar / steps legacy — no se usan en el diseño de 2 tarjetas */
.sidebar, .steps { display: none; }

/* ------------------------------------------------------------------ Layout */
.wizard { display: flex; min-height: 100dvh; }

.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.cards-container {
  display: flex;
  justify-content: center;       /* centrar la única tarjeta visible */
  align-items: stretch;
  gap: 1.25rem;
  width: 100%;
  max-width: 420px;              /* una sola tarjeta (ya no hay accesos rápidos al lado) */
}

.card-uno, .card-dos {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}
.card-uno, .card-dos { flex: 0 0 360px; }

/* -------------------------------------------------------------- Logo (compacto) */
.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;                /* logo limpio, sin caja ni borde */
  margin-bottom: 1rem;
}
.logo-ia { max-width: 180px; height: auto; }
.logo-ia.small { max-width: 120px; }

/* ------------------------------------------- Bienvenido (texto plano, sin banner) */
.content-header { text-align: center; padding: 2px 0 14px; }
.content-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.2px;
}
.content-header p {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* ----------------------------------------------------------------- Formulario */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.input-wrapper { position: relative; }
.input-wrapper > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-size: 1rem;
  pointer-events: none;
}
.input-wrapper input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 38px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line-input);
  border-radius: var(--r-sm);
  transition: border-color .12s, box-shadow .12s;
}
.input-wrapper input::placeholder { color: var(--text-light); }
.input-wrapper input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}
.input-wrapper input:focus ~ i { color: var(--accent); }

/* Correos recientes (chips) */
.emails-recientes { margin-top: 10px; }
.er-label { display: block; font-size: 0.7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.er-list { display: flex; flex-wrap: wrap; gap: 6px; }
.er-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 4px 4px 4px 10px;
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.8rem; color: var(--text); cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.er-chip:hover { border-color: var(--accent); background: #f0f6ff; }
.er-chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.er-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0; padding: 0;
  background: transparent; border: none; border-radius: 50%;
  color: var(--text-light); cursor: pointer; line-height: 1;
}
.er-chip-x:hover { background: #fee2e2; color: var(--danger); }

/* Accesos guardados (empresa+usuario, sin clave) */
.accesos-guardados { margin-bottom: 16px; }
.ag-label { display: block; font-size: 0.7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.ag-list { display: flex; flex-direction: column; gap: 6px; }
.ag-chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 8px 8px 10px;
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: 10px; font-size: 0.85rem; color: var(--text); cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.ag-chip:hover { border-color: var(--accent); background: #f0f6ff; }
.ag-chip-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.8rem;
}
.ag-chip-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ag-chip-nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-chip-empresa { font-size: 0.72rem; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0; padding: 0;
  background: transparent; border: none; border-radius: 50%;
  color: var(--text-light); cursor: pointer; line-height: 1;
}
.ag-chip-x:hover { background: #fee2e2; color: var(--danger); }

/* --------------------------------------------------------------------- Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  padding: 0 16px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy); border-color: var(--navy); }
.btn-primary:disabled { background: var(--surface-alt); border-color: var(--line); color: var(--text-light); cursor: not-allowed; }

.btn-outline { background: var(--surface); border-color: var(--line-input); color: var(--navy); }
.btn-outline:hover { background: var(--surface-alt); border-color: var(--accent); color: var(--accent); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn-outline { flex: 0 0 40%; }
.btn-row .btn-primary { flex: 1; }

.btn-home {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  visibility: hidden;
  opacity: 0;
  transition: background-color .12s;
}
.btn-home:hover { background: rgba(255, 255, 255, 0.28); }
.btn-home.visible { visibility: visible; opacity: 1; }

/* ------------------------------------------------ Header de sección (navy sólido) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.section-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}
.section-header .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--navy);
  background: #fff;
  border-radius: 999px;
}

/* ----------------------------------------------------------- Listas + scroll */
.card-dos { overflow: hidden; }
.bottom-section { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.section-header, .search-box { flex-shrink: 0; }

.section-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty-msg { padding: 1.5rem; text-align: center; color: var(--text-light); font-size: 0.85rem; }

/* --------------------------------------------------------------- Buscador */
.search-box { position: relative; margin-bottom: 12px; }
.search-box > i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
}
.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  font: inherit;
  font-size: 0.9rem;
  border: 1.5px solid var(--line-input);
  border-radius: var(--r-sm);
}
.search-box input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

/* --------------------------------------------------- Ítem compacto (empresa/usuario) */
.compact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.compact-item:hover, .compact-item.kb-focus { border-color: var(--accent); background: #f0f6ff; }
.compact-item.selected { border-color: var(--accent); background: #e8f0fe; }
.mini-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: #fff;
  font-size: 1rem;
  border-radius: 50%;
}
.avatar-empresa { background: var(--navy); }     /* empresa = navy */
.avatar-usuario { background: var(--accent); }    /* usuario = azul (los distingue) */
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 0.8rem; color: var(--text-mute); display: flex; align-items: center; gap: 4px; }
.item-arrow { color: var(--text-light); flex-shrink: 0; }

/* ------------------------------------------------- Paso 4: usuario + contraseña */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.user-info .avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  font-weight: 700;
}
.user-info .details h4 { font-size: 0.95rem; font-weight: 600; }
.user-info .details p { font-size: 0.78rem; opacity: 0.85; }

.alert {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.alert.show { display: flex; }
.alert-warning { background: #fef3c7; color: var(--warning); }
.alert-error { background: #fee2e2; color: #991b1b; }

.password-field { letter-spacing: 0.15em; }

/* ---------------------------------------------------------- Ficha de ayuda */
.ayuda-sin-correo {
  display: none;
  max-width: 880px;
  margin: 1rem auto 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  color: var(--text-soft);
}
.ayuda-sin-correo.show { display: block; }
.ayuda-sin-correo-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.ayuda-sin-correo-texto, .ayuda-sin-correo-nota { margin-bottom: 8px; line-height: 1.4; }
.ayuda-sin-correo-nota { display: flex; gap: 8px; padding: 8px 10px; background: var(--surface-alt); border-radius: var(--r-sm); }
.ayuda-sin-correo-nota--info { background: #eff6ff; }

/* ------------------------------------------------------------------- Modales */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 20, 40, 0.55);
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 1.25rem auto 0.5rem;
  font-size: 1.5rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--navy));
  border-radius: 50%;
}
.modal-title { text-align: center; font-size: 1.1rem; font-weight: 700; color: var(--navy); padding: 0 1.5rem; }
.modal-message { text-align: center; font-size: 0.9rem; color: var(--text-soft); padding: 0.5rem 1.5rem 1rem; }
.modal-session-info { margin: 0 1.5rem 1rem; padding: 10px 12px; background: var(--surface-alt); border-radius: var(--r-sm); }
.info-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 0.85rem; }
.info-label { color: var(--text-mute); }
.info-value { color: var(--text); font-weight: 600; text-align: right; }
.modal-buttons { display: flex; gap: 10px; padding: 0 1.5rem 1.5rem; }

/* ---------------------------------------------------------------- Toast */
.toast-notification {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  padding: 12px 18px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

/* -------------------------------------------------------------- Responsive */
@media (max-width: 760px) {
  .cards-container { flex-direction: column; max-width: 400px; }
  .card-uno, .card-dos { flex: 1 1 auto; }
}
