/* ==========================================
   SISTEMA DE DISEÑO Y VARIABLES (PREMIUM DARK)
   ========================================== */
:root {
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-glow: rgba(99, 102, 241, 0.05);
  
  /* Paleta de colores primarios */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Colores de Acento (Tailored HSL) */
  --accent-blue: #38bdf8;
  --accent-blue-rgb: 56, 189, 248;
  --accent-purple: #a855f7;
  --accent-purple-rgb: 168, 85, 247;
  --accent-gold: #fbbf24;
  --accent-gold-rgb: 251, 191, 36;
  --accent-green: #34d399;
  --accent-green-rgb: 52, 211, 153;
  --wa-green: #22c55e;
  --accent-danger: #f87171;
  
  /* Burbujas de Chat estilo WhatsApp */
  --bubble-user: rgba(30, 41, 59, 0.8);
  --bubble-bot: rgba(16, 185, 129, 0.15);
  --bubble-bot-border: rgba(16, 185, 129, 0.25);
  
  /* UI general */
  --sidebar-width: 280px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
}

/* ==========================================
   RESETEOS Y ESTILOS BASE
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.07) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.07) 0px, transparent 50%);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
   ESTRUCTURA DE CONTENEDORES (LAYOUT)
   ========================================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ==========================================
   BARRA LATERAL (SIDEBAR)
   ========================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: rgba(15, 23, 42, 0.85);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  z-index: 10;
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--card-border);
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-green), #10b981);
  border-radius: var(--brand-border-radius, var(--border-radius-md));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
}

.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-top: 1px;
}

.sidebar-menu {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.menu-item svg {
  transition: var(--transition-smooth);
}

.menu-item:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.menu-item.active {
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.2);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.05);
}

.menu-item.active svg {
  color: var(--accent-purple);
  filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.5));
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-left: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

/* ==========================================
   PERFIL DE USUARIO EN SIDEBAR
   ========================================== */
.user-profile-widget {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.user-profile-widget .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(99, 102, 241, 0.2));
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--accent-purple);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.user-profile-widget .user-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-profile-widget .user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-widget .role-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 2px;
}

.role-badge.admin {
  background-color: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.role-badge.viewer {
  background-color: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-logout:hover {
  color: var(--accent-danger);
  background-color: rgba(248, 113, 113, 0.08);
}

/* ==========================================
   CONTENIDO PRINCIPAL (MAIN CONTENT)
   ========================================== */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-header {
  padding: 24px 40px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.header-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ==========================================
   ELEMENTOS DE BOTONES
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================
   SECCIONES Y TABS
   ========================================== */
.content-container {
  flex-grow: 1;
  padding: 32px 40px;
  overflow-y: auto;
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease-out;
  height: 100%;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   SECCIÓN DASHBOARD: KPIs Y GRÁFICOS
   ========================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

/* Tarjeta Glassmorphic */
.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
  backdrop-filter: blur(16px);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, transparent 60%, rgba(255, 255, 255, 0.01));
  pointer-events: none;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon svg {
  width: 26px;
  height: 26px;
}

.metric-info h3 {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.metric-info h2 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}

.metric-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Colores Tematizados */
.metric-card.gold .metric-icon {
  background-color: rgba(251, 191, 36, 0.1);
  color: var(--accent-gold);
}
.metric-card.gold:hover { box-shadow: 0 8px 30px rgba(251, 191, 36, 0.05); }

.metric-card.purple .metric-icon {
  background-color: rgba(168, 85, 247, 0.1);
  color: var(--accent-purple);
}
.metric-card.purple:hover { box-shadow: 0 8px 30px rgba(168, 85, 247, 0.05); }

.metric-card.blue .metric-icon {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent-blue);
}
.metric-card.blue:hover { box-shadow: 0 8px 30px rgba(56, 189, 248, 0.05); }

.metric-card.green .metric-icon {
  background-color: rgba(52, 211, 153, 0.1);
  color: var(--accent-green);
}
.metric-card.green:hover { box-shadow: 0 8px 30px rgba(52, 211, 153, 0.05); }

/* Gráficos Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 380px;
}

.chart-card.span-two {
  grid-column: span 2;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.chart-card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.badge {
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 20px;
  display: inline-block;
}

.badge.purple { background-color: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }
.badge.blue { background-color: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.badge.green { background-color: rgba(52, 211, 153, 0.15); color: var(--accent-green); }

.chart-container {
  flex-grow: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* ==========================================
   SECCIÓN CONVERSACIONES: ESPACIO DE CHATS
   ========================================== */
#tab-conversations {
  height: calc(100vh - 120px);
  padding: 0;
  margin: -32px -40px;
}

.chats-workspace {
  display: flex;
  height: 100%;
  width: 100%;
}

/* Panel de Contactos */
.contacts-panel {
  width: 340px;
  border-right: 1px solid var(--card-border);
  background-color: rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.panel-search {
  padding: 20px;
  border-bottom: 1px solid var(--card-border);
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-wrapper svg {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-wrapper input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-wrapper input:focus {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.1);
}

.contacts-list {
  flex-grow: 1;
  overflow-y: auto;
}

/* Contacto Individual */
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.contact-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background-color: var(--accent-green);
  opacity: 0;
  transition: var(--transition-smooth);
}

.contact-item:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.contact-item.active {
  background-color: rgba(168, 85, 247, 0.04);
}

.contact-item.active::after {
  opacity: 1;
  background-color: var(--accent-purple);
}

.contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.contact-info {
  flex-grow: 1;
  min-width: 0;
}

.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.contact-header h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-header span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.contact-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.contact-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-badge {
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
}

.contact-badge.cost { background-color: rgba(251, 191, 36, 0.1); color: var(--accent-gold); }
.contact-badge.tokens { background-color: rgba(168, 85, 247, 0.1); color: var(--accent-purple); }

/* Visor de Chat Activo */
.chat-viewport {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #0b0f19;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(52, 211, 153, 0.03) 0%, transparent 40%);
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
}

.empty-icon {
  width: 100px;
  height: 100px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  color: var(--text-muted);
}

.chat-empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.chat-empty-state p {
  color: var(--text-secondary);
  max-width: 460px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-active-state {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 16px 32px;
  background-color: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-title-wrapper h4 {
  font-size: 1.05rem;
  font-weight: 600;
}

/* Botones de acción en cabecera de chat (Lápiz y basurero) */
.btn-chat-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-chat-action:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.btn-chat-action.edit:hover {
  color: var(--accent-green);
}

.btn-chat-action.delete:hover {
  color: var(--accent-danger);
  background-color: rgba(248, 113, 113, 0.06);
}

.chat-header-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.chat-header-stats {
  display: flex;
  gap: 20px;
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.header-stat span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-stat strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-stat strong#active-chat-tokens { color: var(--accent-purple); }
.header-stat strong#active-chat-cost { color: var(--accent-gold); }

/* Globos de Diálogo estilo WhatsApp */
.chat-messages-area {
  flex-grow: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chat-bubble-group {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.chat-bubble-group.user {
  align-self: flex-start;
}

.chat-bubble-group.bot {
  align-self: flex-end;
}

/* Globo Usuario */
.bubble-text-user {
  background-color: var(--bubble-user);
  border: 1px solid var(--card-border);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
}

.bubble-meta-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 4px;
}

.bubble-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Globo Bot */
.bubble-text-bot {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(20, 184, 166, 0.12));
  border: 1px solid var(--bubble-bot-border);
  border-radius: 18px 4px 18px 18px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.03);
}

.bubble-text-bot pre {
  background-color: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  margin: 10px 0;
  overflow-x: auto;
  font-family: monospace;
}

.bubble-text-bot code {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Barra de telemetría de tokens del Bot */
.bubble-telemetry {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.telemetry-chip {
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.telemetry-chip.model { color: var(--accent-blue); background-color: rgba(56, 189, 248, 0.05); border-color: rgba(56, 189, 248, 0.15); }
.telemetry-chip.tokens { color: var(--accent-purple); background-color: rgba(168, 85, 247, 0.05); border-color: rgba(168, 85, 247, 0.15); }
.telemetry-chip.cost { color: var(--accent-gold); background-color: rgba(251, 191, 36, 0.05); border-color: rgba(251, 191, 36, 0.15); }

/* ==========================================
   SECCIÓN REPORTES Y TABLAS
   ========================================== */
.reports-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.filters-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
}

.filters-card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.filters-row {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}

.filter-group {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group input,
.filter-group select {
  width: 100%;
  padding: 10px 14px;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: rgba(168, 85, 247, 0.5);
}

.filter-group.button-group {
  flex-grow: 0;
}

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background-color: rgba(15, 23, 42, 0.6);
  padding: 16px 24px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 16px 24px;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition-smooth);
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.01);
}

.table-pagination {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--card-border);
}

#table-entries-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

/* ==========================================
   GUÍA DE INTEGRACIÓN Y CÓDIGO
   ========================================== */
.integration-guide {
  max-width: 900px;
  margin: 0 auto;
}

.guide-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 36px;
}

.guide-card > h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}

.guide-card > p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.step {
  display: flex;
  gap: 24px;
}

.step-num {
  width: 36px;
  height: 36px;
  background-color: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--accent-purple);
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.step-content {
  flex-grow: 1;
}

.step-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.step-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 14px;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.guide-table td, .guide-table th {
  padding: 10px 16px;
  font-size: 0.88rem;
  border: 1px solid var(--card-border);
}

.guide-table tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.01);
}

.guide-table td code {
  font-family: monospace;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Diagrama de Flujo Simulado */
.diagram-placeholder {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 18px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--card-border);
  margin: 16px 0;
}

.dia-node {
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
}

.dia-node.whatsapp { background-color: rgba(34, 197, 94, 0.1); color: var(--accent-green); border-color: rgba(34, 197, 94, 0.2); }
.dia-node.openai { background-color: rgba(56, 189, 248, 0.1); color: var(--accent-blue); border-color: rgba(56, 189, 248, 0.2); }
.dia-node.whatsapp-send { background-color: rgba(34, 197, 94, 0.1); color: var(--accent-green); border-color: rgba(34, 197, 94, 0.2); }
.dia-node.dashboard { background-color: rgba(168, 85, 247, 0.15); color: var(--accent-purple); border-color: rgba(168, 85, 247, 0.3); }

.dia-arrow {
  color: var(--text-muted);
  font-weight: 700;
}

/* Bloque de Código interactivo */
.code-block-wrapper {
  margin: 16px 0;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--card-border);
  overflow: hidden;
  background-color: rgba(5, 8, 16, 0.8);
}

.code-header {
  padding: 10px 18px;
  background-color: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-header span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-copy {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-copy:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.code-block-wrapper pre {
  padding: 16px 20px;
  margin: 0;
  overflow-x: auto;
}

.code-block-wrapper code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.84rem;
  color: #e2e8f0;
  line-height: 1.5;
}

kbd {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.78rem;
  font-family: monospace;
}

/* ==========================================
   ESTILOS DE LOGIN DE USUARIO (OVERLAY)
   ========================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(4, 6, 12, 0.88);
  backdrop-filter: blur(24px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: var(--transition-smooth);
}

.login-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  width: 400px;
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

.login-logo svg {
  width: 32px;
  height: 32px;
}

.login-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: -14px;
}

/* Alerta de Error en Login */
.login-alert {
  background-color: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.login-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-bottom: 12px;
}

.login-form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.login-form-group input {
  width: 100%;
  padding: 12px 16px;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.login-form-group input:focus {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.1);
}

.login-help-section {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 14px;
  border-radius: var(--border-radius-md);
  text-align: left;
  font-size: 0.78rem;
}

.login-help-section span {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-help-section ul {
  padding-left: 14px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-help-section code {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
}

/* ==========================================
   ESTILOS DE MODALES (VENTANAS EMERGENTES)
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(4, 6, 12, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: var(--transition-smooth);
}

.modal-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  width: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card.danger {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 20px 50px rgba(239, 68, 68, 0.08);
}

@keyframes modalSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.warning-text {
  color: #fca5a5;
  background-color: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  padding: 12px;
  border-radius: var(--border-radius-md);
  margin-top: 14px;
  font-size: 0.82rem;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.15);
}

/* ==========================================
   ELEMENTOS DE CARGA (LOADING)
   ========================================== */
.loading-spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(168, 85, 247, 0.1);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* ==========================================
   SCROLLBAR
   ========================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.1);
}
