/* ==================== IDEI-A Sales Tracker - Refined Minimal Theme ==================== */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #6366f1;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  
  --bg-main: #f8f9fa;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f4f4f5;
  --bg-hover: #e4e4e7;
  
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  
  --border-color: #e4e4e7;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  
  --sidebar-width: 260px;
  --header-height: 60px;
  
  --transition: all 0.15s ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

/* ==================== LOGIN ==================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-white);
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 320px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img {
  height: 48px;
  width: auto;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.5rem 0 0.25rem;
  letter-spacing: -0.025em;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

#login-form .form-group {
  margin-bottom: 1.25rem;
}

#login-form .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#login-form .form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

#login-form .form-group input:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

#login-form .form-group input::placeholder {
  color: var(--text-muted);
}

#login-form .btn-primary {
  width: auto;
  padding: 0.75rem 2rem;
}

.error-message {
  color: var(--danger);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.login-error {
  background: #fee2e2;
  color: #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* ==================== FORM ELEMENTS ==================== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

select.form-control {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

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

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}

/* ==================== LAYOUT ==================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-img {
  height: 28px;
  width: auto;
}

.logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.5rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

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

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1rem;
}

.user-details {
  flex: 1;
  min-width: 0;
}

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

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 1.25rem;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--bg-input);
  color: var(--danger);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.main-app {
  display: flex;
  min-height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==================== PAGE CONTENT ==================== */
#page-content {
  padding: 1.5rem;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

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

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

.stat-change {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ==================== TABLES ==================== */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th,
.table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-input);
}

.table tbody tr:hover {
  background: var(--bg-input);
}

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

/* ==================== BADGES ==================== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #cffafe; color: #0e7490; }

.badge-frio { background: #dbeafe; color: #1d4ed8; }
.badge-tibio { background: #fef3c7; color: #b45309; }
.badge-caliente { background: #fee2e2; color: #dc2626; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: 6px;
}

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

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-danger { background: #fee2e2; color: #dc2626; }
.alert-info { background: #cffafe; color: #0e7490; }

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.125rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ==================== LOADING ==================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.9375rem;
  animation: slideIn 0.2s ease;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info { background: var(--primary); color: white; }

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

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .header-title {
    font-size: 1rem;
  }
  
  #page-content {
    padding: 1rem;
  }
}

/* ==================== SCORECARD ==================== */
.scorecard {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.scorecard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.scorecard-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.scorecard-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 10px;
}

.score-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.score-value {
  font-weight: 600;
}

/* ==================== AUDIO PLAYER ==================== */
.audio-player {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.audio-player audio {
  flex: 1;
  height: 40px;
}

/* ==================== VIDEO CALL ==================== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.video-container {
  background: #1f2937;
  border-radius: var(--border-radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  position: relative;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
}

.control-btn.active {
  background: var(--primary);
  color: white;
}

.control-btn.inactive {
  background: var(--bg-input);
  color: var(--text-secondary);
}

.control-btn.danger {
  background: var(--danger);
  color: white;
}

/* ==================== CHAT ==================== */
.chat-container {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  height: 300px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-message {
  margin-bottom: 0.75rem;
}

.chat-message-user {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.8125rem;
}

.chat-message-text {
  background: var(--bg-input);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  display: inline-block;
  max-width: 80%;
  font-size: 0.9375rem;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

.chat-input input {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.9375rem;
  background: var(--bg-white);
}

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

/* ==================== MAP ==================== */
.map-container {
  background: var(--bg-input);
  border-radius: var(--border-radius);
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

#ubicaciones-map {
  height: 400px;
  border-radius: var(--border-radius);
  z-index: 1;
}

/* ==================== CHAT INTERNO - ESTILO WHATSAPP ==================== */

.chat-container-full {
  display: flex;
  height: calc(100vh - var(--header-height) - 3rem);
  background: var(--bg-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* Sidebar de conversaciones */
.chat-sidebar {
  width: 320px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
}

.chat-sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.chat-sidebar-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.chat-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.chat-search input {
  width: 100%;
  padding: 0.625rem 1rem;
  background: var(--bg-input);
  border: none;
  border-radius: 20px;
  font-size: 0.875rem;
}

.chat-search input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.chat-conversaciones {
  flex: 1;
  overflow-y: auto;
}

/* Items de conversación */
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border-color);
}

.chat-conv-item:hover {
  background: var(--bg-input);
}

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

.chat-conv-avatar {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.chat-conv-info {
  flex: 1;
  min-width: 0;
}

.chat-conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.chat-conv-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.chat-conv-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-conv-preview {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-badge {
  background: var(--primary);
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Área de chat */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
}

.chat-area-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
}

.btn-back-chat {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-secondary);
}

.chat-header-info {
  flex: 1;
}

.chat-header-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.typing-indicator {
  font-size: 0.75rem;
  color: var(--success);
  font-style: italic;
}

.typing-indicator.hidden {
  display: none;
}

/* Mensajes */
.chat-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chat-empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.chat-date-divider {
  text-align: center;
  margin: 1rem 0;
}

.chat-date-divider span {
  background: rgba(0, 0, 0, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Burbujas de mensaje */
.chat-msg {
  display: flex;
  margin-bottom: 0.25rem;
}

.chat-msg-mine {
  justify-content: flex-end;
}

.chat-msg-other {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 65%;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  position: relative;
}

.chat-msg-mine .chat-bubble {
  background: #dcf8c6;
  border-bottom-right-radius: 4px;
}

.chat-msg-other .chat-bubble {
  background: var(--bg-white);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.chat-bubble-text {
  font-size: 0.9375rem;
  line-height: 1.4;
  word-wrap: break-word;
  color: var(--text-primary);
}

.chat-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

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

.chat-bubble-status {
  font-size: 0.75rem;
  color: #53bdeb;
}

/* Input de mensaje */
.chat-input-area {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
}

.chat-input-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: none;
  border-radius: 24px;
  font-size: 0.9375rem;
}

.chat-input-area input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

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

.btn-send:hover {
  background: var(--primary-dark);
}

/* Badge de no leídos en menú */
.nav-item .chat-badge,
#menu-chat-badge {
  background: var(--danger);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  margin-left: 0.5rem;
}

#menu-chat-badge.hidden,
.chat-badge.hidden {
  display: none;
}

/* Status online/offline */
.status-online {
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
}

.status-offline {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-container-full {
    height: calc(100vh - 120px);
  }

  .chat-sidebar {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
  }

  .chat-area {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 20;
  }

  .chat-area.active {
    transform: translateX(0);
  }

  .btn-back-chat {
    display: block;
  }

  .chat-bubble {
    max-width: 85%;
  }
}

/* ==================== CHAT CLIENTES MEJORADO ==================== */

.chat-sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-sidebar-header .header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-sidebar-header h3 {
  margin: 0;
  font-size: 16px;
}

.estado-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  background: white;
}

.estado-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: #f3f4f6;
}

/* Respuestas Rápidas */
.respuestas-rapidas {
  padding: 10px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.respuestas-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.resp-rapida-btn {
  padding: 6px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 15px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.resp-rapida-btn:hover {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* Emoji Picker */
.emoji-picker {
  position: absolute;
  bottom: 60px;
  right: 50px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 200px;
  z-index: 100;
}

.emoji-item {
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  transition: background 0.2s;
}

.emoji-item:hover {
  background: #f3f4f6;
}

/* Modal Info Visitante */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.info-visitante-modal {
  background: white;
  padding: 25px;
  border-radius: 12px;
  min-width: 350px;
  max-width: 90%;
}

.info-visitante-modal h4 {
  margin: 0 0 15px 0;
  font-size: 18px;
}

.info-row {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.info-row:last-of-type {
  border-bottom: none;
  margin-bottom: 15px;
}

.info-row strong {
  color: #6b7280;
  margin-right: 8px;
}

/* Chat Input Area mejorado */
.chat-input-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  border-top: 1px solid #e5e7eb;
  background: white;
}

.chat-input-area input {
  flex: 1;
}

/* ==================== MODALES CHAT CLIENTES ====================*/

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  min-width: 350px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h4 {
  margin: 0 0 15px 0;
  font-size: 18px;
}

.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  margin: 10px 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 15px;
}

/* Agentes Lista */
.agentes-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 15px 0;
  max-height: 300px;
  overflow-y: auto;
}

.agente-item {
  padding: 12px 15px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.agente-item:hover {
  background: #f3f4f6;
}

.agente-item.selected {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* Etiquetas */
.etiquetas-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 15px 0;
}

.etiqueta-btn {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.etiqueta-btn:hover {
  border-color: #3b82f6;
}

.etiqueta-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* Nota interna en mensajes */
.chat-msg-nota {
  background: #fef3c7 !important;
  border-left: 3px solid #f59e0b;
  font-style: italic;
}

.chat-msg-nota::before {
  content: '📝 Nota interna: ';
  font-weight: 600;
}

/* ==================== ARCHIVOS EN CHAT ==================== */

.chat-imagen {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-imagen:hover {
  transform: scale(1.05);
}

.chat-archivo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
}

.chat-archivo:hover {
  background: rgba(255,255,255,0.3);
}

/* ==================== FILTROS CHAT CLIENTES ==================== */

.chat-filtros {
  display: flex;
  gap: 8px;
  padding: 10px 15px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.chat-filtros select {
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  background: white;
  cursor: pointer;
  min-width: 100px;
}

.chat-filtros select:focus {
  outline: none;
  border-color: #3b82f6;
}

.chat-filtros select:hover {
  border-color: #9ca3af;
}

/* ==================== MÉTRICAS CHAT ==================== */

.metricas-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.metricas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 15px;
}

.metricas-header h2 {
  margin: 0;
  font-size: 24px;
}

.metricas-filtros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metricas-filtros input,
.metricas-filtros select {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
}

.metricas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.metrica-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.metrica-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.metrica-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.metrica-value {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 5px;
}

.metrica-label {
  font-size: 13px;
  color: #6b7280;
}

.metricas-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.chart-section,
.table-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.chart-section h3,
.table-section h3 {
  margin: 0 0 20px 0;
  font-size: 16px;
  color: #374151;
}

.chart-container {
  height: 200px;
  display: flex;
  align-items: flex-end;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  width: 100%;
  height: 100%;
  gap: 10px;
}

.chart-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
}

.chart-bar {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 6px 6px 0 0;
  width: 100%;
  max-width: 50px;
  min-height: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: height 0.3s ease;
}

.chart-bar-value {
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding-top: 5px;
}

.chart-bar-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 8px;
  text-align: center;
}

.empty-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  color: #9ca3af;
  font-size: 14px;
}

/* Rating Distribution */
.rating-distribution {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rating-stars {
  font-size: 14px;
  color: #fbbf24;
  min-width: 80px;
}

.rating-bar-container {
  flex: 1;
  height: 20px;
  background: #f3f4f6;
  border-radius: 10px;
  overflow: hidden;
}

.rating-bar {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.rating-count {
  font-size: 14px;
  color: #6b7280;
  min-width: 30px;
  text-align: right;
}

/* Tables */
.metricas-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.metricas-table {
  width: 100%;
  border-collapse: collapse;
}

.metricas-table th,
.metricas-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
}

.metricas-table th {
  font-size: 12px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 600;
}

.metricas-table td {
  font-size: 14px;
}

.metricas-table tr:hover {
  background: #f9fafb;
}

/* Calificaciones Lista */
.calificaciones-lista {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 400px;
  overflow-y: auto;
}

.calificacion-item {
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 3px solid #fbbf24;
}

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

.calificacion-nombre {
  font-weight: 600;
  color: #1f2937;
}

.calificacion-estrellas {
  color: #fbbf24;
}

.calificacion-comentario {
  font-size: 14px;
  color: #4b5563;
  font-style: italic;
  margin: 8px 0;
}

.calificacion-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #9ca3af;
}

.empty-list {
  text-align: center;
  padding: 30px;
  color: #9ca3af;
}

@media (max-width: 768px) {
  .metricas-charts,
  .metricas-tables {
    grid-template-columns: 1fr;
  }
  
  .metricas-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
