/* === VARIABLES GLOBALES === */
:root {
  --color-bg: #f5f7fb;
  --color-white: #ffffff;
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-text: #111827;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --transition: 0.3s ease;
  font-family: 'Inter', sans-serif;
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* === LOGIN === */
/* === LOGIN === */
.login-body-light {
  background: var(--color-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh; /* antes height: 100vh → cambia a min-height */
  padding: 20px 0;   /* evita que se pegue a los bordes */
}

.login-container-light {
  background: var(--color-white);
  width: 380px;
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === LOGO Y MARCA === */
.login-logo {
  width: 160px;
  height: auto;
  margin-bottom: 12px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--color-text);
  margin-bottom: 4px;
}

.brand-subtitle {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* === FORMULARIO === */
.input-group {
  text-align: left;
  margin-bottom: 20px;
  width: 100%;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  font-size: 1rem;
  transition: var(--transition);
}

.input-group input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* === BOTONES GLOBALES === */
.btn-primary,
.btn-cancel,
.btn-danger {
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  height: 38px;
  min-width: 110px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  padding: 8px 14px;
}

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

.btn-cancel {
  background: #f3f4f6;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-cancel:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  min-width: 90px;
  height: 34px;
  font-size: 0.85rem;
}

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

/* === SIDEBAR & LAYOUT GENERAL === */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-shadow: var(--shadow);
}

.sidebar .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar ul li {
  margin-bottom: 12px;
}

.sidebar ul li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  transition: var(--transition);
}

.sidebar ul li a:hover {
  background: rgba(37,99,235,0.08);
  color: var(--color-primary);
}

.sidebar ul li a.active,
.sidebar ul li a:focus {
  background: rgba(37,99,235,0.15);
  color: var(--color-primary-dark);
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: 36px;
  min-height: 100vh;
  background: var(--color-bg);
  overflow-x: hidden;
}

/* === DASHBOARD === */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.user-info h1 {
  font-size: 1.8rem;
  color: var(--color-text);
  margin-bottom: 4px;
}

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

.user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 1.3rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.stat-card i {
  font-size: 2rem;
  color: var(--color-primary);
}

.stat-card h3 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--color-text);
}

.stat-card p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.dashboard-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 30px 20px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}

.dashboard-card i {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 10px;
}

.dashboard-card h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text);
}

.dashboard-card p {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  border-color: var(--color-primary);
}

/* === CONFIGURACIÓN (ADMIN) === */

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: var(--color-text);
}

.tab.active {
  background: var(--color-primary);
  color: #fff;
}

.tab:hover {
  background: rgba(37,99,235,0.1);
}

/* Tabla de usuarios */
.table-container {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  padding: 20px;
}

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

.table th, .table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
}

.table th {
  background: #f9fafb;
  text-align: left;
  font-weight: 600;
  color: var(--color-muted);
}

/* === Ajuste visual del botón “Nuevo usuario” === */
.table-actions {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px;              /* ← más separación arriba y lados */
  margin-bottom: 8px;              /* ← espacio extra entre el botón y la tabla */
}

.table-actions .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;                        /* ← separa el ícono del texto */
  font-size: 0.9rem;
  padding: 7px 16px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  font-weight: 600;
}

.table-actions .btn-primary i {
  font-size: 1rem;                 /* tamaño del icono */
  margin-right: 4px;               /* separación adicional de respaldo */
}

.table-actions .btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}


/* Modal */
.modal.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--color-white);
  padding: 24px;
  border-radius: var(--radius);
  width: 420px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: fadeIn 0.3s ease;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-muted);
  cursor: pointer;
}

.modal-content label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 10px 0 4px;
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.modal-content input:focus,
.modal-content select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
  outline: none;
}

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

@keyframes fadeIn {
  from {opacity: 0; transform: scale(0.95);}
  to {opacity: 1; transform: scale(1);}
}

/* === BOTONES DE ACCIÓN EN TABLAS === */
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  height: auto;
}

.btn-small i {
  font-size: 0.9rem;
}

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

/* === Botón secundario (Editar) === */
.btn-secondary {
  background: #f3f4f6;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: #e5e7eb;
  color: var(--color-primary-dark);
}

/* === Botón peligro (Desactivar) === */
.btn-danger {
  background: #dc2626 !important;
  color: #fff;
}

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

/* === Botón éxito (Activar) === */
.btn-success {
  background: #16a34a !important; /* Verde base */
  color: #fff;
}

.btn-success:hover {
  background: #15803d !important; /* Verde oscuro al pasar el mouse */
}

/* Ajuste leve para iconos dentro de botones */
.btn-small i {
  font-size: 0.9rem;
  vertical-align: middle;
}

/* === Alineación de botones dentro de las acciones === */
/* Centrar encabezado "Acciones" */
.table th:last-child {
  text-align: center;
}

/* Centrar botones dentro de la celda de acciones */
.table td:last-child {
  display: flex;
  justify-content: center; /* 👈 centra horizontalmente los botones */
  align-items: center;
  gap: 8px; /* espacio entre botones */
  padding: 8px 12px;
}

.permiso-item {
  margin: 3px 0;
  display: flex;
  align-items: center;
}

.permiso-item input {
  margin-right: 8px;
  accent-color: var(--color-primary);
}

/* === Contenedores de permisos (editar y nuevo rol) === */
#rol_permisos_container,
#rol_permisos_container_nuevo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 16px;
  margin-top: 10px;
  padding: 8px 0;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fafafa;
  padding: 12px;
}

#rol_permisos_container label,
#rol_permisos_container_nuevo label {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
  gap: 6px;
}

#rol_permisos_container input[type="checkbox"],
#rol_permisos_container_nuevo input[type="checkbox"] {
  accent-color: var(--color-primary);
  transform: scale(1.1);
  cursor: pointer;
}

/* Scrollbar */
#rol_permisos_container::-webkit-scrollbar,
#rol_permisos_container_nuevo::-webkit-scrollbar {
  width: 6px;
}
#rol_permisos_container::-webkit-scrollbar-thumb,
#rol_permisos_container_nuevo::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 6px;
}
#rol_permisos_container::-webkit-scrollbar-thumb:hover,
#rol_permisos_container_nuevo::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

#modalPermiso input,
#modalEditarPermiso input {
  margin-bottom: 10px;
}

.hidden { display: none !important; }

/* ---- Estilos para la lista del Dashboard ---- */

/* El contenedor de la lista */
.dashboard-list-container {
  /* Hacemos que sea scrollable si la lista es muy larga */
  max-height: 220px; 
  overflow-y: auto;
  
  /* Un poco de espacio */
  margin-top: 10px;
  
  /* Para navegadores Webkit (Chrome, Safari) */
  scrollbar-width: thin;
  scrollbar-color: #ccc #f0f0f0;
}

/* Cada fila de la lista */
.list-item {
  display: flex; /* Alinea etiqueta y valor */
  justify-content: space-between; /* Pone uno a cada lado */
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid #f0f0f0; /* Separador ligero */
  gap: 15px; /* Espacio entre texto y número */
}

/* El nombre de la ubicación */
.list-label {
  font-size: 0.85rem;
  color: #333;
  
  /* Evita que el texto largo se desborde */
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* El número (total) */
.list-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #007bff; /* Color primario (azul) */
  
  /* Evita que el número se parta */
  white-space: nowrap; 
  
  /* Fondo sutil */
  background-color: #f0f4f8;
  padding: 3px 6px;
  border-radius: 6px;
  min-width: 25px; /* Ancho mínimo para que se vea bien */
  text-align: center;
}

/* Mensaje si la lista está vacía */
.empty-message {
  font-size: 0.9rem;
  color: #888;
  text-align: center;
  padding-top: 20px;
}

/* ========================
   🎨 DASHBOARD VISUAL STYLE
   ======================== */

/* ====== Header ====== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
}

.dashboard-header h1 {
  font-size: 1.6rem;
  color: #1e293b;
  margin-bottom: 4px;
}

.user-role {
  color: #64748b;
  font-size: 0.9rem;
}

.user-avatar {
  background-color: #2563eb;
  color: white;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* ====== KPIs ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: all .2s ease-in-out;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.stat-card i {
  background-color: #e0e7ff;
  color: #2563eb;
  font-size: 1.2rem; /* Tamaño del icono */
  border-radius: 50%; /* Lo hace circular */

  /* --- Corrección --- */
  width: 44px;         /* Ancho fijo */
  height: 44px;        /* Alto fijo (igual al ancho) */
  padding: 0;          /* Quitamos el padding */
  display: flex;       /* Usamos flex para centrar */
  align-items: center; /* Centrado vertical */
  justify-content: center; /* Centrado horizontal */
}

.stat-card h3 {
  color: #1e293b !important;   /* Asegura contraste */
  font-size: 1.6rem !important;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card p {
  margin: 2px 0 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* ====== Filters ====== */
.filters-card {
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.filters-card button.btn-small {
  background: #e2e8f0;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filters-card button.btn-small:hover {
  background: #2563eb;
  color: #fff;
}

/* ====== Cards (Gráficas) ====== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-top: 15px;
}

.dashboard-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.dashboard-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.dashboard-card h3 {
  font-size: 1rem;
  color: #1e293b;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-card i {
  color: #2563eb;
  font-size: 1.1rem;
}

/* ====== Top Ubicaciones List ====== */
.dashboard-list-container {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
  margin-top: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* <-- CAMBIADO: Para alinear arriba */
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}

.list-label {
  font-size: 0.9rem;
  color: #334155;
  flex: 1;
  margin-right: 10px;

  /* --- NUEVO: Para cortar el texto --- */
  white-space: nowrap;     /* No saltar de línea */
  overflow: hidden;        /* Esconder lo que no cabe */
  text-overflow: ellipsis; /* Poner '...' al final */
}

.list-value {
  font-size: 0.9rem;
  font-weight: 600;
  /* ... (el resto de tus estilos) ... */
}

/* --- NUEVA REGLA: Para la etiqueta 'regs.' --- */
.list-value small {
  font-size: 0.75rem; /* Más pequeño */
  font-weight: 500;   /* Menos grueso */
  color: inherit;     /* Hereda el color (azul, verde, etc.) */
  opacity: 0.8;       /* Ligeramente transparente */
  margin-left: -3px;  /* Pega 'regs.' un poco más al número */
}
.empty-message {
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
  margin-top: 15px;
}

/* === Colores individuales para cada KPI === */
.stat-card:nth-child(1) i { background-color: #dbeafe; color: #2563eb; }  /* Usuarios */
.stat-card:nth-child(2) i { background-color: #dcfce7; color: #16a34a; }  /* Registros */
.stat-card:nth-child(3) i { background-color: #fef3c7; color: #f59e0b; }  /* Ubicaciones */
.stat-card:nth-child(4) i { background-color: #fee2e2; color: #ef4444; }  /* Incidencias */
.stat-card:nth-child(5) i { background-color: #ede9fe; color: #7c3aed; }  /* % Procesado */

/* === 🌤️ Flatpickr - Estilo minimal y moderno (coherente con el dashboard) === */
.flatpickr-calendar {
  font-family: 'Inter', sans-serif;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border: none;
  background: #fff;
  padding-bottom: 8px;
  animation: fadeIn 0.25s ease-out;
}

.flatpickr-months {
  background-color: transparent;
  color: #0f172a;
  font-weight: 600;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.flatpickr-current-month {
  font-size: 0.95rem;
}

.flatpickr-prev-month,
.flatpickr-next-month {
  color: #2563eb;
  fill: #2563eb;
  transition: 0.2s ease;
}
.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
  transform: scale(1.2);
  color: #1e40af;
  fill: #1e40af;
}

.flatpickr-weekday {
  color: #64748b;
  font-weight: 500;
  font-size: 0.8rem;
}

.flatpickr-day {
  color: #334155;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin: 2px 1px;
}

.flatpickr-day:hover {
  background-color: #eff6ff;
  color: #1e40af;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #2563eb;
  color: white !important;
  box-shadow: 0 2px 6px rgba(37,99,235,0.4);
}

.flatpickr-day.today {
  border: 1px solid #2563eb;
  color: #1e40af;
}

/* === Input de fecha limpio === */
.flatpickr-input {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 0.9rem;
  color: #0f172a;
  transition: all 0.25s ease;
  width: 12%;
}

.flatpickr-input:focus {
  outline: none;
  background: #fff;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.flatpickr-input::placeholder {
  color: #94a3b8;
}

/* Animación ligera */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.filters-card input[type="date"],
.filters-card .flatpickr-input {
  margin: 0 4px;
}

.filters-card {
  background: #f9fafb;
  border: 1px solid #e2e8f0;
  padding: 10px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 1. La tarjeta sigue siendo un 'flex column' */
.dashboard-cards .dashboard-card {
  display: flex;
  flex-direction: column;
}

/* 2. El NUEVO 'chart-wrapper' es el que va a crecer */
.dashboard-cards .dashboard-card .chart-wrapper {
  flex-grow: 1;      /* Le dice al wrapper que ocupe el espacio */
  position: relative; /* ¡MUY IMPORTANTE! para que el canvas de adentro se posicione */
  min-height: 0;     /* El truco de flexbox de siempre */
}

/* 3. La LISTA de ubicaciones (no tiene wrapper) sigue creciendo normal */
.dashboard-cards .dashboard-card > .dashboard-list-container {
  flex-grow: 1;
  min-height: 0;
  /* ... (tus otros estilos de lista) ... */
}

/* 4. El CANVAS ahora ocupa el 100% de su 'chart-wrapper' */
.dashboard-cards .dashboard-card .chart-wrapper > canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* =========================================== */
/* CSS ÚNICO Y MEJORADO PARA MAPA.PHP */
/* =========================================== */

/* --- 1. Estilos del Mapa (Opcional, ya que lo tienes inline) --- */
/* Esto le da un estilo base por si quitas el style="" del HTML */
#map {
  width: 100%;
  height: 60vh;
  min-height: 500px;
  border-radius: 12px;
  border: 1px solid #e2e8f0; /* Borde sutil */
}

/* --- 2. Estilos para la Barra de Filtros (¡Ahora Responsiva!) --- */
.op-filters {
  display: flex; /* Usamos Flexbox */
  flex-wrap: wrap; /* Permite que los elementos "bajen" en pantallas chicas */
  gap: 14px;
  align-items: flex-end; /* Alinea todo en la base (se ve más limpio) */
}

.op-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1; /* Por defecto, permite que los campos crezcan */
  min-width: 170px; /* Ancho mínimo para fechas y tipo */
}

/* El campo de nombres debe crecer más que los otros */
.op-field-grow {
  flex-grow: 3; /* Le da más prioridad para ocupar espacio */
  min-width: 300px; /* Un ancho mínimo más grande */
}

/* 1. REGLA SÓLO PARA LOS CHECKBOXES */
.op-switches {
  /* Hereda 'display: flex' y 'flex-direction: column' de .op-field */
  
  /* ¡LA CLAVE! Alinea los items (checkboxes) a la izquierda */
  align-items: flex-start; 

  /* Centra la pila de checkboxes verticalmente en la caja */
  justify-content: center; 
  
  /* Propiedades de altura y espaciado */
  min-height: 42px; 
  gap: 8px; /* Un gap más pequeño para checkboxes apilados */
  flex-grow: 0;
  white-space: nowrap;
  padding-bottom: 0;
}

/* 2. REGLA SÓLO PARA LOS BOTONES */
.op-actions {
  /* Los botones SÍ usan display: flex (para ponerse en fila) */
  display: flex; 
  gap: 10px;
  flex-grow: 0;
  white-space: nowrap;

  /* Centra los botones verticalmente */
  align-items: center;  

  /* Misma altura que los inputs */
  min-height: 42px; 
  padding-bottom: 0; 
}

/* Ajuste fino para el 'gap' de los botones */
.op-actions {
  gap: 10px;
}

/* --- 3. Estilos de Inputs y Checkbox --- */
.op-input {
  background: #fff;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .95rem;
  width: 100%;
  box-sizing: border-box; /* Clave para que el padding no rompa el ancho */
}

.op-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  color: #334155;
  cursor: pointer;
}

/* --- 4. ESTILOS PARA INTEGRAR SELECT2 CON .op-input --- */

/* Contenedor principal de Select2 (para que parezca un .op-input) */
.select2-container .select2-selection--multiple {
  background-color: #fff;
  border: 1px solid var(--color-border, #e2e8f0) !important;
  border-radius: 10px !important;
  padding: 5px 6px; /* Ajuste vertical para la altura */
  height: 40px; /* Altura exacta de tu .op-input */
  min-height: 40px; /* Altura exacta de tu .op-input */
  font-size: .95rem;
  width: 100%;
  box-shadow: none; /* Quita sombras por defecto de select2 */
  box-sizing: border-box;
}

/* La caja de búsqueda dentro de Select2 */
.select2-container .select2-search--inline .select2-search__field {
  padding-left: 6px;
  margin-top: 6px; /* Alinea el texto de búsqueda */
  font-size: .95rem; /* Mismo tamaño que .op-input */
}

/* El placeholder (ej. "Filtrar por nombre") */
.select2-container .select2-selection__placeholder {
  color: #94a3b8; /* Color de placeholder estándar */
  margin-top: 6px; /* Alinea el placeholder */
}

/* El placeholder "Varios" personalizado que hicimos en JS */
.select2-container .select2-selection__placeholder-custom {
  color: var(--color-text, #111827); /* Color de texto normal */
  margin-top: 6px;
}

/* Estilo cuando está enfocado (azul) */
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); /* Sombra de foco sutil */
}

/* Oculta las "etiquetas" de selección múltiple (solo mostramos "Varios") */
.select2-container .select2-selection__choice {
  display: none !important;
}

/* ======================================================== */
/* --- Dropdown limpio y del mismo ancho que el input --- */
/* ======================================================== */
.select2-container .select2-dropdown {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  width: auto !important; 
  /* Le damos un ancho mínimo (puedes ajustarlo) */
  min-width: 300px;
  box-sizing: border-box;
  animation: fadeDown 0.15s ease-out; /* Suave aparición */
  background-color: #fff;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 10px;
  padding: 5px 6px; /* Ajuste vertical para la altura */
  min-height: 42px; /* Altura exacta de tu .op-input */
  box-sizing: border-box;
}

/* Corrige gris del cuerpo de resultados */
.select2-results,
.select2-results__options {
  background: #fff !important;
}

/* Cada opción del menú */
.select2-results__option {
  background-color: #fff !important;
  color: #1e293b;
  padding: 8px 12px;
  font-size: 0.95rem;
  transition: background-color 0.15s ease;
}

/* Hover */
.select2-results__option--highlighted {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

/* Seleccionada */
.select2-results__option[aria-selected="true"] {
  background-color: #e0e7ff !important;
  color: #1e3a8a !important;
}

/* --- Mantiene "Varios seleccionados" sin deformar --- */
.select2-container .select2-selection__rendered.varios {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 42px;
  padding-left: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.select2-container .select2-selection__rendered.varios::before {
  content: attr(data-label);
  color: #94a3b8; /* mismo tono que placeholder */
  font-size: .95rem;
  line-height: 1.4;
}

.select2-container .select2-selection__rendered.varios .select2-selection__choice {
  display: none !important;
}

/* --- Animación de apertura del menú --- */
@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ======================================================== */
/* --- Leyenda del mapa --- */
/* ======================================================== */
.map-legend {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  width: fit-content;
  margin: 10px auto;
}
.map-legend img {
  vertical-align: middle;
}

/* ============================================ */
/* 🎯 Ajustes visuales específicos de Incidencias */
/* ============================================ */
.table-incidencias th {
  text-align: center !important;
  color: #334155;
  font-weight: 600;
  background: #f8fafc;
  vertical-align: middle;
}

.table-incidencias td {
  text-align: center !important;
  vertical-align: middle;
  font-size: 0.9rem;
  color: #1e293b;
  border: none;
}

/* Opcional: Filas más limpias y separadas */
.table-incidencias tr {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
}

.table-incidencias tr:hover {
  background: #f9fafb;
  transition: background-color 0.2s ease;
}

/* Encabezado redondeado superior */
.table-incidencias thead th:first-child {
  border-top-left-radius: 10px;
}
.table-incidencias thead th:last-child {
  border-top-right-radius: 10px;
}

/* ================================*/
/* 🎨 Ajuste de botones en incidencias */
/* ================================ */
.table-incidencias .btn-small {
  margin-top: 5%;
  font-size: 0.78rem !important;
  padding: 3px 10px !important;
  display: inline-flex;
  align-items: center; 
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  font-weight: 500;
  vertical-align: middle !important;
}

.table-incidencias .btn-small i {
  font-size: 0.9rem !important;
  color: inherit; 
  line-height: 1; /* Esto está bien, quita espacio extra */

  /* --- LA SOLUCIÓN MANUAL --- */
  position: relative;
  top: 5px; /* <-- AJUSTA ESTE VALOR SI ES NECESARIO */
}

/* El span no necesita nada especial */
.table-incidencias .btn-small span {
  line-height: 1;
}

/* ... (tus reglas de hover y disabled están bien) ... */
.table-incidencias .btn-small:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  transition: all 0.15s ease;
}

.table-incidencias .btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

#btnDescargarEvidencia {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  text-decoration: none;       /* 🔹 quita el subrayado */
  color: #fff;                 /* asegúrate de mantener el color del texto */
}

#btnDescargarEvidencia:hover {
  text-decoration: none;       /* 🔹 asegura que no aparezca al hacer hover */
  filter: brightness(1.1);
  transform: translateY(-1px);
  transition: all 0.2s ease;
}


#btnDescargarEvidencia i {
  font-size: 1rem;
  position: relative;
  top: 1px; /* 🔹 Ajuste vertical suave */
}

#modalEvidencia .modal-content {
  max-width: 1000px;
  width: 90%;
  height: 90%;
}

#contenedorEvidencia iframe,
#contenedorEvidencia img {
  width: 100%;
  height: 65vh;
  border: none;
  border-radius: 8px;
}

/* 2. Soluciona el texto de "Estado" muy pequeño */
.table-incidencias .badge {
  font-size: 0.875rem;  /* Esto es 14px (si 1rem = 16px). Es un tamaño mucho más legible */
  font-weight: 500;    /* Hacemos la letra un poco más gruesa */
  padding: 6px 10px;   /* Le damos un poco más de espacio interno */
}

/* === Grupo de checkboxes (Distritos) === */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
  max-height: 250px;
  overflow-y: auto;
  padding: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb; /* azul consistente con tus botones */
  cursor: pointer;
}

.checkbox-group .muted {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  font-style: italic;
}

/* Para scrollbar elegante en la lista */
.checkbox-group::-webkit-scrollbar {
  width: 6px;
}
.checkbox-group::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}
.checkbox-group::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.table-incidencias td:nth-child(6),
.table-incidencias td:nth-child(8) {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-incidencias td:nth-child(6):hover,
.table-incidencias td:nth-child(8):hover {
  white-space: normal;
  overflow: visible;
}
