/* Xux CRM — estilos sobre Tailwind CDN */

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* En móvil, 100vh incluye la barra del browser y corta el layout.
   100dvh (dynamic viewport height) descuenta esa zona correctamente.
   !important necesario porque Tailwind CDN inyecta h-screen (100vh) después de este archivo. */
body {
  height: 100dvh !important;
}

/* Safe area para iPhone: se aplica en los elementos hoja (no en body con overflow:hidden) */
#input-area {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

.xux-sidebar {
  padding-bottom: env(safe-area-inset-bottom);
}

/* En mobile: sidebar se oculta en páginas con chat-fullscreen-mobile.
   En desktop (md+) el sidebar vertical sigue visible normalmente. */
@media (max-width: 767px) {
  body.chat-fullscreen-mobile .xux-sidebar {
    display: none;
  }
  /* Bottom nav solo en páginas que lo pidan explícitamente (inbox) */
  body.xux-show-bottom-nav .mobile-bottom-nav {
    display: flex;
  }
  /* Empuja la lista del inbox para que no quede tapada por el bottom nav */
  body.xux-show-bottom-nav #mobile-list-wrap {
    padding-bottom: calc(3.75rem + env(safe-area-inset-bottom));
  }
}

/* Bottom nav mobile: oculto por defecto, activo solo con chat-fullscreen-mobile */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  align-items: center;
  justify-content: space-around;
  padding: 0.375rem 0.5rem;
  padding-bottom: max(0.375rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.12);
}

/* Kardex como drawer lateral en mobile: cubre el 88% desde la derecha,
   dejando el borde del chat visible para mantener contexto. */
@media (max-width: 767px) {
  #kardex-panel.kardex-open {
    display: flex !important;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 12%;          /* deja un borde del chat visible a la izquierda */
    width: 88% !important;
    z-index: 200;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
    animation: slideInRight 0.24s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  #kardex-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 199;
    animation: fadeIn 0.2s ease-out;
  }
  #kardex-backdrop.active { display: block; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0.6; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0.6; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (max-width: 767px) {
  #kardex-panel.kardex-closing {
    animation: slideOutRight 0.22s cubic-bezier(0.55, 0, 0.75, 0.06) forwards;
  }
  #kardex-backdrop.closing {
    animation: fadeOut 0.22s ease-out forwards;
  }
}

/* Input area más compacto en mobile */
@media (max-width: 767px) {
  #input-area {
    padding: 0.5rem 0.75rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
  /* iOS Safari hace zoom automático en inputs con font-size < 16px.
     Forzar 16px en mobile evita el zoom sin afectar la apariencia en desktop. */
  #msg-input,
  input[type="text"],
  input[type="search"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px !important;
  }
  #takeover-notice,
  #bot-active-notice,
  #window-closed-notice {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.7rem;
  }
}

.xux-app-shell {
  min-height: 0;
}

:root {
  --xux-gold: #C5A059;
  --xux-turquoise: #2D6A74;
  --xux-dark-blue: #223E44;
  --xux-text: #546E7A;
  --xux-bg-light: #F8F9FA;
  --xux-text-strong: #1F2937;
  --xux-text-medium: #334155;
  --xux-text-soft: #64748B;
}

/* Scrollbar personalizado */
::-webkit-scrollbar            { width: 6px; height: 6px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: #9ca3af; }

/* Chat messages */
.msg-bubble {
  max-width: 75%;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Textarea auto-resize helper */
textarea.auto-resize { resize: none; overflow: hidden; }

/* Fila del compositor del chat: botones alineados al borde inferior del campo
   (1 línea = mismo alto → se ve centrado; varias líneas = botones abajo, estilo WhatsApp) */
#message-form {
  flex-wrap: nowrap;
  align-items: flex-end;
}
#message-form textarea.chat-msg-input {
  box-sizing: border-box;
}

/* Fade-in para nuevos mensajes */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-new { animation: fadeSlideUp .15s ease-out; }

/* Skeleton loader */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

/* Barra superior de página (ritmo unificado) */
.xux-topbar {
  flex-shrink: 0;
  height: 3.5rem;
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Sidebar */
.xux-sidebar nav a {
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Eslogan en sidebar (turquesa aclarado sobre fondo oscuro) */
.xux-brand-slogan {
  color: rgba(165, 218, 226, 0.92);
}

/* Sidebar active link — alineado con --xux-turquoise (antes #3498DB) */
.nav-item-active {
  background: rgba(45, 106, 116, 0.28);
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--xux-gold);
}

/* Títulos de bloque dentro de tarjetas */
.xux-card-heading {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--xux-text-medium);
  letter-spacing: 0.02em;
}

/* Título principal de cada vista (barra superior) */
.xux-page-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--xux-dark-blue);
}

/* Elevación suave en KPIs / tarjetas destacadas */
.xux-hover-lift {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.xux-hover-lift:hover {
  box-shadow: 0 10px 28px rgba(44, 62, 80, 0.09);
  transform: translateY(-1px);
}

/* Lead card hover */
.lead-card:hover { background: var(--xux-bg-light); }
.lead-card.selected { background: rgba(45, 106, 116, 0.08); border-left: 3px solid var(--xux-turquoise); }

/* Toasts flotantes (public/assets/js/api.js → toast()) */
.xux-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  line-height: 1.35;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 1;
  transform: translateY(0);
}
.xux-toast svg {
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.xux-toast--ok {
  background: var(--xux-gold);
  color: #fff;
}
.xux-toast--info {
  background: var(--xux-turquoise);
  color: #fff;
}
.xux-toast--err {
  background: var(--xux-dark-blue);
  color: #fecaca;
  border-left: 4px solid #f87171;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(248, 113, 113, 0.15) inset;
}

/* Bloques de error / aviso en formularios y modales */
.xux-alert--error {
  background: rgba(45, 106, 116, 0.08);
  border: 1px solid rgba(45, 106, 116, 0.22);
  border-left: 4px solid #dc6b6b;
  color: var(--xux-dark-blue);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(34, 62, 68, 0.06);
}

.xux-alert--warn {
  background: rgba(197, 160, 89, 0.12);
  border: 1px solid rgba(197, 160, 89, 0.35);
  border-left: 4px solid var(--xux-gold);
  color: #4a3d22;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* Alertas en listado (ej. partner dashboard) */
.xux-inline-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 0.625rem;
  padding: 0.625rem 1rem;
  border: 1px solid;
}
.xux-inline-alert--critical {
  background: rgba(45, 106, 116, 0.08);
  border-color: rgba(220, 107, 107, 0.38);
  color: var(--xux-dark-blue);
}
.xux-inline-alert--critical .xux-inline-alert__dot {
  background: #e85d5d;
}
.xux-inline-alert--warn {
  background: rgba(197, 160, 89, 0.14);
  border-color: rgba(197, 160, 89, 0.4);
  color: #4a3d22;
}
.xux-inline-alert--warn .xux-inline-alert__dot {
  background: var(--xux-gold);
}
.xux-inline-alert__link {
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  opacity: 0.95;
}
.xux-inline-alert__link:hover {
  opacity: 1;
}

/* Mejora de contraste global para mantener legibilidad */
.text-gray-900, .text-gray-800 { color: var(--xux-text-strong) !important; }
.text-gray-700, .text-gray-600 { color: var(--xux-text-medium) !important; }
.text-gray-500, .text-gray-400 { color: var(--xux-text-soft) !important; }

/* Acabado visual de paneles */
.bg-white.rounded-xl.border,
.bg-white.rounded-2xl.border {
  box-shadow: 0 1px 3px rgba(44, 62, 80, 0.07);
}

/* ─── Mobile bottom nav: uniforme y alineado ──────────────────
   Cada botón = ícono (24×24) + etiqueta (10px), centrados y fijos.
   El indicador activo es una línea en el borde superior del nav,
   usando ::before position:absolute sobre el contenedor del botón. */

.mob-nav-btn {
  position: relative;           /* necesario para el indicador ::before */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: 12px;
  color: #9ca3af;
  transition: color 0.15s ease;
  min-width: 56px;
  cursor: pointer;
}
.mob-nav-btn.active  { color: #fff; }
.mob-nav-btn.inactive { color: #9ca3af; }
.mob-nav-btn:hover   { color: #e5e7eb; }

/* Línea turquesa en borde superior – solo botón activo */
.mob-nav-btn.active::before {
  content: '';
  position: absolute;
  top: -6px;                    /* asoma justo en el borde del nav */
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background-color: var(--xux-turquoise);
}

/* Contenedor de ícono: mismo tamaño fijo para todos los ítems */
.mob-nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;           /* para el badge del online dot */
  flex-shrink: 0;
}
.mob-nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Etiqueta inferior uniforme */
.mob-nav-label {
  font-size: 10px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

/* ─── Mi negocio (business.php): pestañas laterales + barra móvil ─────────
   Clases .biz-nav-btn / .biz-mob-btn — desplegado May 2026
   .biz-nav-desktop / .biz-mob-tabs: visibilidad responsive en CSS propio
   (no solo Tailwind CDN) para WebKit/Safari y hosts con caché viejo. */
.biz-layout {
  position: relative;
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  -webkit-flex: 1 1 0%;
}
/* < md (640px): solo barra móvil; ≥ md: sidebar vertical */
.biz-nav-desktop {
  display: none;
}
@media (min-width: 640px) {
  .biz-nav-desktop {
    display: flex;
    flex-direction: column;
  }
  .biz-mob-tabs {
    display: none !important;
  }
}
@media (max-width: 639.98px) {
  .biz-mob-tabs {
    display: flex;
  }
}

.biz-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.biz-nav-btn:hover { background: #e2e8f0; color: #1e293b; }
.biz-nav-btn.active-nav { background: var(--xux-dark-blue); color: #fff; }

/* Tabs mobile horizontales */
.biz-mob-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.biz-mob-btn.active-mob { color: var(--xux-dark-blue); border-bottom-color: var(--xux-turquoise); }

/* ─── Filter bottom sheet (inbox mobile) ────────────────────── */
#filter-sheet {
  display: none;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#filter-backdrop {
  display: none;
}
#filter-backdrop:not(.hidden) {
  display: block;
}
