/* ========================================
   VARIABLES DE DISEÑO MODERNO
   ======================================== */
:root {
  /* Paleta de colores principal */
  --primary: #00a89c;
  --primary-dark: #008075;
  --primary-light: #00c4b4;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  
  /* Colores neutros */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* Colores de fondo */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  
  /* Textos */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  /* Bordes y sombras */
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Bordes redondeados */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Espaciados */
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Tipografía */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ========================================
   ESTILOS GLOBALES
   ======================================== */
body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ========================================
   NAVEGACIÓN
   ======================================== */
.navbar {
  background: var(--bg-primary) !important;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 0;
  backdrop-filter: blur(10px);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary) !important;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.2s ease;
}

.navbar-brand:hover {
  transform: translateY(-2px);
}

.navbar .nav-link {
  color: var(--text-secondary) !important;
  font-weight: 500;
  padding: 0.4rem 0.8rem !important;
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  position: relative;
  font-size: 0.9rem;
}

.navbar .nav-link:hover {
  color: var(--primary) !important;
  background: var(--gray-100);
}

.navbar .nav-link.active {
  color: var(--primary) !important;
  background: var(--gray-100);
  font-weight: 600;
}

.navbar .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* User Profile Dropdown */
.user-profile-dropdown {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--gray-100);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  color: var(--text-primary);
}

.user-profile-btn:hover {
  background: var(--gray-200);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
}

.user-info-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 280px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 1000;
  padding: 1rem;
}

.user-info-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-info-dropdown .dropdown-header {
  padding: 0.75rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.user-info-dropdown .dropdown-header h6 {
  margin: 0;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-info-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.user-info-item:last-child {
  margin-bottom: 0;
}

.user-info-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-info-content {
  flex: 1;
}

.user-info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.user-info-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 600;
  word-break: break-all;
}

.user-info-dropdown .logout-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: none;
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.user-info-dropdown .logout-btn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Dropdown divider & action buttons */
.user-info-dropdown .dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.75rem 0;
}

.user-info-dropdown .dropdown-action-btn {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-color);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 0.9rem;
}

.user-info-dropdown .dropdown-action-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--primary);
  color: var(--primary);
}

/* ========================================
   BOTONES
   ======================================== */
.btn {
  border-radius: var(--radius-md);
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  transition: all 0.3s ease;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn-outline-primary {
  border: 2px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.btn-outline-secondary {
  border: 2px solid var(--gray-300);
  color: var(--text-secondary);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.btn-outline-danger {
  border: 2px solid var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ========================================
   TARJETAS (CARDS)
   ======================================== */
.card {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.card-header {
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 1.5rem;
}

.card-title {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-size: 1.125rem;
}

/* ========================================
   TABLAS
   ======================================== */
.table-responsive {
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
  box-shadow: var(--shadow-md);
  background: var(--bg-primary);
  position: relative;
}

.table {
  margin-bottom: 0;
}

.table thead {
  background: var(--bg-primary);
}

.table thead th {
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.65rem 0.75rem;
  border: none;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-primary);
  box-shadow: 0 1px 0 var(--border-color), 0 2px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

.table tbody td {
  padding: 0.6rem 0.75rem;
  vertical-align: middle;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  line-height: 1.3;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background: var(--gray-50);
  transform: scale(1.01);
}

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

.table-bordered {
  border: none;
}

.table-bordered td,
.table-bordered th {
  border-left: none !important;
  border-right: none !important;
}

/* ========================================
   FORMULARIOS
   ======================================== */
.form-control,
.form-select {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
}

.form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-control-sm,
.form-select-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

textarea.form-control {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00a89c 0%, #008075 100%);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: moveBackground 20s linear infinite;
}

@keyframes moveBackground {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

.login-card {
  max-width: 420px;
  width: 100%;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
}

.login-title {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, #008075 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

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

/* ========================================
   LOADING STATES
   ======================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.loading-overlay .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
  color: var(--primary);
}

.loading-text {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-weight: 600;
}

#loadingIndicator {
  text-align: center;
  padding: 3rem;
}

#loadingIndicator .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
  color: var(--primary);
}

/* ========================================
   BADGES Y ESTADOS
   ======================================== */
.badge {
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.7rem;
}

.badge-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.badge-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.badge-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #f59e0b 100%);
}

/* ========================================
   COLLAPSIBLE CONTENT
   ======================================== */
.collapsible-content {
  max-height: 200px;
  overflow-y: auto;
  background: var(--gray-50);
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.collapsible-content::-webkit-scrollbar {
  width: 8px;
}

.collapsible-content::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

.collapsible-content::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

.collapsible-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

.btn-toggle {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
}

/* ========================================
   TRUNCATE TEXT
   ======================================== */
.truncate-text {
  max-height: 100px;
  overflow: hidden;
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--gray-50);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

.truncate-text.show-full {
  max-height: none;
}

.truncate-toggle {
  display: inline-block;
  cursor: pointer;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: color 0.2s ease;
}

.truncate-toggle:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ========================================
   CARD MODE (Mobile)
   ======================================== */
.card-mode {
  display: none;
}

.card-metric {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.card-metric:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-metric h5 {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 1rem;
  font-size: 1.125rem;
}

.card-metric p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.card-metric strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ========================================
   GRÁFICOS
   ======================================== */
.chart-container {
  position: relative;
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.chart-container-small {
  position: relative;
  max-width: 300px;
  margin: 0 auto;
  padding: 1.5rem;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.chart-wrapper {
  position: relative;
  height: 400px;
}

/* Gráficos compactos y modernos para home */
.chart-card-compact {
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.chart-card-compact:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.chart-card-compact .card-body {
  padding: 1.25rem;
}

.chart-title-compact {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-wrapper-compact {
  position: relative;
  height: 220px;
  width: 100%;
}

.chart-wrapper-compact canvas {
  max-height: 220px;
}

.summary-total {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

/* ========================================
   PAGINACIÓN
   ======================================== */
.pagination {
  gap: 0.5rem;
}

.pagination .page-item {
  margin: 0;
}

.pagination .page-link {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
}

.pagination .page-link:hover {
  background: var(--gray-100);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}

/* ========================================
   ALERTS Y MENSAJES
   ======================================== */
.alert {
  border-radius: var(--radius-lg);
  border: none;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
}

.alert-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}

.alert-info {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
}

/* ========================================
   UTILIDADES
   ======================================== */
.text-muted {
  color: var(--text-muted) !important;
}

.shadow-sm {
  box-shadow: var(--shadow-sm) !important;
}

.shadow-md {
  box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .table-mode {
    display: none;
  }
  
  .card-mode {
    display: block;
  }
  
  .table-responsive {
    display: none !important;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .login-card {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .chart-container {
    padding: 1rem;
  }
  
  .summary-total {
    font-size: 1.25rem;
    padding: 1rem;
  }
}

@media (min-width: 769px) {
  .card-view {
    display: none !important;
  }
}

/* ========================================
   ANIMACIONES
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

.slide-in {
  animation: slideIn 0.5s ease-out;
}

/* ========================================
   SCROLLBAR PERSONALIZADO
   ======================================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 6px;
  border: 2px solid var(--gray-100);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ========================================
   ESTADOS DE HOVER
   ======================================== */
.hover-lift {
  transition: all 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ========================================
   ESTILOS ESPECÍFICOS - EXECUTIONS
   ======================================== */
.download-link {
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s ease;
}

.download-link:hover {
  color: var(--primary-dark);
}

#logContent pre {
  max-height: 400px;
  overflow-y: auto;
  background-color: var(--gray-50);
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: var(--font-mono);
}

#logsModal .modal-header h5,
#logsModal .modal-body h6,
#logsModal #currentFileName {
  color: var(--text-primary) !important;
  font-weight: 600;
}

#logsModal .modal-body {
  color: var(--text-primary);
}

#logsModal .list-group-item {
  color: var(--text-primary) !important;
  transition: all 0.2s ease;
}

.log-file-item:hover {
  background-color: var(--gray-100);
  transform: translateX(4px);
}

.modal-xl {
  max-width: 90vw;
}

#logsModal .col-12.col-md-8 {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#logsModal #logContent {
  flex: 1;
  min-height: 200px;
}

/* Responsive para modales y táctil en móvil */
@media (max-width: 768px) {
  .log-file-item {
    padding: 0.75rem 1rem !important;
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
  }
  
  .log-file-item:active {
    background-color: var(--gray-200) !important;
    transform: scale(0.98);
    transition: all 0.1s ease;
  }
  
  .btn:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
  }

  .modal-xl {
    max-width: 98vw;
    margin: 0.5rem;
    max-height: 95vh;
  }
  
  #logsModal .modal-dialog {
    height: 95vh;
    max-height: 95vh;
    margin: 0.5rem auto;
  }
  
  #logsModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  #logsModal .modal-body {
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  #logsModal .modal-body .row {
    height: 100%;
  }
  
  #logsModal .col-12.col-md-8 {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  
  #logsModal #logContent {
    flex: 1;
    min-height: 200px;
  }
  
  #logsModal .modal-header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1rem 0.5rem;
  }
  
  #logsModal .modal-header .d-flex.align-items-center.flex-grow-1 {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  #logsModal .modal-title {
    font-size: 1.1rem;
    margin-right: 0 !important;
  }
  
  #logsModal #operationIdBadge {
    font-size: 0.7rem !important;
    padding: 4px 8px !important;
    word-break: break-all;
    max-width: calc(100vw - 6rem);
    overflow: hidden;
  }
  
  #logsModal #operationIdText {
    font-size: 0.7rem !important;
    display: inline-block;
    max-width: calc(100% - 2rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }
  
  #logsModal .modal-body .row {
    --bs-gutter-x: 0;
  }
  
  #logsModal .modal-body .col-md-4,
  #logsModal .modal-body .col-md-8 {
    padding: 0.5rem;
  }
  
  #logsModal .col-md-4 {
    margin-bottom: 1rem;
  }
  
  #logsModal #logFilesList {
    max-height: 200px !important;
  }
  
  #logsModal #logContent {
    max-height: 300px !important;
    font-size: 0.85rem;
    padding: 10px !important;
  }
  
  #logsModal .modal-footer {
    padding: 0.75rem 1rem;
  }
  
  #logsModal .btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
  }
  
  #logsModal #logFilesList,
  #logsModal #logContent {
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   STATS CARDS (HOME PAGE)
   ======================================== */
.stats-card {
  border: none;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  border-radius: var(--radius-lg);
}

.stats-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.stats-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border-radius: var(--radius-lg);
  color: white;
}

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

.stats-value {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.stats-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  font-weight: 500;
}

/* ========================================
   ICONOS PROFESIONALES
   ======================================== */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.icon-lg {
  width: 32px;
  height: 32px;
}

.icon-xl {
  width: 48px;
  height: 48px;
}

.navbar-brand .icon {
  width: 24px;
  height: 24px;
}

.action-card-icon {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border-radius: var(--radius-lg);
  color: white;
  margin-bottom: 1rem;
}

.action-card-icon svg {
  width: 32px;
  height: 32px;
}

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

/* Top Bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(135deg, #00a89c 0%, #008075 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1030;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.brand-logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
}

.top-bar-brand svg {
  flex-shrink: 0;
}

.brand-text {
  white-space: nowrap;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: 280px;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 1020;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.25rem;
  color: #4a5568;
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
  gap: 1rem;
  white-space: nowrap;
}

.sidebar-item:hover {
  background-color: #e8eaed;
  color: #2d3748;
}

.sidebar-item.active {
  background-color: #e0f7f5;
  color: #00a89c;
  border-left: 3px solid #00a89c;
}

.sidebar-item.active .sidebar-icon {
  color: #00a89c;
}

.sidebar-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.sidebar-text {
  font-size: 0.95rem;
  font-weight: 500;
  transition: opacity 0.3s;
}

.sidebar.collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 0.875rem 0;
}

/* Sidebar Admin Section */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: 1rem 1rem;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem;
  margin-top: 0.5rem;
}

.sidebar.collapsed .sidebar-divider {
  margin: 1rem 0.5rem;
}

.sidebar.collapsed .sidebar-section-title {
  display: none;
}

/* Body with Sidebar */
body.has-sidebar {
  margin-left: 280px;
  margin-top: 60px;
  transition: margin-left 0.3s ease;
}

body.has-sidebar.sidebar-collapsed {
  margin-left: 70px;
}

/* User Profile en Top Bar */
.top-bar .user-profile-dropdown {
  margin-left: auto;
}

.top-bar .user-profile-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.top-bar .user-profile-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.top-bar .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.top-bar .user-info-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 280px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1050;
}

.top-bar .user-info-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar:not(.collapsed) {
    transform: translateX(0);
  }
  
  body.has-sidebar {
    margin-left: 0 !important;
  }
  
  .brand-text {
    display: none;
  }
  
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
}

@media (max-width: 576px) {
  .top-bar {
    padding: 0 1rem;
  }
  
  .top-bar-brand {
    font-size: 0.95rem;
  }
  
  .user-profile-btn span {
    display: none !important;
  }
}

/* ========================================
   STICKY TABLE HEADERS ENHANCEMENT
   ======================================== */
/* Contenedor con scroll propio para las tablas */
.table-responsive {
  position: relative;
}

/* Aprovechar todo el ancho disponible */
body.has-sidebar .container {
  max-width: 100%;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Eliminar el efecto visual de contenido pasando */
.table thead::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: var(--bg-primary);
  z-index: -1;
}

/* ========================================
   MINI METRICS CHART
   ======================================== */
.metric-total-box {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-md);
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
}

.metric-total-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.metric-total-text {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
  font-weight: 600;
}

.metric-summary-mini {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
  height: 80px;
  display: flex;
  align-items: center;
  position: relative;
}

.metric-summary-mini canvas {
  width: 100% !important;
  height: 100% !important;
}

