:root {
  --color-primary: #3B82F6;
  --color-primary-rgb: 59, 130, 246;
  --color-primary-dark: #2563EB;
  --color-primary-darker: #1D4ED8;
  --color-secondary: #6C3BFF;
  --color-secondary-rgb: 108, 59, 255;
  --color-secondary-dark: #5B21B6;
  --color-secondary-light: #DDD6FE;
  --color-success: #10B981;
  --color-success-dark: #059669;
  --color-success-rgb: 16, 185, 129;
  --color-warning: #F59E0B;
  --color-warning-rgb: 245, 158, 11;
  --color-danger: #EF4444;
  --color-danger-rgb: 239, 68, 68;
  --color-border-light: #E2E8F0;
  --color-progress-bg: #E2E8F0;
  --color-card-border: #E2E8F0;
  --color-bg: #F8FAFC;
  --color-bg-dark: #1E293B;
  --color-surface: #FFFFFF;
  --color-surface-dark: #0F172A;
  --color-background: var(--color-bg);
  --color-background-secondary: var(--color-bg);
  --color-text-primary: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted: #94A3B8;
  --color-shadow-sm: rgba(0, 0, 0, 0.06);
  --color-shadow-md: rgba(0, 0, 0, 0.10);
  --color-shadow-lg: rgba(0, 0, 0, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --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-color: var(--color-bg);
  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;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 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 ===== */
.theme-gamer {
  --color-primary: #10B981; --color-primary-rgb: 16,185,129;
  --color-primary-dark: #059669; --color-primary-darker: #047857;
  --color-secondary: #3BD1FF; --color-secondary-rgb: 59,209,255;
  --color-secondary-dark: #0EA5E9; --color-secondary-light: #BAF3FF;
  --color-border-light: #E2E8F0; --color-progress-bg: #D1FAE5;
  --color-bg: #F8FAFC; --color-bg-dark: #1E293B;
  --color-surface: #FFFFFF; --color-surface-dark: #0F172A;
}
.theme-urban-tech {
  --color-primary: #3B82F6; --color-primary-rgb: 59,130,246;
  --color-primary-dark: #2563EB; --color-primary-darker: #1D4ED8;
  --color-secondary: #6C3BFF; --color-secondary-rgb: 108,59,255;
  --color-secondary-dark: #5B21B6; --color-secondary-light: #DDD6FE;
  --color-border-light: #E2E8F0; --color-progress-bg: #DBEAFE;
  --color-bg: #F8FAFC; --color-bg-dark: #1E293B;
  --color-surface: #FFFFFF; --color-surface-dark: #0F172A;
}
.theme-minimal-clean {
  --color-primary: #1E293B; --color-primary-rgb: 30,41,59;
  --color-primary-dark: #0F172A; --color-primary-darker: #020617;
  --color-secondary: #3B82F6; --color-secondary-rgb: 59,130,246;
  --color-secondary-dark: #2563EB; --color-secondary-light: #DBEAFE;
  --color-border-light: #E2E8F0; --color-progress-bg: #E2E8F0;
  --color-bg: #F9FAFB; --color-bg-dark: #0F172A;
  --color-surface: #FFFFFF; --color-surface-dark: #1E293B;
}
.theme-mystic {
  --color-primary: #8B5CF6; --color-primary-rgb: 139,92,246;
  --color-primary-dark: #7C3AED; --color-primary-darker: #6D28D9;
  --color-secondary: #2DD4BF; --color-secondary-rgb: 45,212,191;
  --color-secondary-dark: #14B8A6; --color-secondary-light: #CCFBF1;
  --color-border-light: #E2E8F0; --color-progress-bg: #EDE9FE;
  --color-bg: #F8FAFC; --color-bg-dark: #1E293B;
  --color-surface: #FFFFFF; --color-surface-dark: #0F172A;
}
.theme-wine {
  --color-primary: #BE123C; --color-primary-rgb: 190,18,60;
  --color-primary-dark: #9F1239; --color-primary-darker: #881337;
  --color-secondary: #E11D48; --color-secondary-rgb: 225,29,72;
  --color-secondary-dark: #BE123C; --color-secondary-light: #FFE4E6;
  --color-border-light: #E2E8F0; --color-progress-bg: #FFE4E6;
  --color-bg: #F8FAFC; --color-bg-dark: #1E293B;
  --color-surface: #FFFFFF; --color-surface-dark: #0F172A;
}

.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-border-light);
  box-shadow: 0 1px 3px var(--color-shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--color-shadow-md);
  border-color: var(--color-primary);
}
.card:active {
  transform: translateY(0);
}
.card-sm {
  border-radius: var(--radius-md);
}
.card-lg {
  border-radius: var(--radius-lg);
}

.card-header {
  background: var(--color-bg);
  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: 700;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(var(--color-primary-rgb), 0.4);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.4);
}
.btn-outline-primary {
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  background: transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  padding: 0.55rem 1.3rem;
  transition: all 0.2s ease;
}
.btn-outline-primary:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px 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;
}

/* ===== HEADER GLASS ===== */
.header-glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 8px var(--color-shadow-sm);
  border-bottom: none !important;
}
body.dark .header-glass,
body.dark-mode .header-glass {
  background: rgba(15, 23, 42, 0.85);
}

/* Logo en color primario */
header[role="banner"] > div > a:first-child {
  color: var(--color-primary);
  transition: color 0.2s;
}
header[role="banner"] > div > a:first-child:hover {
  color: var(--color-primary-dark);
}

/* Botones y links de accion en color texto (negro light, gris dark) */
header[role="banner"] nav button,
header[role="banner"] nav a,
header[role="banner"] > div > a:not(:first-child) {
  color: var(--color-text-primary);
  transition: opacity 0.2s;
}
header[role="banner"] nav button:hover,
header[role="banner"] nav a:hover,
header[role="banner"] > div > a:not(:first-child):hover {
  opacity: 0.65;
}
body.dark header[role="banner"] nav button,
body.dark-mode header[role="banner"] nav button,
body.dark header[role="banner"] nav a,
body.dark-mode header[role="banner"] nav a,
body.dark header[role="banner"] > div > a:not(:first-child),
body.dark-mode header[role="banner"] > div > a:not(:first-child) {
  color: #d1d5db;
}

/* ===== BOTTOM NAV GLASS ===== */
.bottom-nav-glass {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: none !important;
}
body.dark .bottom-nav-glass,
body.dark-mode .bottom-nav-glass {
  background: rgba(26, 26, 46, 0.9);
}
.bottom-nav-glass a {
  color: var(--color-text-primary);
  opacity: 0.6;
  transition: opacity 0.2s;
}
.bottom-nav-glass a:hover,
.bottom-nav-glass a[aria-current="page"] {
  opacity: 1;
}
body.dark .bottom-nav-glass a,
body.dark-mode .bottom-nav-glass a {
  color: #d1d5db;
}

/* ===== STAT WIDGET ===== */
.stat-widget {
  background: linear-gradient(135deg, var(--color-surface) 0%, rgba(var(--color-primary-rgb), 0.08) 100%);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px var(--color-shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.stat-widget:hover {
  border-color: var(--color-secondary);
  box-shadow: 0 2px 8px var(--color-shadow-md);
}
body.dark .stat-widget,
body.dark-mode .stat-widget {
  background: linear-gradient(135deg, var(--color-surface-dark) 0%, rgba(var(--color-primary-rgb), 0.15) 100%);
  border-color: #1E293B;
}

.stat-widget .font-bold {
  font-weight: 900;
}

/* ===== FEED CARD ===== */
.feed-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  transition: box-shadow 0.2s;
}
body.dark .feed-card,
body.dark-mode .feed-card {
  background: var(--color-surface-dark);
  border-color: #1E293B;
}

.feed-card .font-bold,
.feed-card h4,
.feed-card h5 {
  color: var(--color-text-primary);
}

.feed-card svg.text-gray-600,
.feed-card .text-gray-600 svg {
  color: var(--color-text-secondary);
}

/* ===== STAT WIDGET ICONS ===== */
.stat-widget svg {
  color: var(--color-text-primary);
}
body.dark .stat-widget svg,
body.dark-mode .stat-widget svg {
  color: #d1d5db;
}

/* ===== EMPTY STATE ICONS ===== */
.text-center.py-12 > svg:first-child,
.text-center.py-8 > svg:first-child,
.text-center.py-5 > svg:first-child,
.text-center.py-4 > svg:first-child {
  padding: 0.75rem;
  border-radius: 9999px;
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-primary) !important;
  margin-bottom: 0.5rem;
  box-sizing: content-box;
}

/* ===== BACK BUTTON ICONS ===== */
a.inline-flex.items-center.gap-2 > svg {
  color: var(--color-primary);
}

/* ===== UPLOAD LABEL ICONS ===== */
label svg {
  color: var(--color-primary);
}

@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, body.dark-mode {
  background: var(--color-bg-dark);
  color: #E2E8F0;
}

body.dark h1, body.dark h2, body.dark h3, body.dark h4, body.dark h5, body.dark h6,
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 {
  color: #F1F5F9;
}

body.dark .nav-link:hover, body.dark-mode .nav-link:hover {
  color: #F1F5F9;
}

body.dark .card, body.dark-mode .card {
  background: var(--color-surface-dark);
  border: 1px solid #1E293B;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
body.dark .card:hover, body.dark-mode .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border-color: var(--color-primary);
}

body.dark-mode .card-header {
  background: #1a1a2e;
  border-bottom: 1px solid #1E293B;
  color: #F1F5F9;
}

body.dark-mode .card-footer {
  background: #1a1a2e;
  border-top: 1px solid #1E293B;
  color: #E2E8F0;
}

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

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

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

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

body.dark-mode .modal-content {
  background: var(--color-surface-dark);
  color: #E2E8F0;
}

body.dark-mode .btn-outline-secondary {
  color: #94A3B8;
  border-color: #334155;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
  background: #1a1a2e;
  border-color: #334155;
  color: #E2E8F0;
}

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

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

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

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

body.dark-mode .nav-tabs .nav-link.active {
  color: var(--color-primary);
}

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

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

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

/* ============ BOTTOM NAVIGATION ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--color-surface);
  box-shadow: 0 -1px 8px var(--color-shadow-sm);
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1px solid var(--color-border-light);
}
body.dark .bottom-nav,
body.dark-mode .bottom-nav {
  background: var(--color-surface-dark);
  border-top-color: #1e293b;
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 0.6rem;
  color: var(--color-text-muted);
  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(--color-primary);
  border-top-color: var(--color-secondary);
}

.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 .bottom-nav, body.dark-mode .bottom-nav {
  background: #16213e;
  border-top-color: #0f3460;
  box-shadow: 0 -2px 16px rgba(var(--color-primary-rgb), 0.15);
}
body.dark-mode .bottom-nav .nav-item {
  color: #5c5c7a;
}
body.dark-mode .bottom-nav .nav-item.active {
  color: #00e5ff;
  border-top-color: #00e5ff;
}

/* ============ 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: #00e5ff;
}

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

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

/* ============ 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;
}
