/* Portal ESRI — BuenTrato.AI
   Identidad visual: Inter font, paleta BuenTrato + firma ESRI en header */

:root {
  /* Logo BuenTrato.ai usa solo dos colores oficiales: #0380A6 (azul) + #777579 (gris) */
  --color-primary: #0380A6;
  --color-primary-dark: #026B8A;
  --color-primary-deeper: #01516A;
  --color-accent: #04B5D6;
  --color-accent-light: #6DCFE0;
  --color-logo-gray: #777579;
  /* Fondo gris claro fijo en todo el portal — más claro que el #777579 del logo
     para que el azul #0380A6 resalte. Misma tonalidad en todas las páginas. */
  --color-bg: #ECEBEB;
  --color-surface: #FFFFFF;
  --color-border: #DDD9D9;
  --color-text: #1A1A1A;
  --color-text-muted: #5A6776;
  --color-success: #2E7D32;
  --color-warning: #E65100;
  --color-error: #C62828;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--color-text);
  /* Fondo blanco con waves azul claro (validado 2026-04-30); el gris #ECEBEB
     queda solo para elementos secundarios (separadores, hover, progress bar). */
  background: #FFFFFF;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-header .brand img.brand-logo {
  /* Mínimo 64px en headers (regla de identidad institucional) */
  max-height: 64px;
  width: auto;
  object-fit: contain;
}

/* El logo ESRI tiene un globo visualmente más pesado que la carita BuenTrato;
   se baja proporcionalmente para que ambos se sientan al mismo peso visual */
.app-header .brand img.brand-logo[alt="ESRI"] {
  max-height: 48px;
}

/* Separador vertical entre logo BuenTrato.ai y logo ESRI (co-branding) */
.app-header .brand-divider {
  width: 1px;
  height: 42px;
  background: rgba(0,0,0,0.18);
  flex-shrink: 0;
}

/* Compat: el viejo selector .brand img (sin clase) sigue funcionando */
.app-header .brand img:not(.brand-logo) {
  max-height: 48px;
  width: auto;
  object-fit: contain;
}

.app-header .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.app-header .brand-text .title {
  font-weight: 600;
  color: var(--color-text);
  font-size: 15px;
}

.app-header .brand-text .subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
}

.app-main {
  flex: 1;
  padding: 40px 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* === Auth screen === */
.auth-wrap {
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--color-primary-deeper);
}

.auth-card p.lede {
  margin: 0 0 24px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* === Form === */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 120ms, box-shadow 120ms;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(3, 128, 166, 0.12);
}

.form-group input.otp-input {
  font-size: 22px;
  text-align: center;
  letter-spacing: 10px;
  font-weight: 600;
  color: var(--color-primary-deeper);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms, transform 80ms;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { background: #9FC7D6; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(3, 128, 166, 0.08); }

/* === Messages === */
.msg {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
}

.msg-info { background: #E6F4F9; color: var(--color-primary-deeper); }
.msg-error { background: #FDECEA; color: var(--color-error); }
.msg-success { background: #E8F5E9; color: var(--color-success); }

/* === Utilities === */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }

/* === Dashboard placeholder === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* === Layout simple BuenTrato: hero, listas planas, CTA, formas circulares === */
/* La marca BuenTrato es redonda (la carita es circular). Los iconos y avatares
   usan border-radius: 50%. Los rectángulos quedan reservados para tarjetas/contenedores. */

.hero { margin: 16px 0 52px; }
.hero h1 {
  font-size: 38px;
  font-weight: 500;
  color: var(--color-text);
  margin: 0 0 8px;
  line-height: 1.05;
  letter-spacing: -0.5px;
}
.hero .subtitle {
  font-size: 17px;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
}

.section { margin-bottom: 44px; }
.section-label {
  font-size: 12px;
  font-weight: 500;
  color: #8A95A2;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0 0 14px;
  padding-left: 4px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 14px;
  padding: 0 4px;
}
.section-header .section-link {
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
}

.row-list {
  background: var(--color-surface);
  border-radius: 22px;
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.row-list .row {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  transition: background 120ms;
}
.row-list .row:hover { background: var(--color-bg); }
.row-list .row + .row { border-top: 1px solid var(--color-border); }
.row-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.row-icon svg { width: 22px; height: 22px; }
.row-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--color-primary-light, #E2EEF3);
  color: var(--color-primary-deeper);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500;
  flex-shrink: 0;
}
.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 16px;
  color: var(--color-text);
  margin-bottom: 3px;
  line-height: 1.3;
}
.row-meta {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.row-aside { text-align: right; flex-shrink: 0; }
.row-aside-primary {
  font-size: 14px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.row-aside-secondary {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.row-aside-link {
  font-size: 13px;
  color: var(--color-primary);
  font-weight: 500;
}

.cta-wrap {
  display: flex;
  justify-content: center;
  margin: 48px 0 12px;
}
.btn-cta {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 16px 36px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.1px;
  transition: background 120ms, transform 80ms;
}
.btn-cta:hover { background: var(--color-primary-dark); }
.btn-cta:active { transform: translateY(1px); }

/* Header limpio con logo grande + avatar */
.app-header.app-header-clean {
  background: transparent;
  border-bottom: none;
  padding: 24px 32px;
}
.app-header.app-header-clean .brand img {
  max-height: 64px;
  width: auto;
  object-fit: contain;
}
.user-menu {
  position: relative;
  z-index: 50;
}
.user-menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary .user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500;
}
.user-menu summary .user-name {
  font-size: 14px;
  color: var(--color-text-muted);
}
.user-menu .user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
  z-index: 250;
}
.user-menu .user-menu-panel a, .user-menu .user-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.user-menu .user-menu-panel a:hover, .user-menu .user-menu-panel button:hover {
  background: var(--color-bg);
}

/* === Empty state unificado === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 28px 20px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.empty-state img { max-height: 36px; width: auto; opacity: 0.85; }
.empty-state .es-title { font-size: 14px; color: var(--color-text); font-weight: 500; }
.empty-state .es-desc { font-size: 13px; color: var(--color-text-muted); max-width: 360px; line-height: 1.5; }
.empty-state.es-success { border-style: solid; border-color: #C8E6C9; background: #F1F8E9; color: var(--color-success); }
.empty-state.es-success .es-title { color: var(--color-success); }

/* === Loading con carita === */
@keyframes carita-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.06); opacity: 1; }
}
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}
.page-loading img {
  max-height: 48px;
  width: auto;
  animation: carita-pulse 1.4s ease-in-out infinite;
}

/* === Skeleton loaders === */
@keyframes skeleton-pulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #EDF1F5 0%, #F5F7FA 50%, #EDF1F5 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  display: inline-block;
}
.skeleton-line { height: 14px; width: 100%; }
.skeleton-line.lg { height: 22px; }
.skeleton-line.sm { height: 11px; }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* === Waves decorativas globales (top + bottom) ===
   Se posicionan absolutas dentro del .app-shell con z-index 0, el contenido
   debe quedar por encima con z-index 2 (header/main/tabs-bar). */
.page-wave-top, .page-wave-bottom {
  position: absolute; left: 0; right: 0; pointer-events: none; z-index: 0;
}
.page-wave-top { top: 0; }
.page-wave-bottom { bottom: 0; }
.app-shell { position: relative; z-index: 1; }
/* El header tiene z-index alto para que el dropdown del avatar quede encima de las tabs y del main */
.app-shell > header { position: relative; z-index: 50; }
.app-shell > .tabs-bar,
.app-shell > main { position: relative; z-index: 2; }

/* === Hero block azul corporativo (saludo / título de página)
   Bloque con fondo primary, círculo blanco recortado en la esquina inferior derecha
   y wave blanca al pie. Se usa en dashboard, proceso, informe, etc. */
.hero-block {
  position: relative;
  background: var(--color-primary);
  border-radius: 26px;
  padding: 38px 36px 42px;
  margin: 16px 0 32px;
  overflow: hidden;
  color: #fff;
}
.hero-block .hero-deco-circle,
.hero-block .hero-deco-wave { position: absolute; pointer-events: none; }
.hero-block .hero-deco-circle { right: -60px; bottom: -60px; opacity: 0.18; }
.hero-block .hero-deco-wave { left: 0; right: 0; bottom: 0; opacity: 0.22; }
.hero-block h1 {
  position: relative;
  margin: 0 0 12px;
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
  color: #fff;
  letter-spacing: -0.8px;
}
.hero-block h1 .name-bold { font-weight: 500; }
.hero-block h1 .smile { opacity: 0.92; margin-left: 4px; }
.hero-block .subtitle {
  position: relative;
  margin: 0;
  font-size: 16px;
  color: #fff;
  opacity: 0.88;
  line-height: 1.5;
}
.hero-block .meta-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  font-size: 13px;
  color: #fff;
  opacity: 0.88;
}
.hero-block .meta-row .meta-pill {
  background: rgba(255,255,255,0.18);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 500;
}

/* === Títulos editoriales de sección (sec-head) === */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  padding-left: 4px;
  flex-wrap: wrap;
}
.sec-head h2 {
  font-size: 19px;
  color: var(--color-primary-deeper);
  font-weight: 500;
  letter-spacing: -0.3px;
  margin: 0;
}
.sec-head .count { font-size: 13px; color: var(--color-text-muted); }
.sec-head .sec-action { margin-left: auto; }

/* === Grid responsive de cards (cartera, casos, objetivos, sesiones)
   3 cols en desktop, 2 en tablet, 1 en celular vía auto-fill */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.grid-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid #E0DCDC;
  border-radius: 22px;
  padding: 18px 20px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease;
  display: flex;
  flex-direction: column;
}
.grid-card[href]:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.05); }
.grid-card .gc-wave {
  position: absolute; bottom: 0; left: 0; right: 0; opacity: 0.5; pointer-events: none;
}
.grid-card > * { position: relative; }
.grid-card .gc-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.grid-card .gc-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; flex-shrink: 0;
}
.grid-card .gc-avatar.av-info { background: #E6F4F9; color: #01516A; }
.grid-card .gc-avatar.av-gray { background: #F0EEEE; color: #444441; }
.grid-card .gc-avatar.av-warning { background: #FFF4E5; color: #B25600; }
.grid-card .gc-name {
  font-size: 15px; font-weight: 500; color: var(--color-text);
  letter-spacing: -0.2px; line-height: 1.25; min-width: 0;
}
.grid-card .gc-codigo {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px; color: var(--color-text-muted); margin-top: 2px;
}
.grid-card .gc-meta {
  font-size: 12.5px; color: var(--color-text-muted);
  line-height: 1.5; margin-bottom: 14px; flex: 1;
}
.grid-card .gc-foot {
  display: flex; align-items: center; gap: 10px;
  padding-top: 4px;
}
.grid-card .gc-bar {
  flex: 1; height: 4px; background: #ECEBEB;
  border-radius: 999px; overflow: hidden;
}
.grid-card .gc-bar > span { display: block; height: 100%; background: var(--color-primary); }
.grid-card .gc-frac {
  font-size: 11.5px; color: var(--color-text-muted);
  flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.grid-card .gc-pill {
  display: inline-block;
  background: #FFF4E5; color: var(--color-warning);
  padding: 3px 10px; border-radius: 999px;
  font-weight: 500; font-size: 11px;
}
.grid-card .gc-key {
  font-size: 10px; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin: 8px 0 2px; font-weight: 500;
}
.grid-card .gc-block {
  font-size: 13px; color: var(--color-text);
  line-height: 1.5; margin-bottom: 8px;
}

/* === FAB de chat IA (botón flotante visible en todas las páginas autenticadas) === */
.fab-chat {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.14);
  transition: transform 180ms ease, box-shadow 180ms ease;
  z-index: 200;
}
.fab-chat:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 10px 26px rgba(3,128,166,0.22);
}
.fab-chat img { width: 44px; height: 44px; object-fit: contain; }
.fab-chat .fab-tip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  background: #1a1a1a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.fab-chat:hover .fab-tip { opacity: 1; transform: translateY(-50%) translateX(0); }

/* === Mobile === */
@media (max-width: 600px) {
  .app-header { padding: 14px 16px; }
  .app-main { padding: 24px 16px; }
  .auth-card { padding: 28px 22px; }
  .fab-chat { bottom: 18px; right: 18px; width: 56px; height: 56px; }
  .fab-chat img { width: 38px; height: 38px; }
}
