/* =========================================
   VARIABLES GLOBALES
========================================= */
:root {
  /* Paleta principal (Mezcla de la versión moderna y la intensa) */
  --primary: #2b6fe0; /* #5b2be0;  */
  --primary-alt: #0065e1; 
  --primary-light: #f3f4fe;
  --secondary: #4cc9f0;
  
  /* Tonos neutros */
  --dark: #1e1e2f;
  --light: #f8f9fa;
  --gray: #8d99ae;
  --gray-light: #e2e8f0;
  --bg-color: #f4f6f9;

  /* Estados */
  --success: #10b981;  /* verde esmeralda */
  --warning: #f59e0b;  /* ámbar */
  --danger: #ef4444;   /* rojo intenso */

  /* Dimensiones */
  --sidebar-width: 260px;
  --sidebar-collapsed: 80px;
}

/* =========================================
   RESET Y BASE
========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  display: none;
  background-color: var(--bg-color);
  color: var(--dark);
  overflow-x: hidden;
}

/* =========================================
   LAYOUT PRINCIPAL
========================================= */
.dashboard, 
.dashboard-layout {
  display: flex;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(145deg, #ffffff, #f8faff);
}

/* =========================================
   SIDEBAR
========================================= */
.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--gray-light);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.03);
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  height: 80px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-light);
}

.logo-grande {
  width: 180px;
  transform-origin: left center;
  transition: opacity 0.3s, width 0.3s;
}

.sidebar.collapsed .logo-grande {
  opacity: 0;
  width: 0;
  display: none;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.toggle-btn:hover {
  color: var(--primary);
}

.sidebar-user {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--gray-light);
}

.sidebar.collapsed .user-info {
  display: none;
}

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

.menu-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--gray);
  font-weight: 600;
  margin: 0 1.5rem 1rem;
}

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

.menu-item {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  color: var(--gray);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  cursor: pointer;
}

.menu-item i {
  font-size: 1.2rem;
  width: 25px;
  text-align: center;
  margin-right: 1rem;
}

.menu-item .menu-text {
  white-space: nowrap;
  transition: opacity 0.3s;
}

.sidebar.collapsed .menu-item .menu-text {
  opacity: 0;
  display: none;
}

.menu-item:hover, 
.menu-item.active {
  color: var(--primary);
  background-color: rgba(91, 43, 224, 0.05);
  border-right: 4px solid var(--primary);
  font-weight: 600;
}

.menu-item.logout:hover {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.05);
  border-right: 4px solid var(--danger);
}

.sidebar-footer {
  padding-bottom: 1rem;
  border-top: 1px solid var(--gray-light);
}

/* =========================================
   MAIN CONTENT & HEADER
========================================= */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fb 100%);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #fff;
  border-radius: 16px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -0.5px;
}

.header h1::after {
  content: "";
  display: block;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, #00a3ff, #007bff);
  border-radius: 2px;
  margin-top: 8px;
}

.user-profile {
  display: flex;
  align-items: center;
}

.user-profile img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.user-info h4 { font-size: 0.9rem; font-weight: 600; color: var(--dark); margin: 0; }
.user-info p { font-size: 0.75rem; color: var(--gray); margin: 0; }

/* Botones */
.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-alt));
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(91, 43, 224, 0.2);
}

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

.stat-card {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.08);
}

.stat-card:hover::before { opacity: 1; }

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

.stat-title {
  color: var(--gray);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-header i {
  font-size: 1.5rem;
  padding: 10px;
  border-radius: 12px;
  background: rgba(91, 43, 224, 0.1);
  color: var(--primary);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--primary), var(--primary-alt));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-change { font-size: 0.75rem; display: flex; align-items: center; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

.stat-card.placeholder {
  background: transparent;
  border: 2px dashed var(--gray-light);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray);
}

.stat-card.placeholder:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(91, 43, 224, 0.02);
}

/* =========================================
   TABLAS (Unificadas)
========================================= */
.companies-container,
.table-container {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow-x: auto;
}

.table-header,
.table-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-header h3 { font-weight: 600; color: var(--dark); }

.search-bar,
.table-search {
  display: flex;
  align-items: center;
  background: var(--gray-light);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  min-width: 300px;
  transition: box-shadow 0.3s ease;
}

.search-bar:focus-within,
.table-search:focus-within {
  box-shadow: 0 0 0 2px rgba(91, 43, 224, 0.2);
  background: #ffffff;
}

.search-bar input,
.table-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  margin-left: 0.5rem;
  font-size: 0.9rem;
  color: var(--dark);
}

table,
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
.modern-table th {
  text-align: left;
  padding: 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--gray);
  font-weight: 600;
  border-bottom: 2px solid var(--gray-light);
  background: #fafbfc;
}

th:first-child, .modern-table th:first-child { border-top-left-radius: 8px; }
th:last-child, .modern-table th:last-child { border-top-right-radius: 8px; }

td,
.modern-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-light);
  font-size: 0.9rem;
  color: var(--dark);
  vertical-align: middle;
  transition: background 0.2s ease;
}

tbody tr:hover td,
.modern-table tbody tr:hover td {
  background-color: rgba(91, 43, 224, 0.02);
}

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

/* Elementos de tabla específicos */
.company-info { display: flex; align-items: center; }

.company-logo {
  width: 45px;
  height: 45px;
  min-width: 45px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2394ff, #0037ff);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  margin-right: 0.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.company-name h4 { font-weight: 600; margin-bottom: 0.25rem; color: var(--dark); }
.company-name p { font-size: 0.75rem; color: var(--gray); }

.status-badge {
  padding: 0.4rem 0.9rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.status-badge.active { background: #e6f7ee; color: #00a854; }
.status-badge.inactive { background: #feeceb; color: #f5222d; }

.action-btn {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.action-btn:hover {
  background: linear-gradient(90deg, var(--primary), var(--primary-alt)); 
  color: #fff;
}

/* Paginación */
.pagination-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 1.5rem;
  gap: 0.5rem;
}

.pagination-btn {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--gray-light);
  background: #ffffff;
  color: var(--gray);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--gray-light);
  color: var(--dark);
}

.pagination-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================
   MODALES
========================================= */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.modal.active { opacity: 1; pointer-events: all; }

.modal-content {
  background: #fff;
  border-radius: 20px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.modal.active .modal-content { transform: translateY(0); }

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

.modal-header h3 { font-weight: 600; color: var(--dark); }

.modal-close {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--gray); transition: all 0.2s ease;
}

.modal-close:hover { color: var(--primary); }
.modal-body { padding: 1.5rem; }







/* =========================================
   ALERTAS PERSONALIZADAS (VERSIÓN PREMIUM)
========================================= */
.custom-alert-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  backdrop-filter: blur(6px); /* Efecto cristal más pronunciado */
  background-color: rgba(30, 30, 47, 0.5); /* Tono oscuro adaptado a var(--dark) */
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-alert-overlay.active { opacity: 1; pointer-events: all; }

.custom-alert-box {
  background: #ffffff; 
  border-radius: 24px; /* Más curvo, como las modales modernas */
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255,255,255,0.5) inset;
  width: 90%; max-width: 420px; 
  padding: 40px 30px;
  text-align: center; 
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Animación de rebote */
}

.custom-alert-overlay.active .custom-alert-box { transform: translateY(0) scale(1); }

.custom-alert-icon {
  width: 75px; height: 75px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px auto; 
  position: relative;
}

/* Animación de halo para el ícono */
.custom-alert-icon::after {
  content: '';
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 50%;
  z-index: -1;
  animation: pulseIcon 2s infinite;
}

@keyframes pulseIcon {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Estilos de Íconos contextuales */
.custom-alert-icon.success { color: var(--success); background: rgba(16, 185, 129, 0.15); }
.custom-alert-icon.success::after { background: var(--success); }

.custom-alert-icon.error { color: var(--danger); background: rgba(239, 68, 68, 0.15); }
.custom-alert-icon.error::after { background: var(--danger); }

.custom-alert-icon.warning { color: var(--warning); background: rgba(245, 158, 11, 0.15); }
.custom-alert-icon.warning::after { background: var(--warning); }

.custom-alert-title { 
  font-size: 1.5rem; font-weight: 700; color: var(--dark); 
  margin-bottom: 12px; letter-spacing: -0.5px; 
}

.custom-alert-message { 
  font-size: 0.95rem; color: var(--gray); 
  margin-bottom: 30px; line-height: 1.6; 
}

.custom-alert-actions { display: flex; justify-content: center; gap: 12px; }

.custom-alert-actions .btn {
  min-width: 120px; padding: 0.8rem 1.5rem; border-radius: 12px;
  font-weight: 600; cursor: pointer; transition: all 0.3s ease;
  border: none; font-size: 0.95rem; display: flex; align-items: center; justify-content: center;
}

/* Botón primario heredando tu gradiente global */
.custom-alert-actions .btn-primary { 
  background: linear-gradient(90deg, var(--primary), var(--primary-alt)); 
  color: #fff; 
  box-shadow: 0 4px 15px rgba(91, 43, 224, 0.2);
}
.custom-alert-actions .btn-primary:hover { 
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(91, 43, 224, 0.3); 
}

/* Botón destructivo (para eliminar) */
.custom-alert-actions .btn-danger { 
  background: var(--danger); 
  color: #fff; 
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}
.custom-alert-actions .btn-danger:hover { 
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3); 
}

.custom-alert-actions .btn-outline { 
  background: transparent; border: 2px solid var(--gray-light); color: var(--gray); 
}
.custom-alert-actions .btn-outline:hover { 
  background: var(--gray-light); color: var(--dark); border-color: var(--gray);
}




/* =========================================
   LOADER / SPINNER (VIDRIADO)
========================================= */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Fondo oscuro traslúcido adaptado a var(--dark) */
  background-color: rgba(30, 30, 47, 0.4); 
  /* Efecto vidriado (frosted glass) */
  backdrop-filter: blur(8px); 
  -webkit-backdrop-filter: blur(8px); /* Soporte para Safari */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000; /* Un nivel por encima de las alertas si es necesario */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Clase para mostrar el loader */
.loader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loader-spinner {
  width: 80px;
  height: 80px;
  border: 5px solid var(--gray-light); /* Color de fondo del círculo */
  border-top: 5px solid var(--secondary); /* Color celeste de carga */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Animación de rotación */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}