/* ==========================================================================
   XCORP / XPYME DESIGN SYSTEM v1.2.0
   Central de Comunicaciones (PRY-135)
   Arquitectura de Tokens de 3 Niveles (Global, Semántico, Componente)
   ========================================================================== */

:root {
  /* --------------------------------------------------------------------------
     NIVEL 1: TOKENS GLOBALES (Primitivos)
     -------------------------------------------------------------------------- */
  
  /* 1.1 Escala Teal (Primario Oficial XCORP / XPYME) */
  --color-teal-50: #E0F7FA;
  --color-teal-100: #B2EBF2;
  --color-teal-200: #80DEEA;
  --color-teal-300: #4DD0E1;
  --color-teal-400: #26C6DA;
  --color-teal-500: #00BCD4;
  --color-teal-600: #00ACC1;
  --color-teal-700: #0097A7; /* Base oficial */
  --color-teal-800: #00838F;
  --color-teal-900: #006064;

  /* 1.2 Escala Slate (Secundario Oficial) */
  --color-slate-50: #ECEFF1;
  --color-slate-100: #CFD8DC;
  --color-slate-200: #B0BEC5;
  --color-slate-300: #90A4AE;
  --color-slate-400: #78909C;
  --color-slate-500: #607D8B;
  --color-slate-600: #546E7A;
  --color-slate-700: #455A64;
  --color-slate-800: #37474F;
  --color-slate-900: #263238;

  /* 1.3 Escala Neutros & Grises */
  --color-gray-50: #F8F9FA;
  --color-gray-100: #F1F3F5;
  --color-gray-200: #E9ECEF;
  --color-gray-300: #DEE2E6;
  --color-gray-400: #CED4DA;
  --color-gray-500: #ADB5BD;
  --color-gray-600: #868E96;
  --color-gray-700: #495057;
  --color-gray-800: #343A40;
  --color-gray-900: #212529;

  /* 1.4 Feedback & Estados */
  --color-green-500: #28A745;
  --color-green-600: #218838;
  --color-red-500: #DC3545;
  --color-red-600: #C82333;
  --color-yellow-500: #FFC107;
  --color-yellow-600: #E0A800;
  --color-blue-500: #17A2B8;
  --color-white: #FFFFFF;

  /* 1.5 Espaciado (Sistema 8pt Canónico) */
  --size-4: 4px;
  --size-8: 8px;
  --size-12: 12px;
  --size-16: 16px;
  --size-20: 20px;
  --size-24: 24px;
  --size-32: 32px;
  --size-48: 48px;
  --size-64: 64px;
  --base-container: 1440px;

  /* 1.6 Tipografía Inter */
  --font-family-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-12: 0.75rem;
  --font-size-14: 0.875rem;
  --font-size-16: 1rem;
  --font-size-18: 1.125rem;
  --font-size-20: 1.25rem;
  --font-size-24: 1.5rem;
  --font-size-32: 2rem;

  /* 1.7 Sombras & Elevaciones */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.22);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.35);

  /* 1.8 Radios */
  --radius-none: 0px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* --------------------------------------------------------------------------
     NIVEL 2: TOKENS SEMÁNTICOS (Alias / Tema Pro)
     -------------------------------------------------------------------------- */
  
  --color-primary-base: var(--color-teal-700);
  --color-primary-hover: var(--color-teal-600);
  --color-primary-light: rgba(0, 151, 167, 0.15);
  --color-primary-border: rgba(0, 151, 167, 0.4);

  --color-secondary-base: var(--color-slate-800);
  --color-secondary-hover: var(--color-slate-900);

  --color-success: var(--color-green-500);
  --color-error: var(--color-red-500);
  --color-warning: var(--color-yellow-500);
  --color-info: var(--color-blue-500);

  /* Superficies para Alta Densidad y Consistencia Operativa */
  --surface-app: #0a0f1d;
  --surface-header: #0f172a;
  --surface-main: #131d31;
  --surface-card: #182238;
  --surface-card-hover: #1e2b45;
  --surface-input: #0f172a;
  --surface-overlay: rgba(10, 15, 29, 0.85);

  --border-subtle: #223049;
  --border-strong: #334464;
  --border-focus: var(--color-teal-500);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --text-brand: var(--color-teal-400);

  --state-focus-ring: 0 0 0 3px rgba(0, 151, 167, 0.35);

  /* Espaciado Semántico */
  --space-xs: var(--size-4);
  --space-sm: var(--size-8);
  --space-md: var(--size-12);
  --space-lg: var(--size-16);
  --space-xl: var(--size-24);
  --space-2xl: var(--size-32);
  --space-3xl: var(--size-48);
  --space-4xl: var(--size-64);

  /* --------------------------------------------------------------------------
     NIVEL 3: TOKENS DE COMPONENTE
     -------------------------------------------------------------------------- */
  --btn-padding-y: 9px;
  --btn-padding-x: 18px;
  --btn-radius: var(--radius-md);
  --input-padding: 10px 14px;
  --input-radius: var(--radius-md);
  --card-radius: var(--radius-lg);
  --card-shadow: var(--shadow-md);
}

/* ==========================================================================
   RESET & ESTILOS BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family-main);
  background-color: var(--surface-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: var(--font-size-14);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Scrollbar Corporativo */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--surface-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-teal-700);
}

/* ==========================================================================
   HEADER CORPORATIVO OFICIAL
   ========================================================================== */
.app-header {
  background-color: var(--surface-header);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.xcorp-official-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  transition: transform 0.2s ease;
}

.xcorp-official-logo:hover {
  transform: scale(1.02);
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title h1 {
  font-size: var(--font-size-18);
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  letter-spacing: -0.01em;
}

.brand-title h1 .highlight {
  color: var(--color-teal-400);
  font-weight: 700;
}

.brand-title h1 .version-badge {
  font-size: 11px;
  font-weight: 600;
  background-color: var(--color-primary-light);
  color: var(--color-teal-300);
  border: 1px solid var(--color-primary-border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

.brand-title .subtitle {
  font-size: var(--font-size-12);
  color: var(--text-muted);
  font-weight: 400;
}

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

.status-pills {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  padding: 5px 11px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.pill:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-green-500);
  box-shadow: 0 0 6px var(--color-green-500);
}

/* ==========================================================================
   NAVEGACIÓN (TABS OFICIALES XCORP)
   ========================================================================== */
.app-nav {
  background-color: var(--surface-main);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--space-xl);
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family-main);
  font-size: var(--font-size-14);
  font-weight: 500;
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  color: var(--color-teal-400);
  border-bottom-color: var(--color-teal-500);
  font-weight: 600;
}

.nav-tab svg {
  width: 17px;
  height: 17px;
}

.nav-counter {
  font-size: 11px;
  font-weight: 600;
  background-color: var(--surface-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.nav-tab.active .nav-counter {
  background-color: var(--color-teal-900);
  color: var(--color-teal-200);
  border-color: var(--color-teal-700);
}

/* ==========================================================================
   MAIN CONTENT & LAYOUTS
   ========================================================================== */
.main-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.15s ease-out;
}

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

/* ==========================================================================
   BOTONES & ELEMENTOS INTERACTIVOS (NIVEL 3)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--btn-padding-y) var(--btn-padding-x);
  border-radius: var(--btn-radius);
  font-family: var(--font-family-main);
  font-size: var(--font-size-14);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--state-focus-ring);
}

.btn-primary {
  background-color: var(--color-teal-700);
  color: var(--color-white);
  border-color: var(--color-teal-600);
}

.btn-primary:hover {
  background-color: var(--color-teal-600);
  border-color: var(--color-teal-500);
}

.btn-secondary {
  background-color: var(--surface-card);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background-color: var(--surface-card-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background-color: rgba(220, 53, 69, 0.15);
  color: #ff6b6b;
  border-color: rgba(220, 53, 69, 0.4);
}

.btn-danger:hover {
  background-color: rgba(220, 53, 69, 0.3);
  border-color: var(--color-red-500);
}

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

/* ==========================================================================
   CARDS, PANELES & TABLAS (ATOMIC DESIGN)
   ========================================================================== */
.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-header {
  padding: var(--space-md) var(--space-lg);
  background-color: var(--surface-main);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--font-size-16);
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

/* Form Inputs */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-size-12);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--input-padding);
  background-color: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--input-radius);
  color: var(--text-main);
  font-family: var(--font-family-main);
  font-size: var(--font-size-14);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--state-focus-ring);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--color-gray-600);
}

/* ==========================================================================
   BADGES & PILLS SEMÁNTICOS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-teal {
  background-color: var(--color-primary-light);
  color: var(--color-teal-300);
  border: 1px solid var(--color-primary-border);
}

.badge-sentiment-positivo, .badge-success {
  background-color: rgba(40, 167, 69, 0.15);
  color: #4ade80;
  border: 1px solid rgba(40, 167, 69, 0.35);
}

.badge-sentiment-friccion, .badge-danger {
  background-color: rgba(220, 53, 69, 0.15);
  color: #f87171;
  border: 1px solid rgba(220, 53, 69, 0.35);
}

.badge-sentiment-neutro, .badge-warning {
  background-color: rgba(255, 193, 7, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.badge-collaborator {
  background-color: rgba(144, 164, 174, 0.15);
  color: var(--color-slate-200);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   CHAT LAYOUT & BURBUJAS (OMNICANAL)
   ========================================================================== */
.chat-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: var(--space-lg);
  height: calc(100vh - 180px);
  min-height: 600px;
}

.chat-sidebar {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-search-bar {
  padding: var(--space-md);
  background-color: var(--surface-main);
  border-bottom: 1px solid var(--border-subtle);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs);
}

.chat-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  cursor: pointer;
  display: flex;
  gap: var(--space-md);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chat-item:hover {
  background-color: var(--surface-card-hover);
}

.chat-item.active {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary-border);
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: var(--color-slate-800);
  color: var(--color-teal-300);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-14);
  flex-shrink: 0;
}

.chat-item-body {
  flex: 1;
  min-width: 0;
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.chat-item-title {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-item-snippet {
  font-size: var(--font-size-12);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel Principal de Chat */
.chat-main {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: var(--space-md) var(--space-lg);
  background-color: var(--surface-main);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background-color: var(--surface-app);
}

.message-bubble {
  max-width: 72%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  position: relative;
  box-shadow: var(--shadow-sm);
  font-size: var(--font-size-14);
  flex-shrink: 0;
  min-height: fit-content;
}

.message-bubble.incoming {
  align-self: flex-start;
  background-color: var(--surface-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-sm);
}

.message-bubble.outgoing {
  align-self: flex-end;
  background-color: var(--color-teal-700);
  color: var(--color-white);
  border-bottom-right-radius: var(--radius-sm);
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.message-bubble.outgoing.pending-outgoing {
  opacity: 0.88;
}

.message-bubble.outgoing.pending-outgoing .bubble-status {
  opacity: 0.7;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  font-size: 11px;
  color: var(--text-muted);
}

.message-bubble.outgoing .message-meta {
  color: var(--color-teal-100);
}

/* Copilot Suggestion Box */
.copilot-box {
  padding: var(--space-md) var(--space-lg);
  background-color: var(--surface-main);
  border-top: 1px solid var(--border-subtle);
  border-left: 3px solid var(--color-teal-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

/* ==========================================================================
   TABLAS CORPORATIVAS & DIRECTORIO
   ========================================================================== */
.table-container {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background-color: var(--surface-main);
  color: var(--text-muted);
  font-size: var(--font-size-12);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: var(--font-size-14);
}

.data-table tbody tr:hover {
  background-color: var(--surface-card-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   KPIs & AUDITORÍA SLA
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.kpi-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--color-primary-light);
  color: var(--color-teal-400);
  border: 1px solid var(--color-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.kpi-info .kpi-label {
  font-size: var(--font-size-12);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.kpi-info .kpi-value {
  font-size: var(--font-size-24);
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   MODALES (ATOMIC DESIGN)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface-overlay);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.modal-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--card-radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: var(--font-size-16);
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-18);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

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

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

/* Phone Cards */
.phone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.phone-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: var(--space-lg);
  border-top: 3px solid var(--color-teal-500);
}

.phone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.phone-title {
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.phone-meta {
  background-color: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-12);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.phone-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ==========================================================================
   ANIMATIONS & MODAL QR CODE UTILITIES
   ========================================================================== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 151, 167, 0.2);
  border-top-color: var(--color-teal-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

#modal-qr-container {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
}

#modal-qr-img {
  image-rendering: pixelated;
}

/* ==========================================================================
   ORDENAMIENTO Y GRUPOS POR NÚMERO WHATSAPP DE COLABORADOR
   ========================================================================== */
.badge-phone {
  background-color: rgba(0, 151, 167, 0.18);
  color: var(--color-teal-300);
  border: 1px solid rgba(0, 151, 167, 0.4);
  font-family: var(--font-family-mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-phone i {
  width: 12px;
  height: 12px;
}

.colab-group-header {
  padding: 8px 12px;
  margin: 10px 4px 6px 4px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.75) 100%);
  border: 1px solid rgba(0, 151, 167, 0.25);
  border-left: 3px solid var(--color-teal-400);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.colab-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.colab-phone-pill {
  font-weight: 700;
  font-size: 11.5px;
  color: var(--color-teal-300);
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-family-mono, monospace);
}

.colab-name-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.colab-badge-count {
  font-size: 10px;
  font-weight: 700;
  background-color: var(--color-slate-800);
  color: var(--color-slate-300);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-item-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  gap: 4px;
}

.chat-item-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ==========================================================================
   MODULO CORREOS CORPORATIVOS (PRY-135)
   ========================================================================== */
.email-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--surface-header);
  border-bottom: 1px solid var(--border-subtle);
}

.filter-pills-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-pill {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--surface-main);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  border-color: var(--color-teal-500);
  color: var(--text-main);
}

.filter-pill.active {
  background-color: var(--color-teal-500);
  color: #FFFFFF;
  border-color: var(--color-teal-400);
}

.email-thread-stream {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.email-message-card {
  background-color: var(--surface-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
  min-height: fit-content;
  height: auto;
  width: 100%;
}

.email-message-card.from-me {
  border-left: 4px solid var(--color-teal-400);
}

.email-message-card.from-client {
  border-left: 4px solid var(--color-slate-400);
}

.email-card-header {
  padding: 14px 18px;
  background-color: rgba(30, 41, 59, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.email-card-sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.email-card-body-content {
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  word-break: break-word;
  overflow-wrap: break-word;
  min-height: auto;
  height: auto;
}

.email-view-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background-color: var(--surface-header);
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
}

.email-html-container {
  background-color: #FFFFFF;
  color: #0F172A;
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
}

.email-composer-area {
  padding: 14px 20px;
  background-color: var(--surface-header);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.email-composer-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 220px;
  padding: 10px 14px;
  background-color: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
}

.email-composer-textarea:focus {
  outline: none;
  border-color: var(--color-teal-400);
  box-shadow: 0 0 0 2px rgba(0, 151, 167, 0.2);
}

.email-composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.spinning {
  animation: spin 1s linear infinite;
}

/* Force High Specificity for Email Composer & Cards */
.tab-pane#tab-emails .email-composer-area {
  padding: 14px 20px;
  background-color: var(--surface-header);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tab-pane#tab-emails .email-composer-textarea {
  width: 100% !important;
  min-height: 85px !important;
  max-height: 220px !important;
  padding: 12px 14px !important;
  background-color: var(--surface-input) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-main) !important;
  font-family: var(--font-family-main) !important;
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  resize: vertical !important;
  box-sizing: border-box !important;
  display: block !important;
}

.tab-pane#tab-emails .email-composer-textarea:focus {
  outline: none !important;
  border-color: var(--color-teal-400) !important;
  box-shadow: 0 0 0 2px rgba(0, 151, 167, 0.25) !important;
}

.tab-pane#tab-emails .email-composer-actions {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 10px !important;
  flex-wrap: wrap !important;
}

/* Force High Specificity for Email Thread Cards & Stream (PRY-135 / Bug #9829) */
.tab-pane#tab-emails .email-thread-stream {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  padding: 20px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

.tab-pane#tab-emails .email-message-card {
  flex-shrink: 0 !important;
  min-height: fit-content !important;
  height: auto !important;
  width: 100% !important;
  display: block !important;
}

.tab-pane#tab-emails .email-card-body-content {
  min-height: auto !important;
  height: auto !important;
  display: block !important;
}

.tab-pane#tab-emails .email-card-body-content > div[id^="email-text-"] {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  min-height: auto !important;
  height: auto !important;
  line-height: 1.6 !important;
}

/* ==========================================================================
   GOOGLE BUSINESS PROFILE REVIEWS TAB (PRY-135 / SNC #311108)
   ========================================================================== */
.google-reviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.google-review-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.google-review-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.google-stars {
  color: #f59e0b;
  letter-spacing: 2px;
  font-size: 14px;
}

.google-official-reply {
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid var(--color-teal-400);
  border-radius: 6px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 13px;
}

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

.spin {
  animation: spin 1s linear infinite;
}
