/* ============================================
   RESET & BASE
   ============================================ */

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

:root {
  /* Colors - Minimalista, neutros */
  --color-bg: #ffffff;
  --color-bg-secondary: #fafafa;
  --color-bg-tertiary: #f5f5f5;
  --color-border: #e5e5e5;
  --color-border-light: #f0f0f0;
  
  --color-text: #171717;
  --color-text-secondary: #737373;
  --color-text-tertiary: #a3a3a3;
  
  --color-primary: #0a0a0a;
  --color-primary-hover: #262626;
  
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-warning: #ea580c;
  
  --color-message-in: #ffffff;
  --color-message-out: #f5f5f5;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Typography - Light/Regular weights only */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  
  /* Transitions */
  --transition: 150ms ease;
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] {
  --color-bg: #0a0a0a;
  --color-bg-secondary: #141414;
  --color-bg-tertiary: #1f1f1f;
  --color-border: #2a2a2a;
  --color-border-light: #1f1f1f;
  
  --color-text: #f5f5f5;
  --color-text-secondary: #a3a3a3;
  --color-text-tertiary: #737373;
  
  --color-primary: #f5f5f5;
  --color-primary-hover: #d4d4d4;
  
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f97316;
  
  --color-message-in: #1f1f1f;
  --color-message-out: #262626;
}

/* Transición suave entre temas */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition: background-color 300ms ease, 
              color 300ms ease, 
              border-color 300ms ease,
              box-shadow 300ms ease !important;
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */

/* Estilos para iconos de tema (funcionan en cualquier contenedor) */
.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* Botón flotante (fallback si no hay botón en header) */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 200ms ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border-color: var(--color-text-tertiary);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.15);
}

[data-theme="dark"] .theme-toggle:focus {
  box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.2);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--color-text);
  transition: transform 300ms ease, opacity 200ms ease;
}

/* Animación de rotación al cambiar */
.theme-toggle:hover svg {
  transform: rotate(15deg);
}

/* Mobile responsive para botón flotante */
@media (max-width: 768px) {
  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }
  
  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }
}

/* Botón de tema integrado en header - NO es flotante */
#theme-toggle.btn-config,
#theme-toggle.btn-icon {
  position: static;
  width: auto;
  height: auto;
  border-radius: var(--space-sm);
  box-shadow: none;
  z-index: auto;
}

#theme-toggle.btn-config:hover,
#theme-toggle.btn-icon:hover {
  transform: none;
  box-shadow: none;
}

body {
  font-family: var(--font-family);
  font-weight: var(--font-weight-normal);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: var(--space-md);
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  pointer-events: auto;
  animation: toastSlideIn 0.2s var(--transition);
}

.toast.removing {
  animation: toastSlideOut 0.2s var(--transition) forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(calc(100% + var(--space-lg)));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  to {
    transform: translateX(calc(100% + var(--space-lg)));
    opacity: 0;
  }
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.toast-message {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  padding: 0;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--color-text-tertiary);
  transition: color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.toast-close svg {
  width: 14px;
  height: 14px;
}

/* Toast Types */
.toast.success .toast-icon {
  color: var(--color-success);
}

.toast.error .toast-icon {
  color: var(--color-error);
}

.toast.warning .toast-icon {
  color: var(--color-warning);
}

.toast.info .toast-icon {
  color: var(--color-text-secondary);
}

/* Progress Bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.3;
  animation: toastProgress linear;
}

.toast.success .toast-progress {
  color: var(--color-success);
}

.toast.error .toast-progress {
  color: var(--color-error);
}

.toast.warning .toast-progress {
  color: var(--color-warning);
}

.toast.info .toast-progress {
  color: var(--color-text-secondary);
}

@keyframes toastProgress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* Responsive */
@media (max-width: 480px) {
  #toast-container {
    top: var(--space-md);
    right: var(--space-md);
    left: var(--space-md);
  }
  
  .toast {
    min-width: auto;
    max-width: none;
  }
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ============================================
   NAV SIDEBAR (Menú lateral izquierdo)
   ============================================ */

.nav-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: #0a0a0a !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex !important;
  flex-direction: column;
  z-index: 10000;
  transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Ocultar nav-sidebar en pantalla de login */
#login-screen.active ~ .nav-sidebar {
  display: none !important;
}

.nav-sidebar.collapsed {
  width: 64px !important;
}

.nav-sidebar-toggle {
  position: absolute;
  top: 16px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  transition: all 200ms ease;
  z-index: 2;
}

.nav-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

.nav-sidebar-toggle svg {
  transition: transform 300ms ease;
}

.nav-sidebar:not(.collapsed) .nav-sidebar-toggle svg {
  transform: rotate(180deg);
}

.nav-sidebar-nav {
  margin-top: 68px;
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.nav-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.nav-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.nav-sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all 200ms ease;
  margin-bottom: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.nav-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.nav-sidebar-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-sidebar-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  stroke-width: 1.5;
}

.nav-sidebar-text {
  opacity: 1;
  transition: opacity 150ms ease;
  white-space: nowrap;
}

.nav-sidebar.collapsed .nav-sidebar-text {
  display: none;
}

.nav-sidebar-status-dot {
  position: absolute;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #737373;
  opacity: 0;
  transition: all 200ms ease;
}

.nav-sidebar.collapsed .nav-sidebar-status-dot {
  right: auto;
  left: 38px;
  top: 8px;
}

.nav-sidebar-item.status-connected .nav-sidebar-status-dot {
  background: #22c55e;
  opacity: 1;
}

.nav-sidebar-item.status-connecting .nav-sidebar-status-dot {
  background: #ea580c;
  opacity: 1;
  animation: pulse 2s ease-in-out infinite;
}

.nav-sidebar-item.status-error .nav-sidebar-status-dot {
  background: #dc2626;
  opacity: 1;
}

.nav-sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 12px 8px;
}

/* Tooltips cuando está colapsado */
.sidebar.collapsed .nav-sidebar-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 12px;
  padding: 6px 12px;
  background: #1f1f1f;
  color: #ffffff;
  font-size: 13px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed .nav-sidebar-item:hover::after {
  opacity: 1;
}

/* Ajuste del dashboard cuando sidebar está activo */
#dashboard-screen {
  padding-left: 64px;
  transition: padding-left 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

#dashboard-screen.nav-sidebar-expanded {
  padding-left: 240px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  #dashboard-screen {
    padding-left: 0 !important;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ============================================
   LOGIN
   ============================================ */

#login-screen {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}

#login-screen.active {
  display: flex;
}

.login-video-container {
  position: fixed;
  top: 0;
  right: 0;
  width: 45%;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
}

.login-video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  object-fit: cover;
}

.login-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    var(--color-bg) 0%, 
    transparent 60%
  );
  pointer-events: none;
}

[data-theme="dark"] .login-video-overlay {
  background: linear-gradient(90deg, 
    rgba(10, 10, 10, 0.98) 0%, 
    rgba(10, 10, 10, 0.2) 60%
  );
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.login-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-xl);
  width: 100%;
  max-width: 380px;
}

.logo {
  font-size: 24px;
  font-weight: var(--font-weight-normal);
  margin-bottom: var(--space-xs);
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: var(--space-xs);
  font-weight: var(--font-weight-medium);
}

.subtitle-small {
  color: var(--color-text-tertiary);
  font-size: 12px;
  margin-bottom: var(--space-lg);
}

.login-footer {
  text-align: center;
  margin-top: var(--space-md);
}

.login-link {
  color: var(--color-text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: color var(--transition);
}

.login-link:hover {
  color: var(--color-text);
}

.login-divider {
  color: var(--color-text-tertiary);
  margin: 0 var(--space-sm);
}

.login-footer-copy {
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 11px;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* Admin Access Icon */
.admin-access-icon {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
  opacity: 0.3;
  transition: opacity 0.2s ease, color 0.2s ease;
  text-decoration: none;
  border-radius: 6px;
}

.admin-access-icon:hover {
  opacity: 1;
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
}

.login-box {
  position: relative;
}

/* Login Responsive */
@media (max-width: 900px) {
  .login-video-container {
    width: 40%;
  }
  
  .login-container {
    width: 60%;
  }
}

@media (max-width: 768px) {
  .login-video-container {
    display: none;
  }
  
  .login-container {
    width: 100%;
    background: var(--color-bg);
  }
}

/* Ocultar video cuando login-screen no está activo */
#login-screen:not(.active) .login-video-container {
  display: none !important;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: relative;
  background: var(--color-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

.modal-title {
  font-size: 18px;
  font-weight: var(--font-weight-medium);
  letter-spacing: -0.3px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-description {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

.modal-description strong {
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
}

/* Referral Benefits */
.referral-benefits {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-radius: 8px;
}

.benefit-item {
  flex: 1;
  text-align: center;
}

.benefit-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  margin: 0 auto var(--space-sm);
}

.benefit-text {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.input-hint {
  display: block;
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
}

.success-message {
  padding: var(--space-md);
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  color: var(--color-success);
  font-size: 13px;
  margin-top: var(--space-md);
  text-align: center;
}

.success-message.hidden {
  display: none;
}

.error-message {
  padding: var(--space-md);
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #dc2626;
  font-size: 13px;
  margin-top: var(--space-md);
  text-align: center;
}

.error-message.hidden {
  display: none;
}

.input-group {
  margin-bottom: var(--space-md);
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.input-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
}

.input-group input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--color-text);
  color: var(--color-bg);
  border: 1px solid var(--color-text);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-weight: normal;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.8;
}

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 8px 16px;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-weight: normal;
  cursor: pointer;
  transition: border-color 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-text);
}

.btn-secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 8px;
  transition: color var(--transition);
}

.btn-text:hover {
  color: var(--color-text);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.error-message {
  color: var(--color-error);
  font-size: 13px;
  margin-top: var(--space-md);
  display: none;
}

.error-message.show {
  display: block;
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

/* System Notifications */
.system-notifications {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  max-width: 420px;
  width: calc(100vw - 48px);
  pointer-events: none;
}

.system-notification {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: var(--color-bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--color-border);
  animation: notifSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.system-notification.info {
  background: var(--color-bg);
}

.system-notification.success {
  background: var(--color-bg);
}

.system-notification.warning {
  background: var(--color-bg);
}

.system-notification.error {
  background: var(--color-bg);
}

.system-notification-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.system-notification.info .system-notification-icon { color: var(--color-primary); }
.system-notification.success .system-notification-icon { color: #16a34a; }
.system-notification.warning .system-notification-icon { color: #ea580c; }
.system-notification.error .system-notification-icon { color: #dc2626; }

.system-notification-content {
  flex: 1;
  min-width: 0;
}

.system-notification-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
}

.system-notification-message {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.system-notification-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1;
  font-weight: 300;
}

.system-notification-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--color-text);
  transform: scale(1.1);
}

.system-notification-close:active {
  transform: scale(0.95);
}

@keyframes notifSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.system-notification.removing {
  animation: notifSlideOut 0.25s ease forwards;
}

@keyframes notifSlideOut {
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  .system-notifications {
    bottom: 16px;
    right: 16px;
    max-width: calc(100vw - 32px);
    width: calc(100vw - 32px);
  }
  
  .system-notification {
    padding: 12px;
  }
}

.header {
  height: 60px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--color-bg);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  justify-content: center;
}

.header-title {
  font-size: 16px;
  font-weight: var(--font-weight-medium);
  letter-spacing: -0.3px;
  margin: 0;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 300;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.header-greeting {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-normal);
  margin: 0;
  line-height: 1.3;
}

.header-org-name {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-weight: var(--font-weight-normal);
  margin: 0;
  line-height: 1.3;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Status Buttons - Same style as config button */
.btn-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  cursor: default;
  transition: all var(--transition);
  position: relative;
}

.btn-status svg {
  flex-shrink: 0;
}

.btn-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all var(--transition);
}

.btn-status .status-dot.active {
  background: var(--color-success);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
  animation: pulse-status 2s ease-in-out infinite;
}

.btn-status .status-dot.error {
  background: var(--color-error);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
  animation: pulse-status 2s ease-in-out infinite;
}

.btn-status .status-dot.warning {
  background: var(--color-warning);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.15);
  animation: pulse-status 2s ease-in-out infinite;
}

@keyframes pulse-status {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Social Media Status Buttons - Coming Soon */
.btn-status-soon {
  opacity: 0.6;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}

.btn-status-soon:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

.btn-status {
  cursor: pointer;
}

.btn-status:not(.btn-status-soon):hover {
  background: var(--color-bg-tertiary);
  transform: translateY(-1px);
}

.status-dot-red {
  background: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
  animation: pulse-status 2s ease-in-out infinite;
}

/* ============================================
   GPT & SOCIAL MEDIA MODALS
   ============================================ */

/* Multimedia Modal */
.multimedia-main {
  max-width: 800px;
  margin: 0 auto;
}

.multimedia-description {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-bottom: 20px;
  line-height: 1.4;
}

.multimedia-types {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.media-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  transition: none;
}

.media-type-card:hover {
  border-color: var(--color-text);
}

.media-type-card svg {
  color: var(--color-text-tertiary);
}

.media-type-card h4 {
  font-size: 11px;
  font-weight: normal;
  color: var(--color-text);
  margin: 0;
}

.media-format {
  font-size: 10px;
  color: var(--color-text-tertiary);
}

.rules-section {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  margin-top: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header span:first-child {
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rules-counter {
  font-size: 10px;
  color: var(--color-text-tertiary);
}

.rules-list {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-rules {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-tertiary);
  padding: 20px;
}

/* Rules Table */
.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.rules-table thead th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  font-weight: normal;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 9px;
}

.rules-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: none;
}

.rules-table tbody tr:hover {
  background: rgba(0,0,0,0.02);
}

.rules-table tbody tr.rule-inactive {
  opacity: 0.5;
}

.rules-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.rule-indicator-cell {
  width: 30px;
  padding-left: 16px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}

.status-active {
  background: #22c55e;
  animation: pulse-status 2s infinite;
}

.status-inactive {
  background: #ef4444;
}

.rule-type-cell {
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 9px;
  font-weight: 500;
  width: 70px;
}

.rule-triggers-cell {
  color: var(--color-text);
  font-size: 10px;
}

.rule-file-cell {
  color: var(--color-text);
  font-size: 10px;
}

.file-size-hint {
  color: var(--color-text-tertiary);
  font-size: 9px;
}

.rule-actions-cell {
  width: 100px;
  text-align: right;
}

.rule-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 16px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ef4444;
  border-radius: 16px;
  transition: background-color 0.2s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #22c55e;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.rule-delete-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: none;
  padding: 0;
}

.rule-delete-btn:hover {
  color: var(--color-text);
}

/* Multimedia Create Form */
.multimedia-create {
  max-width: 700px;
  margin: 0 auto;
}

.create-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-lg);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.btn-back {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: none;
  padding: 0;
}

.btn-back:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

.create-breadcrumb {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: normal;
}

.form-section {
  margin-bottom: var(--space-lg);
}

.form-section label {
  display: block;
  font-size: 12px;
  font-weight: normal;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.big-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.big-input:focus {
  outline: none;
  border-color: var(--color-text);
}

.big-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  resize: vertical;
  transition: border-color 0.2s;
}

.big-textarea:focus {
  outline: none;
  border-color: var(--color-text);
}

.input-help {
  margin-top: var(--space-sm);
}

.help-examples {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.example-tag {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.example-tag:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

.upload-zone {
  border: 1px dashed var(--color-border);
  border-radius: 4px;
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}

.upload-zone:hover {
  border-color: var(--color-text);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.upload-icon svg {
  color: var(--color-text-tertiary);
}

.upload-content h4 {
  font-size: 13px;
  font-weight: normal;
  color: var(--color-text);
  margin: 0;
}

.upload-content p {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0;
}

.size-limit {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.preview-info {
  flex: 1;
}

.preview-info h4 {
  font-size: 13px;
  font-weight: normal;
  color: var(--color-text);
  margin: 0 0 2px 0;
}

.preview-info p {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin: 0;
}

.remove-btn {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s;
}

.remove-btn:hover {
  color: var(--color-text);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-cancel {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: normal;
  cursor: pointer;
  transition: none;
}

.btn-cancel:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

.btn-save {
  padding: 8px 16px;
  border: 1px solid var(--color-text);
  border-radius: 2px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 11px;
  font-weight: normal;
  cursor: pointer;
  transition: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-save svg {
  width: 14px;
  height: 14px;
}

.btn-save:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-tertiary);
}

/* GPT Status Modal */
.gpt-status-container {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--space-xl) 0;
}

.gpt-status-main {
  text-align: center;
  padding-bottom: var(--space-xl);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.status-indicator-large {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-dot-large {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.2);
  animation: pulse-status 2s ease-in-out infinite;
}

.status-dot-large.error {
  background: var(--color-error);
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.2);
}

.status-dot-large.warning {
  background: var(--color-warning);
  box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.2);
}

.gpt-status-main h3 {
  font-size: 24px;
  font-weight: var(--font-weight-medium);
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
}

.status-description {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0;
}

.gpt-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: all var(--transition);
}

.metric-item:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: var(--font-weight-medium);
}

.metric-value {
  font-size: 20px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

/* Social Media Modal */
.social-coming-soon {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  padding: var(--space-xl) 0;
}

.coming-soon-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--space-xl);
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
}

.social-coming-soon h3 {
  font-size: 22px;
  font-weight: var(--font-weight-medium);
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text);
}

.social-coming-soon p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xl) 0;
}

.social-coming-soon p strong {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.features-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-align: left;
}

.feature-preview-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 13px;
  color: var(--color-text);
}

.feature-preview-item svg {
  color: var(--color-success);
  flex-shrink: 0;
}

.social-coming-soon .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.status-soon {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--color-bg);
  color: var(--color-text-tertiary);
  font-size: 8px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.2px;
  text-transform: lowercase;
  border: 1px solid var(--color-border);
  z-index: 1;
}

.user-email {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.main-content {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden; /* Prevenir scroll en el contenedor padre */
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: 360px;
  height: 100%; /* Altura fija del contenedor padre */
  border-right: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* No se encoge nunca */
  overflow: hidden; /* Sin scroll en el contenedor */
}

.panel-title {
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
  transition: all 0.2s ease;
}

.status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  transition: background 0.2s ease;
}

.status-badge .status-dot.online {
  background: var(--color-success);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-badge .status-dot.error {
  background: var(--color-error);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.status-badge .status-dot.warning {
  background: var(--color-warning);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2);
}

/* Connection Panel */
.connection-panel {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.panel-title-compact {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  margin-bottom: 6px;
}

.qr-container.hidden {
  display: none;
}

.qr-container img {
  width: 280px;
  height: 280px;
  border-radius: 8px;
  background: white;
  border: 2px solid var(--color-border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qr-timer {
  margin-top: 4px;
  padding: 2px 6px;
  background: var(--color-text-tertiary);
  color: white;
  border-radius: 8px;
  font-size: 9px;
  font-weight: var(--font-weight-medium);
  display: inline-block;
}

.qr-timer.hidden {
  display: none;
}

.pairing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  margin-bottom: 6px;
}

.pairing-container.hidden {
  display: none;
}

.pairing-info {
  text-align: center;
}

.pairing-title {
  font-size: 10px;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.pairing-code {
  font-size: 28px;
  font-weight: var(--font-weight-medium);
  letter-spacing: 6px;
  color: var(--color-primary);
  margin: 8px 0;
  font-family: 'Courier New', monospace;
}

.pairing-instructions {
  font-size: 10px;
  color: var(--color-text-tertiary);
  line-height: 1.4;
  max-width: 200px;
  margin-top: 6px;
}

.connection-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.connection-actions > div {
  display: flex;
  gap: 6px;
}

.connection-actions button {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
}

.btn-text-small {
  padding: 6px 8px;
  font-size: 11px;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.btn-text-small:hover {
  opacity: 1;
}

/* Search Panel */
.search-panel {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  transition: all var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-bg);
}

.search-input::placeholder {
  color: var(--color-text-tertiary);
}

/* Chat List */
.chat-list-panel {
  padding: var(--space-lg);
  flex: 1 1 0; /* flex-grow, flex-shrink, flex-basis */
  overflow-y: auto; /* Scroll vertical independiente */
  overflow-x: hidden; /* Sin scroll horizontal */
  min-height: 0; /* Importante para que flex + overflow funcionen */
  max-height: 100%; /* No exceder el contenedor padre */
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Sección de silenciados con animación */
.chat-section-divider {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
  animation: dividerSlideIn 0.4s ease-out;
}

@keyframes dividerSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-item {
  padding: var(--space-md);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
  position: relative;
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

/* ========================================
   ANIMACIONES DE CHAT SILENCIADO
   ======================================== */

/* Animación de entrada para chats */
@keyframes chatSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animación de salida para chats */
@keyframes chatSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Aplicar animación a todos los chats al cargar */
.chat-item {
  animation: chatSlideIn 0.3s ease-out;
}

/* Chat silenciado - estilo más tenue con transición suave */
.chat-item.chat-muted {
  opacity: 0.6;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-item.chat-muted:hover {
  opacity: 0.85;
  transform: translateX(2px);
}

/* Icono de silenciado */
.muted-icon {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-right: 6px;
  opacity: 0.7;
  animation: iconFadeIn 0.3s ease-out;
}

@keyframes iconFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 0.7;
    transform: scale(1);
  }
}

.chat-item:hover {
  background: var(--color-bg-secondary);
}

.chat-item.active {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border);
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  flex-shrink: 0;
  overflow: visible; /* Cambiado para que el badge sea visible */
  position: relative;
}

.chat-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Badge de plataforma - esquina inferior derecha visible */
.platform-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 2px solid var(--color-bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.platform-badge.platform-whatsapp {
  background: #25D366;
  color: white;
}

.platform-badge.platform-telegram {
  background: #0088cc;
  color: white;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
  margin-right: 80px; /* Espacio para el toggle */
}

.chat-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-item-name {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-time {
  font-size: 11px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Toggle en posición fija a la derecha */
.ai-toggle-wrapper {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-item-message {
  font-size: 13px;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  max-height: calc(13px * 1.4 * 2); /* 2 líneas */
  word-break: break-word;
}

.chat-item-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--color-primary);
  color: white;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  border-radius: 10px;
  margin-left: 8px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* ============================================
   CHAT VIEW
   ============================================ */

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty .empty-state {
  text-align: center;
  color: var(--color-text-tertiary);
}

.chat-empty .empty-state svg {
  margin-bottom: var(--space-lg);
  opacity: 0.3;
}

.chat-empty .empty-state h2 {
  font-size: 16px;
  font-weight: var(--font-weight-normal);
  margin-bottom: var(--space-xs);
  color: var(--color-text-secondary);
}

.chat-empty .empty-state p {
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: var(--space-lg);
  color: var(--color-text-tertiary);
}

.chat-view {
  flex: 1 1 0; /* Toma el resto del espacio */
  display: flex;
  overflow: hidden; /* Control total del overflow */
  height: 100%; /* Altura fija */
}

.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%; /* Altura fija completa */
  overflow: hidden; /* Control de overflow */
}

.chat-active.hidden {
  display: none;
}

.chat-header {
  height: 60px;
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg);
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  overflow: hidden;
  flex-shrink: 0;
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-info h3 {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  margin-bottom: 2px;
}

.contact-info p {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* Messages */
.messages-container {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23000000' stroke-width='0.5' opacity='0.08'%3E%3C!-- Mensaje burbujas --%3E%3Cpath d='M15 20h18c2 0 3-1 3-3v-8c0-2-1-3-3-3H15c-2 0-3 1-3 3v8c0 2 1 3 3 3z'/%3E%3Cpath d='M18 20l-2 3'/%3E%3C!-- Check mark --%3E%3Cpolyline points='88 15 91 18 96 13'/%3E%3Cpolyline points='92 15 95 18 100 13'/%3E%3C!-- Micrófono --%3E%3Ccircle cx='65' cy='75' r='3'/%3E%3Cpath d='M65 78v4m-2 0h4m-2-12v4'/%3E%3Cpath d='M62 73c0-1.5 1.3-3 3-3s3 1.5 3 3v4c0 1.5-1.3 3-3 3s-3-1.5-3-3z'/%3E%3C!-- Paper plane --%3E%3Cpath d='M85 65l-12-6 12-6 4 6z'/%3E%3Cpath d='M73 59l4 6-4 6'/%3E%3C!-- Emoji feliz --%3E%3Ccircle cx='35' cy='95' r='5'/%3E%3Ccircle cx='33' cy='94' r='0.8' fill='%23000000'/%3E%3Ccircle cx='37' cy='94' r='0.8' fill='%23000000'/%3E%3Cpath d='M33 96.5c0.5 0.8 1.5 1.2 2 1.2s1.5-0.4 2-1.2'/%3E%3C!-- Corazón --%3E%3Cpath d='M105 95c-1.5-1.5-4-1.5-5.5 0l-0.5 0.5-0.5-0.5c-1.5-1.5-4-1.5-5.5 0-1.5 1.5-1.5 4 0 5.5l6 6 6-6c1.5-1.5 1.5-4 0-5.5z'/%3E%3C!-- Rayo --%3E%3Cpath d='M50 48l-3 6h4l-3 6'/%3E%3C!-- Notificación campana --%3E%3Cpath d='M20 85c0-2 1.5-3.5 3.5-3.5s3.5 1.5 3.5 3.5-1.5 3.5-3.5 3.5'/%3E%3Cpath d='M23.5 88.5v1.5m-3-8v-2c0-1.5 1.3-3 3-3s3 1.5 3 3v2'/%3E%3C!-- Candado --%3E%3Crect x='76' y='28' width='8' height='10' rx='1'/%3E%3Cpath d='M78 28v-3c0-1.1 0.9-2 2-2s2 0.9 2 2v3'/%3E%3C!-- Estrella --%3E%3Cpath d='M50 90l1.5 3 3.3 0.5-2.4 2.3 0.6 3.2-2.9-1.5-2.9 1.5 0.6-3.2-2.4-2.3 3.3-0.5z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px;
  min-height: 0;
  max-height: 100%;
}

/* Modo oscuro */
[data-theme="dark"] .messages-container {
  background-color: #0a0a0a;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.06'%3E%3C!-- Mensaje burbujas --%3E%3Cpath d='M15 20h18c2 0 3-1 3-3v-8c0-2-1-3-3-3H15c-2 0-3 1-3 3v8c0 2 1 3 3 3z'/%3E%3Cpath d='M18 20l-2 3'/%3E%3C!-- Check mark --%3E%3Cpolyline points='88 15 91 18 96 13'/%3E%3Cpolyline points='92 15 95 18 100 13'/%3E%3C!-- Micrófono --%3E%3Ccircle cx='65' cy='75' r='3'/%3E%3Cpath d='M65 78v4m-2 0h4m-2-12v4'/%3E%3Cpath d='M62 73c0-1.5 1.3-3 3-3s3 1.5 3 3v4c0 1.5-1.3 3-3 3s-3-1.5-3-3z'/%3E%3C!-- Paper plane --%3E%3Cpath d='M85 65l-12-6 12-6 4 6z'/%3E%3Cpath d='M73 59l4 6-4 6'/%3E%3C!-- Emoji feliz --%3E%3Ccircle cx='35' cy='95' r='5'/%3E%3Ccircle cx='33' cy='94' r='0.8' fill='%23ffffff'/%3E%3Ccircle cx='37' cy='94' r='0.8' fill='%23ffffff'/%3E%3Cpath d='M33 96.5c0.5 0.8 1.5 1.2 2 1.2s1.5-0.4 2-1.2'/%3E%3C!-- Corazón --%3E%3Cpath d='M105 95c-1.5-1.5-4-1.5-5.5 0l-0.5 0.5-0.5-0.5c-1.5-1.5-4-1.5-5.5 0-1.5 1.5-1.5 4 0 5.5l6 6 6-6c1.5-1.5 1.5-4 0-5.5z'/%3E%3C!-- Rayo --%3E%3Cpath d='M50 48l-3 6h4l-3 6'/%3E%3C!-- Notificación campana --%3E%3Cpath d='M20 85c0-2 1.5-3.5 3.5-3.5s3.5 1.5 3.5 3.5-1.5 3.5-3.5 3.5'/%3E%3Cpath d='M23.5 88.5v1.5m-3-8v-2c0-1.5 1.3-3 3-3s3 1.5 3 3v2'/%3E%3C!-- Candado --%3E%3Crect x='76' y='28' width='8' height='10' rx='1'/%3E%3Cpath d='M78 28v-3c0-1.1 0.9-2 2-2s2 0.9 2 2v3'/%3E%3C!-- Estrella --%3E%3Cpath d='M50 90l1.5 3 3.3 0.5-2.4 2.3 0.6 3.2-2.9-1.5-2.9 1.5 0.6-3.2-2.4-2.3 3.3-0.5z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px;
}

.messages {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.message {
  display: flex;
  gap: var(--space-sm);
  max-width: 70%;
}

.message.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
}

.message.incoming .message-bubble {
  background: var(--color-message-in);
  border: 1px solid var(--color-border);
}

.message.outgoing .message-bubble {
  background: var(--color-message-out);
  border: 1px solid var(--color-border-light);
}

.message-time {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
  display: block;
}

.message.processing .message-bubble {
  opacity: 0.6;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--color-bg-secondary);
  border-radius: 18px;
  width: fit-content;
  max-width: 100px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: typingAnimation 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Message Input */
.message-input-container {
  border-top: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg);
}

.message-form {
  display: flex;
  gap: var(--space-sm);
}

.message-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.message-form input:focus {
  border-color: var(--color-primary);
}

.message-form input:disabled {
  background: var(--color-bg-tertiary);
  cursor: not-allowed;
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
  display: none !important;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}
/* ============================================
   CONFIG MODAL - PROMPT CONFIGURATION
   ============================================ */

.modal-large .modal-content {
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-config {
  padding: 0;
}

.modal-config .modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
}

.modal-config .modal-body {
  padding: var(--space-lg);
}

.btn-config {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-config:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-text-tertiary);
}

/* Config Steps */
.config-step {
  display: none;
}

.config-step.active {
  display: block;
}

.config-intro {
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.config-description {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.section-title {
  font-size: 16px;
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

/* Industry Selector - Grid con Scroll Horizontal */
.industry-grid {
  display: grid;
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 10px;
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.industry-grid::-webkit-scrollbar {
  height: 5px;
}

.industry-grid::-webkit-scrollbar-track {
  background: transparent;
}

.industry-grid::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.industry-grid::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

.industry-card {
  padding: 16px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  background: var(--color-bg);
  min-height: 90px;
}

.industry-card:hover {
  border-color: var(--color-text-tertiary);
  background: var(--color-bg-secondary);
}

.industry-card.selected {
  border-color: var(--color-text);
  background: var(--color-bg-tertiary);
}

.industry-card svg {
  width: 32px;
  height: 32px;
  color: var(--color-text);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.industry-card h4 {
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  margin-top: 4px;
  line-height: 1.3;
  color: var(--color-text);
}

.industry-card p {
  display: none;
}

/* Subtype Selector */
.subtype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.subtype-card {
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.subtype-card:hover {
  border-color: var(--color-text-tertiary);
  background: var(--color-bg-secondary);
}

.subtype-card.selected {
  border-color: var(--color-primary);
  background: var(--color-bg-tertiary);
}

.subtype-icon {
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.subtype-icon svg {
  color: var(--color-text);
}

.subtype-card h5 {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
}

/* Config Form */
.config-form-container {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: var(--space-lg);
}

.form-section {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
  border-bottom: none;
}

.form-section-header {
  margin-bottom: var(--space-md);
}

.form-section-title {
  font-size: 15px;
  font-weight: var(--font-weight-medium);
  margin-bottom: 4px;
}

.form-section-description {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.form-field {
  margin-bottom: var(--space-md);
}

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

.form-field label .required {
  color: var(--color-error);
}

.form-field-help {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
}

.form-field input[type="text"],
.form-field input[type="time"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border var(--transition);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

.form-field-multiselect {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.multiselect-option {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.multiselect-option:hover {
  background: var(--color-bg-secondary);
}

.multiselect-option.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Prompt Preview */
.prompt-preview-container {
  margin-bottom: var(--space-lg);
}

.prompt-preview {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: var(--space-md);
  max-height: 50vh;
  overflow-y: auto;
}

.prompt-preview pre {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Config Actions */
.config-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* Settings Section */
.settings-section {
  margin-bottom: var(--space-xl);
}

.settings-section-title {
  font-size: 16px;
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.settings-section-description {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.form-checkbox {
  width: 18px;
  height: 18px;
  margin-right: var(--space-sm);
  cursor: pointer;
  accent-color: var(--color-primary);
}

.form-textarea {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  resize: vertical;
  transition: border-color var(--transition);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.form-hint {
  display: block;
  margin-top: var(--space-sm);
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ============================================
   AI TOGGLE SWITCH - Pequeño y elegante
   ============================================ */

.ai-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.ai-toggle:hover {
  background: var(--color-border-light);
}

.ai-toggle.active {
  background: var(--color-success);
}

.ai-toggle.active:hover {
  background: #15803d;
}

.ai-toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.ai-toggle.active .ai-toggle-slider {
  transform: translateX(14px);
}

.ai-toggle-label {
  font-size: 10px;
  color: var(--color-text-tertiary);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
  transition: color 0.2s ease;
}

.ai-toggle.active + .ai-toggle-label {
  color: var(--color-success);
}

/* ============================================
   PROMPT TABS - Asistido / Manual
   ============================================ */

.prompt-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space-lg);
  padding: 4px;
  background: var(--color-bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.prompt-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-tab:hover {
  background: var(--color-bg-tertiary);
}

.prompt-tab.active {
  background: var(--color-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.prompt-tab .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
}

.prompt-tab .tab-icon svg {
  width: 24px;
  height: 24px;
}

.prompt-tab.active .tab-icon {
  color: var(--color-primary);
}

.prompt-tab .tab-text {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.prompt-tab .tab-hint {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.prompt-tab.active .tab-text {
  color: var(--color-primary);
}

/* Active Badge on Tab */
.tab-active-badge {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-success);
  color: white;
}

.tab-active-badge.visible {
  display: inline-block;
}

.prompt-tab {
  position: relative;
}

.prompt-tab.is-active-prompt {
  border: 2px solid var(--color-success);
}

.prompt-tab.is-active-prompt .tab-active-badge {
  display: inline-block;
}

/* Active Prompt Info Bar */
.active-prompt-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  font-size: 13px;
}

.active-prompt-label {
  color: var(--color-text-secondary);
}

.active-prompt-type {
  font-weight: 600;
  color: var(--color-success);
}

.active-prompt-type.none {
  color: var(--color-text-tertiary);
  font-weight: normal;
}

/* Prompt Tab Content */
.prompt-tab-content {
  display: none;
}

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

/* Manual Prompt Section */
.manual-prompt-section {
  margin-bottom: var(--space-lg);
}

.manual-prompt-section .form-group {
  max-width: 100%;
  width: 100%;
  margin: 0;
}

.prompt-textarea {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 300px;
  width: 100%;
}

.prompt-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: 6px;
  font-size: 13px;
}

.prompt-status .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
}

.prompt-status.saved .status-indicator {
  background: var(--color-success);
}

.prompt-status .status-text {
  color: var(--color-text-secondary);
}

/* Settings Info */
.settings-info {
  background: var(--color-bg-secondary);
  border-radius: 6px;
  padding: var(--space-md);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.info-value {
  color: var(--color-text);
  font-size: 13px;
  font-weight: var(--font-weight-medium);
}

.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

/* ============================================
   STATISTICS MODAL
   ============================================ */

.modal-stats {
  max-width: 1000px;
}

.modal-stats .modal-header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
}

.modal-stats .modal-body {
  padding: 0;
}

/* KPI Cards Grid */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Siempre 4 columnas en una fila */
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

@media (max-width: 900px) {
  .stats-kpi-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columnas en tablets */
  }
}

@media (max-width: 600px) {
  .stats-kpi-grid {
    grid-template-columns: 1fr; /* 1 columna en móviles */
  }
}

.stats-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-md);
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  transition: all var(--transition);
}

.stats-card:hover {
  border-color: var(--color-text-tertiary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stats-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.stats-card-content {
  flex: 1;
  min-width: 0;
}

.stats-card-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: var(--font-weight-medium);
}

.stats-card-value {
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stats-card-sublabel {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

/* Charts Section */
.stats-charts {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.stats-chart-container {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-lg);
}

.stats-chart-title {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Bar Chart */
.stats-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: var(--space-sm) 0;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bar-visual {
  width: 100%;
  background: var(--color-text);
  border-radius: 2px 2px 0 0;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 2px;
}

.bar-visual:hover {
  background: var(--color-text-secondary);
}

.bar-value {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.bar-label {
  font-size: 10px;
  color: var(--color-text-tertiary);
  text-align: center;
  font-weight: 400;
}

/* Split Chart (AI vs Manual) */
.stats-split-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.split-chart-visual {
  padding: var(--space-md) 0;
}

.split-bar {
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  border: 1px solid var(--color-border);
}

.split-bar-ai {
  background: var(--color-text);
  transition: width 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 500;
  font-size: 13px;
}

.split-bar-manual {
  background: var(--color-bg-tertiary);
  transition: width 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 13px;
}

.split-chart-legend {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.legend-label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.legend-label strong {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

/* Top Contacts List */
.stats-top-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.top-contact-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border-radius: 6px;
  transition: all var(--transition);
}

.top-contact-item:hover {
  background: var(--color-bg-tertiary);
}

.top-contact-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.top-contact-rank.gold {
  background: var(--color-text);
}

.top-contact-rank.silver {
  background: var(--color-text-secondary);
}

.top-contact-rank.bronze {
  background: var(--color-text-tertiary);
  color: var(--color-text);
}

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

.top-contact-name {
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-contact-count {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.top-contact-bar {
  flex: 1;
  height: 8px;
  background: var(--color-bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.top-contact-bar-fill {
  height: 100%;
  background: var(--color-text);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Memory Stats */
.memory-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.memory-stat-item {
  text-align: center;
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: 4px;
}

.memory-stat-label {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.memory-stat-value {
  font-size: 28px;
  font-weight: 500;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

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

.stats-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

/* ============================================
   CONNECTION MODALS
   ============================================ */

.modal-compact {
  max-width: 420px;
}

.modal-body-center {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}

.modal-footer-center {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.modal-footer-center button {
  width: 100%;
}

.modal-title svg {
  margin-right: 8px;
  vertical-align: middle;
}

/* Status dots in header buttons */
.btn-status {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-status:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.btn-status .status-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  border: 2px solid var(--color-bg);
  transition: all var(--transition);
}

.btn-status .status-dot.connected {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.btn-status .status-dot.error {
  background: var(--color-error);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.btn-status .status-dot.waiting {
  background: var(--color-warning);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Success/Info backgrounds */
:root {
  --color-success-bg: #f0fdf4;
  --color-info-bg: #eff6ff;
}

[data-theme="dark"] {
  --color-success-bg: #14532d;
  --color-info-bg: #1e3a8a;
}

/* ============================================
   CONNECTION MODALS - WhatsApp & Telegram
   ============================================ */

.modal-connection {
  max-width: 400px;
  border-radius: 16px;
}

.modal-header-minimal {
  border-bottom: none;
  padding: var(--space-md) var(--space-lg);
  justify-content: flex-end;
}

.modal-footer-minimal {
  border-top: none;
  padding: var(--space-lg);
  gap: var(--space-sm);
}

/* Minimal Buttons */
.btn-minimal {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-minimal:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.btn-primary-minimal {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.btn-primary-minimal:hover {
  opacity: 0.85;
}

.btn-disconnect {
  color: var(--color-error);
  border-color: transparent;
}

.btn-disconnect:hover {
  border-color: var(--color-error);
}

/* Connection View */
.connection-view {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
}

.connection-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: var(--space-md);
  letter-spacing: 0.5px;
}

/* QR Display */
.qr-display {
  margin: 0 auto;
  display: inline-block;
}

.qr-image {
  width: 220px;
  height: 220px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #fff;
  padding: var(--space-sm);
}

[data-theme="dark"] .qr-image {
  background: var(--color-bg-secondary);
}

/* Pairing Code */
.pairing-code {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: 0.4em;
  color: var(--color-text);
  font-family: 'SF Mono', 'Courier New', monospace;
  margin: var(--space-xl) 0 var(--space-md);
}

/* Sync Animation */
.connection-sync-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
  position: relative;
}

.sync-device, .sync-cloud {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

.sync-lines {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sync-lines span {
  width: 8px;
  height: 1px;
  background: var(--color-text-secondary);
  opacity: 0.3;
  animation: syncPulse 1.5s ease-in-out infinite;
}

.sync-lines span:nth-child(1) { animation-delay: 0s; }
.sync-lines span:nth-child(2) { animation-delay: 0.2s; }
.sync-lines span:nth-child(3) { animation-delay: 0.4s; }

@keyframes syncPulse {
  0%, 100% { opacity: 0.2; transform: scaleX(1); }
  50% { opacity: 0.8; transform: scaleX(1.5); }
}

.sync-circle {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  opacity: 0.3;
  animation: syncCircle 3s ease-in-out infinite;
}

@keyframes syncCircle {
  0%, 100% { transform: scale(0.9); opacity: 0.2; }
  50% { transform: scale(1.1); opacity: 0.4; }
}

.connection-status-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.connection-ai-status {
  font-size: 11px;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Legacy Styles (kept for backwards compatibility) */
.connection-method-label {
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-lg);
}

/* Form Group */
.form-group {
  max-width: 340px;
  margin: var(--space-xl) auto;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  transition: all var(--transition);
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-text);
}

.form-input-code {
  text-align: center;
  font-size: 24px;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.5em;
  font-family: 'SF Mono', 'Courier New', monospace;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-top: var(--space-sm);
  line-height: 1.5;
}

/* Connection Success */
.connection-success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
}

.connection-success-title {
  font-size: 18px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.connection-success-phone {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-family: 'SF Mono', monospace;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn:hover {
  background: var(--color-bg-secondary);
}

.btn-primary {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.btn-primary:hover {
  background: var(--color-text-secondary);
  border-color: var(--color-text-secondary);
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg-secondary);
}

.btn-error {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}

.btn-error:hover {
  opacity: 0.9;
}
/* ============================================
   SUPPORT CHAT MODAL
   ============================================ */

.support-chat-modal {
  max-width: 500px;
  width: 90%;
  height: 70vh;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
}

.support-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0 !important;
}

.support-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
}

.support-message {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
}

.support-message-assistant .support-message-content {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px 16px 16px 4px;
  padding: var(--space-md);
  max-width: 85%;
  font-size: 14px;
  line-height: 1.6;
}

.support-message-user {
  align-items: flex-end;
}

.support-message-user .support-message-content {
  background: #000;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: var(--space-md);
  max-width: 85%;
  font-size: 14px;
  line-height: 1.6;
}

[data-theme="dark"] .support-message-user .support-message-content {
  background: #333;
  color: #fff;
}

.support-chat-input-area {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.support-chat-input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font-family);
  resize: none;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}

.support-chat-input:focus {
  outline: none;
  border-color: var(--color-text-tertiary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .support-chat-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.support-chat-input::placeholder {
  color: var(--color-text-tertiary);
}

#support-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

#support-send-btn:hover {
  transform: scale(1.05);
}

#support-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#support-send-btn svg {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] #support-send-btn {
  background: #fff;
  color: #000;
}

.support-message-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  max-width: 85%;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.support-loading-dots {
  display: flex;
  gap: 4px;
}

.support-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: supportDotPulse 1.4s infinite ease-in-out;
}

.support-loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.support-loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes supportDotPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

