:root {
  --color-primary: #0095da;
  --color-primary-rgb: 0, 149, 218;
  --color-primary-dark: #007bb5;
  --color-primary-darker: #006699;
  --color-success: #80c342;
  --color-success-dark: #6ab32e;
  --color-success-rgb: 128, 195, 66;
  --color-warning: #fcb116;
  --color-warning-rgb: 252, 177, 22;
  --color-danger: #ea1c24;
  --color-danger-rgb: 234, 28, 36;
  --color-border-light: #e8f4fd;
  --color-progress-bg: #e8f4fd;
  --color-card-border: #e8e8e8;
  --color-background: #ffffff;
  --color-background-secondary: #f8f9fa;
  --color-text-primary: #212529;
  --color-text-secondary: #6c757d;
  --color-text-muted: #adb5bd;
  --color-shadow-sm: rgba(0, 0, 0, 0.08);
  --color-shadow-md: rgba(0, 0, 0, 0.12);
  --color-shadow-lg: rgba(0, 0, 0, 0.16);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 50rem;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  --bs-primary: var(--color-primary);
  --bs-primary-rgb: var(--color-primary-rgb);
  --bs-success: var(--color-success);
  --bs-success-rgb: var(--color-success-rgb);
  --bs-info: var(--color-primary);
  --bs-warning: var(--color-warning);
  --bs-warning-rgb: var(--color-warning-rgb);
  --bs-danger: var(--color-danger);
  --bs-danger-rgb: var(--color-danger-rgb);
}

/* Tipografía mejorada */
body {
  background: var(--color-background);
  min-height: 100vh;
  font-family: 'Nunito', 'Century Gothic', system-ui, -apple-system, sans-serif;
  color: var(--color-text-primary);
  line-height: 1.6;
  font-size: 1rem;
  font-weight: 400;
}

/* Jerarquía tipográfica mejorada */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
  margin-top: 0;
  margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

.display-4 { font-size: 2.5rem; font-weight: 800; }
.display-5 { font-size: 2rem; font-weight: 800; }
.display-6 { font-size: 1.75rem; font-weight: 800; }

.lead {
  font-size: 1.25rem;
  font-weight: 500;
}

/* ===== TEMAS DE COLOR MEJORADOS ===== */
.theme-azul {
  --color-primary: #0095da; --color-primary-rgb: 0,149,218;
  --color-primary-dark: #007bb5; --color-primary-darker: #006699;
  --color-border-light: #e8f4fd; --color-progress-bg: #e8f4fd;
}
.theme-verde {
  --color-primary: #2c5f2d; --color-primary-rgb: 44,95,45;
  --color-primary-dark: #1b5e20; --color-primary-darker: #0d3b0e;
  --color-border-light: #e8f5e9; --color-progress-bg: #e8f5e9;
}
.theme-rojo {
  --color-primary: #c62828; --color-primary-rgb: 198,40,40;
  --color-primary-dark: #b71c1c; --color-primary-darker: #8e0000;
  --color-border-light: #ffebee; --color-progress-bg: #ffebee;
}
.theme-amarillo {
  --color-primary: #f9a825; --color-primary-rgb: 249,168,37;
  --color-primary-dark: #f57f17; --color-primary-darker: #e65100;
  --color-border-light: #fff8e1; --color-progress-bg: #fff8e1;
}
.theme-rosa {
  --color-primary: #e91e63; --color-primary-rgb: 233,30,99;
  --color-primary-dark: #c2185b; --color-primary-darker: #880e4f;
  --color-border-light: #fce4ec; --color-progress-bg: #fce4ec;
}
.theme-purpura {
  --color-primary: #7b1fa2; --color-primary-rgb: 123,31,162;
  --color-primary-dark: #6a1b9a; --color-primary-darker: #4a148c;
  --color-border-light: #f3e5f5; --color-progress-bg: #f3e5f5;
}

/* Nuevos temas premium */
.theme-indigo {
  --color-primary: #3f51b5; --color-primary-rgb: 63,81,181;
  --color-primary-dark: #283593; --color-primary-darker: #1a237e;
  --color-border-light: #e8eaf6; --color-progress-bg: #e8eaf6;
}
.theme-teal {
  --color-primary: #009688; --color-primary-rgb: 0,150,136;
  --color-primary-dark: #00695c; --color-primary-darker: #004d40;
  --color-border-light: #e0f2f1; --color-progress-bg: #e0f2f1;
}
.theme-amber {
  --color-primary: #ffc107; --color-primary-rgb: 255,193,7;
  --color-primary-dark: #ffb300; --color-primary-darker: #ffa000;
  --color-border-light: #fff8e1; --color-progress-bg: #fff8e1;
}

/* ===== TEMAS DE COLOR ===== */
.theme-azul {
  --color-primary: #0095da; --color-primary-rgb: 0,149,218;
  --color-primary-dark: #007bb5; --color-primary-darker: #006699;
  --color-border-light: #e8f4fd; --color-progress-bg: #e8f4fd;
}
.theme-verde {
  --color-primary: #2c5f2d; --color-primary-rgb: 44,95,45;
  --color-primary-dark: #1b5e20; --color-primary-darker: #0d3b0e;
  --color-border-light: #e8f5e9; --color-progress-bg: #e8f5e9;
}
.theme-rojo {
  --color-primary: #c62828; --color-primary-rgb: 198,40,40;
  --color-primary-dark: #b71c1c; --color-primary-darker: #8e0000;
  --color-border-light: #ffebee; --color-progress-bg: #ffebee;
}
.theme-amarillo {
  --color-primary: #f9a825; --color-primary-rgb: 249,168,37;
  --color-primary-dark: #f57f17; --color-primary-darker: #e65100;
  --color-border-light: #fff8e1; --color-progress-bg: #fff8e1;
}
.theme-rosa {
  --color-primary: #e91e63; --color-primary-rgb: 233,30,99;
  --color-primary-dark: #c2185b; --color-primary-darker: #880e4f;
  --color-border-light: #fce4ec; --color-progress-bg: #fce4ec;
}
.theme-purpura {
  --color-primary: #7b1fa2; --color-primary-rgb: 123,31,162;
  --color-primary-dark: #6a1b9a; --color-primary-darker: #4a148c;
  --color-border-light: #f3e5f5; --color-progress-bg: #f3e5f5;
}

body {
  background: var(--color-background);
  min-height: 100vh;
  font-family: 'Nunito', 'Century Gothic', system-ui, -apple-system, sans-serif;
  color: var(--color-text-primary);
  line-height: 1.6;
  font-size: 1rem;
  font-weight: 400;
}

/* Jerarquía tipográfica mejorada */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
  margin-top: 0;
  margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

.display-4 { font-size: 2.5rem; font-weight: 800; }
.display-5 { font-size: 2rem; font-weight: 800; }
.display-6 { font-size: 1.75rem; font-weight: 800; }

.lead {
  font-size: 1.25rem;
  font-weight: 500;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.5px;
}

.navbar-dark.bg-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)) !important;
}

.card {
  border: 1px solid var(--color-card-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-background);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
  border-color: var(--color-border-light);
}
.card:active {
  transform: translateY(0);
}
.card-sm {
  border-radius: var(--radius-md);
}
.card-lg {
  border-radius: var(--radius-lg);
}

.card-header {
  background: var(--color-background-secondary);
  border-bottom: 1px solid var(--color-border-light);
  font-weight: 700;
  padding: 1rem 1.5rem;
  border-top-left-radius: calc(var(--radius-lg) - 1px);
  border-top-right-radius: calc(var(--radius-lg) - 1px);
}
.card-header:first-child {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.card-header h5, .card-header h4, .card-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.card-header .btn-sm {
  margin-top: -0.25rem;
}

.progress {
  background: var(--color-progress-bg);
  border-radius: 10px;
}
.progress-bar {
  border-radius: 10px;
  transition: width 0.5s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  font-weight: 600;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary-darker));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: all 0.6s;
}
.btn-primary:hover::before {
  left: 100%;
}
.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
}
.btn-outline-primary {
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
  transition: all var(--transition-normal);
}
.btn-outline-primary:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3);
}
.btn-outline-primary:active {
  transform: translateY(0);
}
.btn-outline-primary:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-success), var(--color-success-dark));
  border: none;
  font-weight: 600;
}

a.text-decoration-none:hover .card {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.alert {
  border: none;
  border-radius: 12px;
}

.badge {
  font-weight: 600;
  padding: 0.5em 0.8em;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}
.badge:hover {
  transform: scale(1.05);
}
.badge-sm {
  font-size: 0.7rem;
  padding: 0.3em 0.6em;
}
.badge-lg {
  font-size: 1rem;
  padding: 0.7em 1.2em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  font-weight: 500;
  color: var(--color-text-secondary);
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  border-color: var(--color-border-light);
  transform: translateY(-1px);
}

.nav-link.active {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.2);
}

.nav-link.active:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.nav-link:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
  outline: none;
}

.nav-link i {
  font-size: 1.1rem;
  min-width: 1.5rem;
  text-align: center;
}
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  border-color: var(--color-border-light);
  transform: translateY(-1px);
}

.nav-link.active {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.2);
}

.nav-link.active:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.nav-link:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.25);
  outline: none;
}

.nav-link i {
  font-size: 1.1rem;
  min-width: 1.5rem;
  text-align: center;
}

.nav-tabs .nav-link {
  color: #495057;
  border: none;
  padding: 0.5rem 1rem;
}
.nav-tabs .nav-link.active {
  color: var(--bs-primary);
  border-bottom: 3px solid var(--bs-primary);
  background: transparent;
}

.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

#mensajesContainer {
  scroll-behavior: smooth;
}

@media (max-width: 768px) {
  .navbar-nav .nav-link {
    padding: 0.4rem 0.8rem;
  }
  .card-body {
    padding: 1rem;
  }
}

.table th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
  border-width: 2px;
}

.opacity-50 {
  transition: opacity 0.3s;
}
.opacity-50:hover {
  opacity: 0.8;
}

.dark-mode-toggle {
  cursor: pointer;
  user-select: none;
}

body.dark-mode {
  background: #1a1a2e;
  color: #e0e0e0;
}

body.dark-mode .card {
  background: #16213e;
  border-color: #0f3460;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-mode .card-header {
  border-bottom-color: #0f3460;
  color: #e0e0e0;
}

body.dark-mode .card-footer {
  background: #16213e;
  border-top-color: #0f3460;
}

body.dark-mode .text-muted {
  color: #a0a0b0 !important;
}

body.dark-mode .bg-light {
  background: #1a1a2e !important;
}

body.dark-mode .table {
  color: #e0e0e0;
}

body.dark-mode .table th {
  color: #a0a0b0;
}

body.dark-mode .modal-content {
  background: #16213e;
  color: #e0e0e0;
}

body.dark-mode .btn-outline-secondary {
  color: #a0a0b0;
  border-color: #0f3460;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
  background: #1a1a2e;
  border-color: #0f3460;
  color: #e0e0e0;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background: #1a1a2e;
  color: #e0e0e0;
}

body.dark-mode .progress {
  background: #0f3460;
}

body.dark-mode .border-bottom {
  border-bottom-color: #0f3460 !important;
}

body.dark-mode .nav-tabs .nav-link {
  color: #a0a0b0;
}

body.dark-mode .nav-tabs .nav-link.active {
  color: #0095da;
}

body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) {
  background: rgba(255,255,255,0.03);
}

body.dark-mode .alert-success {
  background: #6ab32e;
  color: #ffffff;
}

body.dark-mode .alert-danger {
  background: #ea1c24;
  color: #ffffff;
}

/* ============ BOTTOM NAVIGATION ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1px solid #e8f4fd;
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 0.6rem;
  color: #9e9e9e;
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.2s;
  border-top: 2px solid transparent;
}

.bottom-nav .nav-item i {
  font-size: 1.35rem;
  line-height: 1;
}

.bottom-nav .nav-item span {
  font-size: 0.6rem;
  line-height: 1.2;
}

.bottom-nav .nav-item.active {
  color: var(--bs-primary);
  border-top-color: var(--bs-primary);
}

.bottom-nav .nav-item.active i {
  font-weight: 900;
}

body.has-bottom-nav {
  padding-bottom: 72px;
}

/* ============ RESPONSIVE MOBILE-FIRST ============ */
@media (max-width: 991.98px) {
  .bottom-nav { display: flex; }

  .navbar .navbar-collapse .navbar-nav.me-auto {
    display: none !important;
  }

  /* Header mas compacto */
  .navbar {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }
  .navbar-brand {
    font-size: 1.1rem;
  }
  .navbar .nav-link {
    padding: 0.3rem 0.5rem;
  }

  body {
    font-size: 14px;
    overflow-x: hidden;
  }

  .card {
    margin-bottom: 0.5rem;
  }
  .card-body {
    padding: 0.75rem;
  }
  .card-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
  .card-header h5 {
    font-size: 0.95rem;
  }

  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  h4 { font-size: 1rem; }
  h5 { font-size: 0.9rem; }

  .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
  }

  .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }
  .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
  }

  .table {
    font-size: 0.78rem;
  }
  .table th {
    font-size: 0.7rem;
  }

  canvas { max-height: 150px; }

  .modal-dialog {
    margin: 0.5rem;
  }

  .progress {
    height: 6px !important;
  }

  .badge {
    font-size: 0.65rem;
  }

  .row.g-3 {
    --bs-gutter-y: 0.5rem;
    --bs-gutter-x: 0.5rem;
  }
  .row.g-2 {
    --bs-gutter-y: 0.35rem;
    --bs-gutter-x: 0.35rem;
  }

  .alert {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .nav-tabs .nav-link {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
  }

  select.form-select {
    font-size: 0.85rem;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }

  iframe {
    max-height: 200px;
  }

  .table-responsive {
    font-size: 0.78rem;
  }
  .table-responsive table {
    min-width: 500px;
  }

  .navbar-nav .dropdown-menu {
    position: absolute !important;
  }
}

@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0;
    min-height: 100vh;
  }
  .modal-content {
    border-radius: 0;
    min-height: 100vh;
  }

  h2 { font-size: 1.15rem; }

  .bottom-nav {
    height: 54px;
  }
  .bottom-nav .nav-item i {
    font-size: 1.2rem;
  }
  .bottom-nav .nav-item span {
    font-size: 0.55rem;
  }

  body.has-bottom-nav {
    padding-bottom: 66px;
  }
}

@media (min-width: 992px) {
  .bottom-nav { display: none !important; }
  body.has-bottom-nav { padding-bottom: 0; }
}

/* ============ DARK MODE BOTTOM NAV ============ */
body.dark-mode .bottom-nav {
  background: #16213e;
  border-top-color: #0f3460;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
}
body.dark-mode .bottom-nav .nav-item {
  color: #5c5c7a;
}
body.dark-mode .bottom-nav .nav-item.active {
  color: #0095da;
  border-top-color: #0095da;
}

/* ============ CHAT INTERFACE ============ */
.chat-list {
  display: flex;
  flex-direction: column;
}

.chat-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bs-primary);
  padding: 8px 12px 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #e8f4fd;
  transition: background 0.15s;
}
.chat-item:hover, .chat-item.active {
  background: #e8f4fd;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 1.2rem;
}

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

.chat-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.chat-active {
  max-width: 700px;
  margin: 0 auto;
}

/* Arbol organizacional */
.tree-node {
  font-size: 0.85rem;
}
.tree-node details {
  margin-left: 1rem;
}
.tree-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  list-style: none;
}
.tree-summary::-webkit-details-marker {
  display: none;
}
.tree-summary::before {
  content: '▶';
  font-size: 0.6rem;
  color: #888;
  transition: transform 0.15s;
}
details[open] > .tree-summary::before {
  transform: rotate(90deg);
}
.tree-summary:hover {
  background: #e8f4fd;
}
.tree-summary .tree-icon {
  font-size: 1rem;
}
.tree-summary .tree-name {
  flex: 1;
  font-weight: 600;
}
.tree-children {
  border-left: 2px solid #dee2e6;
  margin-left: 0.6rem;
}
body.dark-mode .tree-summary:hover {
  background: #2a3a4a;
}
body.dark-mode .tree-children {
  border-left-color: #3a4a5a;
}
.tree-usuario-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.tree-usuario-item:hover {
  background: #e8f4fd;
}
body.dark-mode .tree-usuario-item:hover {
  background: #2a3a4a;
}

.chat-messages {
  max-height: 60vh;
  min-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f0f2f5;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message-own {
  align-self: flex-end;
  align-items: flex-end;
}

.message-other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.message-own .message-bubble {
  background: var(--bs-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-other .message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.65rem;
  color: #999;
  margin-top: 2px;
}

.card-footer form {
  background: white;
}

@media (max-width: 576px) {
  .chat-messages {
    max-height: 50vh;
    min-height: 250px;
  }
  .chat-avatar {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .message-bubble {
    font-size: 0.85rem;
    padding: 6px 10px;
  }
}

body.dark-mode .chat-messages {
  background: #1a1a2e;
  border-color: #2a2a4a;
}

.chat-box {
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
}

.chat-box .bg-primary {
  background-color: var(--primary-color) !important;
  border-radius: 12px 12px 4px 12px;
}

.chat-box .bg-light {
  background-color: #f0f2f5 !important;
  border-radius: 12px 12px 12px 4px;
}

body.dark-mode .chat-box .bg-light {
  background-color: #2a2a4a !important;
  color: #e0e0e0;
}

body.dark-mode .message-other .message-bubble {
  background: #16213e;
  color: #e0e0e0;
}

body.dark-mode .chat-item:hover, body.dark-mode .chat-item.active {
  background: #0f3460;
}

body.dark-mode .chat-item {
  border-bottom-color: #0f3460;
}

body.dark-mode .card-footer form {
  background: #16213e;
}

body.dark-mode .chat-section-label {
  color: #0095da;
}

/* ============ INVITACIONES ============ */
.invitacion-card {
  border-left: 4px solid var(--bs-primary);
}

/* ============ AMIGOS ============ */
.friend-request-card {
  border-left: 4px solid #f9a825;
}

/* ============ SIDEBAR GRUPOS ============ */
@media (min-width: 768px) {
  .chat-sidebar {
    border-right: 1px solid #e8f4fd;
    max-height: 70vh;
    overflow-y: auto;
  }
  .chat-main {
    max-height: 70vh;
    display: flex;
    flex-direction: column;
  }
  .chat-main .chat-messages {
    flex: 1;
  }
}

@media (max-width: 767.98px) {
  .chat-sidebar {
    max-height: 40vh;
    overflow-y: auto;
  }
}

body.dark-mode .chat-sidebar {
  border-right-color: #0f3460;
}
