/* =====================================================================
   TITLEFLOW - SISTEMA DE DISEÑO BASE
   Paleta Hummingbird + principios de minimalismo "Apple":
   espacio generoso, bordes redondeados, sombras suaves y difusas,
   y un panel lateral con efecto vidrio (glassmorphism).
   ===================================================================== */

:root {
  /* --- Paleta Hummingbird (ajustada a la paleta usada en Softr) --- */
  --color-teal:    #447293;
  --color-lav:     #8E8BBE;
  --color-navy:    #1A1A2E;
  --color-sage:    #B6CB93;
  --color-cream:   #FAFAF8;

  /* Versiones suaves (para fondos de badges, fills, etc.) */
  --color-teal-soft:  rgba(68, 114, 147, .14);
  --color-lav-soft:   rgba(142, 139, 190, .16);
  --color-sage-soft:  rgba(182, 203, 147, .20);
  --color-danger:     #D98E8E;
  --color-danger-soft: rgba(217, 142, 142, .16);
  --color-warning:    #E0B97D;
  --color-warning-soft: rgba(224, 185, 125, .18);

  /* --- Texto y superficies --- */
  --text-primary:   var(--color-navy);
  --text-muted:     #9a978f;
  --surface:        #ffffff;
  --surface-alt:    var(--color-cream);
  --border-soft:    #ECE8DF;

  /* --- Escala de espaciado --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* --- Bordes y sombras (mandamientos del minimalismo) --- */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 4px 24px rgba(26, 26, 46, .04);
  --shadow-card: 0 6px 28px rgba(26, 26, 46, .06);

  /* --- Tipografía --- */
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html, body {
  font-family: var(--font-base);
  color: var(--text-primary);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================================
   LAYOUT: barra lateral (glassmorphism) + contenido
   ===================================================================== */

.tf-shell {
  display: flex;
  min-height: 100vh;
}

.tf-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-soft);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tf-brand {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-navy);
  margin-bottom: var(--space-5);
  padding: 0 var(--space-2);
  letter-spacing: -.01em;
}
.tf-brand span { color: var(--color-teal); }

.tf-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.tf-nav a:hover { background: var(--color-teal-soft); }
.tf-nav a.active {
  background: var(--color-teal);
  color: #fff;
  font-weight: 600;
}

.tf-sidebar-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-2);
  font-size: .76rem;
  color: var(--text-muted);
}
.tf-sidebar-footer a { color: var(--text-muted); }

.tf-main {
  flex: 1;
  padding: var(--space-6) var(--space-7);
  max-width: 1100px;
}

.tf-page-header {
  margin-bottom: var(--space-6);
}
.tf-page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.01em;
}
.tf-page-header p {
  color: var(--text-muted);
  font-size: .92rem;
  margin-top: var(--space-1);
}

/* =====================================================================
   COMPONENTES
   ===================================================================== */

.tf-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}

.tf-card + .tf-card { margin-top: var(--space-4); }

/* --- Botones --- */
.tf-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-base);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, opacity .15s ease;
}
.tf-btn:hover { opacity: .9; text-decoration: none; }
.tf-btn:active { transform: scale(.98); }

.tf-btn-primary { background: var(--color-teal); color: #fff; }
.tf-btn-secondary { background: var(--color-cream); color: var(--text-primary); }
.tf-btn-danger { background: var(--color-danger-soft); color: #9c4a4a; }
.tf-btn-ghost { background: transparent; color: var(--color-teal); padding: var(--space-2) var(--space-2); }

/* --- Formularios --- */
.tf-field { margin-bottom: var(--space-4); }
.tf-field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tf-field input,
.tf-field select,
.tf-field textarea {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-alt);
  font-family: var(--font-base);
  font-size: .92rem;
  color: var(--text-primary);
}
.tf-field input:focus,
.tf-field select:focus,
.tf-field textarea:focus {
  outline: none;
  border-color: var(--color-teal);
  background: #fff;
}
.tf-field textarea { resize: vertical; min-height: 80px; }

.tf-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* --- Tablas --- */
.tf-table { width: 100%; border-collapse: collapse; }
.tf-table th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-soft);
}
.tf-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  font-size: .9rem;
}
.tf-table tr:last-child td { border-bottom: none; }
.tf-table tr:hover td { background: var(--color-teal-soft); }

/* --- Badges de estado --- */
.tf-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
}
.tf-badge-teal    { background: var(--color-teal-soft);    color: #4f7a82; }
.tf-badge-lav     { background: var(--color-lav-soft);     color: #5d5a92; }
.tf-badge-sage    { background: var(--color-sage-soft);    color: #5e7a3f; }
.tf-badge-warning { background: var(--color-warning-soft); color: #93701f; }
.tf-badge-danger  { background: var(--color-danger-soft);  color: #9c4a4a; }
.tf-badge-muted   { background: var(--border-soft);        color: var(--text-muted); }

/* --- Alertas --- */
.tf-alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: var(--space-4);
}
.tf-alert-error   { background: var(--color-danger-soft); color: #9c4a4a; }
.tf-alert-success { background: var(--color-sage-soft);   color: #5e7a3f; }

/* =====================================================================
   LOGIN / AUTH — split-screen con mascotas
   ===================================================================== */
.tf-auth-shell {
  min-height: 100vh;
  display: flex;
}

/* --- Panel izquierdo: ilustración --- */
.tf-auth-illustration {
  flex: 1.15;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-7) var(--space-5);
  background: linear-gradient(160deg, var(--color-cream) 0%, var(--color-lav-soft) 100%);
}
.tf-mascots {
  width: 100%;
  max-width: 580px;
  height: auto;
  display: block;
  overflow: visible;
}

/* --- Panel derecho: formulario --- */
.tf-auth-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--surface);
}
.tf-auth-card { width: 100%; max-width: 380px; }
.tf-auth-card .tf-brand { font-size: 1.3rem; margin-bottom: var(--space-5); }
.tf-auth-card h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.01em;
  margin-bottom: var(--space-1);
}
.tf-auth-subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: var(--space-5);
}
.tf-auth-foot {
  margin-top: var(--space-5);
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
}

/* --- Fila "Recordarme" --- */
.tf-auth-row {
  display: flex;
  align-items: center;
  margin: calc(var(--space-3) * -1) 0 var(--space-4);
  font-size: .85rem;
}
.tf-auth-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-transform: none;
  font-weight: 500;
  cursor: pointer;
}
.tf-auth-row label input { width: auto; cursor: pointer; }

/* --- Campo de contraseña con botón mostrar/ocultar --- */
.tf-pwd-field { position: relative; }
.tf-pwd-toggle {
  position: absolute;
  top: 38px;
  right: 6px;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 6px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tf-pwd-toggle:hover { color: var(--color-teal); }
.tf-pwd-toggle .tf-pwd-icon-hide { display: none; }
.tf-pwd-toggle.is-visible .tf-pwd-icon-show { display: none; }
.tf-pwd-toggle.is-visible .tf-pwd-icon-hide { display: block; }

/* --- Mascotas: vida, movimiento y reacciones ---
   Estructura: .tf-mascot > .tf-mascot-float > (body + .tf-face)
   - .tf-mascot:       JS pone --shift-x (siguen al mouse de un lado a otro)
                       y dispara .is-shaking si la contraseña fue incorrecta.
   - .tf-mascot-float: animación idle infinita (respiración/flote).
   - .tf-face:         ojos + boca; se encoge y desaparece al escribir
                       la contraseña (efecto "se dan vuelta").
*/

.tf-mascot {
  transform: translateX(var(--shift-x, 0px));
  transition: transform .35s cubic-bezier(.22,1,.36,1);
  transform-box: fill-box;
  transform-origin: center bottom;
}
.tf-mascot.is-shaking {
  animation: tf-shake-no .6s ease-in-out;
  animation-delay: var(--shake-delay, 0ms);
}
@keyframes tf-shake-no {
  0%, 100% { transform: translateX(var(--shift-x,0px)) rotate(0deg); }
  20%      { transform: translateX(var(--shift-x,0px)) rotate(-7deg); }
  40%      { transform: translateX(var(--shift-x,0px)) rotate(6deg); }
  60%      { transform: translateX(var(--shift-x,0px)) rotate(-5deg); }
  80%      { transform: translateX(var(--shift-x,0px)) rotate(4deg); }
}

.tf-mascot-float {
  animation: tf-bob var(--bob-duration, 3.6s) ease-in-out infinite;
  animation-delay: var(--bob-delay, 0s);
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes tf-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

.tf-eye-pupil { transition: transform .12s ease-out; }

/* Al escribir la contraseña: la cara se encoge y desaparece (se dan vuelta) */
.tf-face {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .3s ease, opacity .3s ease;
}
.tf-mascots.is-typing-password .tf-face {
  transform: scaleX(.05);
  opacity: 0;
}

/* Contraseña incorrecta: boca cambia a "pensando" (mirada hacia arriba la mueve JS) */
.tf-mouth-think { opacity: 0; transition: opacity .2s ease; }
.tf-mouth-idle  { opacity: 1; transition: opacity .2s ease; }
.tf-mascots.is-thinking .tf-mouth-idle  { opacity: 0; }
.tf-mascots.is-thinking .tf-mouth-think { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .tf-mascot, .tf-mascot-float, .tf-eye-pupil, .tf-face {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 900px) {
  .tf-auth-illustration { display: none; }
  .tf-auth-panel { padding: var(--space-5); min-height: 100vh; }
}

/* =====================================================================
   INICIO: hero + tarjetas de estadísticas
   ===================================================================== */
.tf-hero {
  text-align: center;
  padding: var(--space-5) 0 var(--space-6);
}
.tf-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--color-lav-soft);
  color: var(--color-navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  margin: 0 auto var(--space-3);
}
.tf-hero h1 { font-size: 1.5rem; font-weight: 800; }
.tf-hero p { color: var(--text-muted); margin-top: var(--space-1); font-size: .92rem; }

.tf-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.tf-stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.tf-stat-label { color: var(--text-muted); font-size: .85rem; margin-bottom: var(--space-2); }
.tf-stat-value { font-size: 1.8rem; font-weight: 800; }

/* =====================================================================
   PORTAL DEL CLIENTE
   ===================================================================== */
.tf-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.tf-topnav-right {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: .85rem; color: var(--text-muted);
}
.tf-topnav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-lav-soft); color: var(--color-navy);
  display:flex; align-items:center; justify-content:center;
  font-weight: 800; font-size: .8rem;
}
.tf-portal-main {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

/* --- Tarjeta de operación --- */
.tf-op-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.tf-op-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.tf-op-card-head strong { font-size: 1.02rem; }
.tf-op-card-foot {
  display:flex; justify-content: space-between; align-items:center;
  margin-top: var(--space-4);
}

/* --- Barra de progreso (Stepper) con tooltip --- */
.tf-progress { position: relative; }
.tf-progress-track {
  position: relative;
  height: 8px;
  border-radius: 8px;
  background: var(--color-teal-soft);
  overflow: hidden;
}
.tf-progress-fill {
  position: absolute; left: 0; top: 0; height: 100%;
  border-radius: 8px;
  background: var(--color-teal);
  width: 0%;
  transition: width .6s ease;
}
.tf-progress-tip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  min-width: 220px;
  max-width: 280px;
  background: #fff;
  border-radius: 12px;
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 10;
}
.tf-progress-tip.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.tf-progress-tip::after {
  content: ""; position: absolute; bottom: -5px; left: 14px;
  width: 10px; height: 10px; background: #fff; transform: rotate(45deg);
}
.tf-progress-tip-step {
  font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-lav); font-weight: 700; margin-bottom: 3px;
}
.tf-progress-tip-stage { font-size: .85rem; font-weight: 700; margin-bottom: var(--space-2); }
.tf-progress-tip-next-label {
  font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-teal); font-weight: 700; margin-bottom: 2px;
}
.tf-progress-tip-next-text { font-size: .78rem; line-height: 1.4; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 860px) {
  .tf-shell { flex-direction: column; }
  .tf-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .tf-brand { display: none; }
  .tf-nav { display: flex; gap: var(--space-2); }
  .tf-sidebar-footer { display: none; }
  .tf-main { padding: var(--space-5); }
  .tf-form-row { grid-template-columns: 1fr; }
  .tf-stat-row { grid-template-columns: 1fr; }
}
