/* =========================================================
   css/style.css ✅ COMPLETO Y COMPUESTO
   Fix principal:
   - Sidebar en móvil ahora SCROLLEA (antes se bloqueaba por overflow)
   - Se permite scroll táctil iOS: -webkit-overflow-scrolling: touch
   - Opción: que scrollee el menú (ul.menu) y no la cabecera MEPI
   - Clase opcional: body.no-scroll para bloquear scroll del body al abrir sidebar
========================================================= */

/********************************************************
  Reset, placeholders y estilos base
********************************************************/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Oculta cualquier scroll horizontal */
}

/* (Opcional) si quieres bloquear scroll del body cuando sidebar esté abierta en móvil */
body.no-scroll {
  overflow: hidden;
}

/* Placeholders para distintos navegadores */
::-webkit-input-placeholder {
  color: #888;
  font-family: inherit;
  font-size: inherit;
  font-style: normal;
}
:-ms-input-placeholder {
  color: #888;
  font-family: inherit;
  font-size: inherit;
  font-style: normal;
}
::placeholder {
  color: #888;
  font-family: inherit;
  font-size: inherit;
  font-style: normal;
}

/* Ejemplo específico que tenías */
input.custom-clase::placeholder {
  color: red;
}

.nav-separator {
  border-bottom: 1px solid #666;
  margin: 10px 0;
}

/********************************************************
  Modo oscuro y animación del toggle
********************************************************/
.dark-mode {
  background-color: #1e1e1e;
  color: #f4f4f4;
}
.dark-mode .card {
  background-color: #444;
  color: #ffffff;
  border: 1px solid #626262;
}
.dark-mode label {
  color: #ffffff;
}
.dark-mode .btn-primary {
  background-color: #28a745;
  color: white;
}
.dark-mode .btn-primary:hover {
  background-color: #218838;
}
.dark-mode table {
  background-color: #2a2a2a;
  color: white;
  border-color: #444;
}
.dark-mode th,
.dark-mode td {
  border: 1px solid #555;
}
.dark-mode .tab-container {
  background-color: #444;
}
.dark-mode .tab-btn {
  color: #ccc;
  background: none;
}
.dark-mode .tab-btn.active {
  background-color: #007bff;
  color: white;
}
/* Ajuste de la navbar en modo oscuro */
.dark-mode .navbar {
  background-color: #0066cc;
}
/* Ajuste sidebar en modo oscuro */
.dark-mode .sidebar {
  background-color: #2a2a2a;
}
.dark-mode .sidebar .menu-item a:hover {
  background-color: #3a3a3a;
}
.dark-mode .modal .modal-content {
  background-color: #333 !important;
  color: #f4f4f4 !important;
}

/* Animación para el botón de modo oscuro */
@keyframes darkModeToggle {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}
.animate-toggle {
  animation: darkModeToggle 0.6s ease-in-out;
}
/* Íconos del toggle */
.navbar-btn i.fa-sun { color: #FFD700; }
.navbar-btn i.fa-moon { color: #fff; }

/********************************************************
  Layout principal: Navbar, Sidebar y Contenido
********************************************************/
/* Navbar con altura fija */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #007bff;
  color: #fff;
  height: 60px;
  padding: 0 1rem;
  position: relative;
  z-index: 1100;
}
.navbar .navbar-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 0.5rem;
}
.navbar .navbar-btn:hover { opacity: 0.8; }
.navbar-right {
  display: flex;
  align-items: center;
}

/* Al eliminar el margin-top del tab-container pegado a la navbar */
.navbar + .tab-container { margin-top: 0; }

/* Wrapper para sidebar y contenido */
.wrapper {
  display: flex;
  height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
  background-color: #343a40;
  color: #fff;
  transition: width 0.3s, transform 0.3s;

  /* ✅ FIX: permitir scroll en general (antes estaba hidden y mataba el scroll) */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-header {
  text-align: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
  background-color: rgb(255, 255, 255);
  border-bottom: 1px solid #495057;

  /* (recomendado) para que el header se vea bien */
  padding: 14px 10px;
}
.sidebar.expanded,
.sidebar.hovered { width: 200px; }
.sidebar.collapsed { width: 60px; }

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

.sidebar .menu-item a {
  display: flex;
  align-items: center;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.3s;
}
.sidebar .menu-item a:hover { background-color: #495057; }

.menu-text {
  margin-left: 1rem;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.3s;
}
.sidebar.collapsed .menu-text {
  opacity: 0;
  pointer-events: none;
}

/* Área de contenido */
.content {
  flex: 1;
  padding: 1rem;
}

/********************************************************
  Contenedores generales
********************************************************/
body {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f4f4f4;
  color: #333;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  max-width: 1200px;
  margin: 10px auto;
  padding: 10px;
}

.header {
  text-align: center;
  margin-bottom: 10px;
  margin-top: -30px;
}

/********************************************************
  Secciones y tarjetas
********************************************************/
.toggle-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.toggle-btn {
  padding: 8px 12px;
  border: none;
  background-color: #007bff;
  color: white;
  cursor: pointer;
  border-radius: 5px;
  font-size: 1rem;
}
.toggle-btn.active { background-color: #0056b3; }

.section { display: none; }
.section.active { display: block; }

.card {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/********************************************************
  Formularios
********************************************************/
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.form-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;

  /* Asegura posición relativa del padre del dropdown */
  position: relative;
}
.form-group label {
  font-weight: bold;
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}
.btn-primary {
  background-color: #28a745;
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}
.btn-primary:hover { background-color: #218838; }

/********************************************************
  Pestañas
********************************************************/
.tab-container {
  display: flex;
  justify-content: center;
  background: #ddd;
  padding: 2px;
  border-radius: 25px;
  width: fit-content;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}
.tab-btn {
  flex: 1;
  padding: 10px 15px;
  border: none;
  background: none;
  color: #333;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s, color 0.3s;
  border-radius: 20px;
}
.tab-btn.active {
  background-color: #007bff;
  color: white;
}
.tab-content {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}
.tab-content.active {
  display: block;
  opacity: 1;
}

/********************************************************
  Custom select (distritos)
********************************************************/
.custom-select-input {
  width: 100%;
  padding: 8px;
  border: 2px solid; /* Azul para destacar */
  border-radius: 4px;
  font-size: 1rem;
}
.custom-select-input:focus { border-color: #0056b3; }

.distrito-option {
  padding: 8px;
  cursor: pointer;
  transition: background 0.3s;
}
.distrito-option:hover {
  background: #007bff;
  color: white;
}

#distrito-dropdown,
#edit-distrito-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 0 0 4px 4px;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: none;
}
#distrito-dropdown.visible,
#edit-distrito-dropdown.visible { display: block; }

#distrito-dropdown .distrito-option,
#edit-distrito-dropdown .distrito-option {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.distrito-option.highlighted {
  background-color: #007bff;
  color: #fff;
}

/********************************************************
  Errores en validación
********************************************************/
.input-error {
  border: 2px solid red;
  background-color: #ffe5e5;
}

/********************************************************
  Tablas
********************************************************/
.tabla-mepi {
  width: 100%;
  border-collapse: collapse;
  border: none;
  font-family: inherit;
  font-size: 1rem;
}
.tabla-mepi th,
.tabla-mepi td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.tabla-mepi th {
  font-weight: bold;
  background-color: #f8f8f8;
  border-bottom: 2px solid #ddd;
}

/* Botones dentro de la tabla */
.tabla-mepi td button {
  margin: 0 4px;
  padding: 6px 12px;
  border-radius: 5px;
  background-color: #007BFF;
  color: white;
  font-size: 12px;
  border: none;
  cursor: pointer;
}
.tabla-mepi td button:hover { background-color: #0056b3; }

/* Ordenamiento visual (flechas) */
.tabla-mepi th[data-col] {
  cursor: pointer;
  position: relative;
}
.tabla-mepi th[data-col]::after {
  content: "";
  display: inline-block;
  margin-left: 5px;
  border-width: 5px;
  border-style: solid;
  border-color: #888 transparent transparent transparent;
  opacity: 0.6;
  transition: transform 0.2s;
}
.tabla-mepi th.sort-asc::after { transform: rotate(180deg); }
.tabla-mepi th.sort-desc::after { transform: rotate(0deg); }

/* Flechas de sort con .sort-arrow (si usas esa clase) */
.sort-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  margin-left: 5px;
  margin-top: -2px;
}
.sort-asc .sort-arrow { border-bottom: 5px solid #000; }
.sort-desc .sort-arrow { border-top: 5px solid #000; }

/* Responsive scroll para tablas */
.tabla-responsive {
  overflow-x: auto;
  display: block;
}

/********************************************************
  Encabezado de tabla y buscador
********************************************************/
.heading-search-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.heading-search-container h2 { margin: 0; }

#search-input,
#dsi-search {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}


/********************************************************
  Botones globales y paginación
********************************************************/
button {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 10px 20px;
  margin: 5px;
  cursor: pointer;
  border-radius: 5px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}
button:hover { background-color: #45a049; }
button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
button i { margin-right: 5px; }

#pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}

/********************************************************
  Contenedor de carga (loading)
********************************************************/
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  font-size: 3rem;
}

/********************************************************
  Modales
********************************************************/
/* Modal genérico */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
}
.modal-content {
  background-color: #ffffff;
  padding: 25px 30px;
  border-radius: 12px;
  text-align: center;
  width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
}
.modal-content h2 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: #333;
}
.modal-content p {
  font-size: 1rem;
  margin-bottom: 20px;
  color: #555;
}
/* Íconos en el modal */
.modal-content .icon {
  font-size: 3rem;
  margin-bottom: 15px;
  color: #007bff;
}
.modal-content .icon.error { color: #dc3545; }
.modal-content .icon.success { color: #28a745; }

.modal-buttons {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}
.modal-buttons button {
  flex: 1;
  padding: 10px 20px;
  text-align: center;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 5px;
}

/* Spinner de carga */
.carga {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1.2s linear infinite;
  margin: 0 auto 15px auto;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal de estado e impresión */
#modal-generico .modal-content {
  width: 95%;
  max-width: 1200px;
  max-height: 90%;
  background-color: #ffffff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  text-align: left;
}
#modal-generico .modal-content h2 {
  font-size: 2rem;
  margin-bottom: 30px;
  text-align: center;
}
#modal-generico .modal-content img {
  max-width: 150px;
  margin-bottom: 20px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Botón cerrar e imprimir en el modal genérico */
.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
  transition: color 0.3s;
}
.close-btn:hover { color: #666; }

.print-btn {
  position: absolute;
  top: 10px;
  left: 10px;
}

/* Encabezado modal en escritorio */
.encabezado-modal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: nowrap;
}

.encabezado-modal .logo-izq,
.encabezado-modal .logo-der {
  width: 90px !important;
  flex-shrink: 0;
  text-align: center;
}

.encabezado-modal .logo-izq img,
.encabezado-modal .logo-der img {
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
}

.encabezado-modal .texto-central {
  flex: 1;
  text-align: center;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.encabezado-modal .texto-central h2,
.encabezado-modal .texto-central h3,
.encabezado-modal .texto-central h4 {
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

/* Ajusta fuentes de escritorio */
.encabezado-modal .texto-central h2 {
  font-size: 1.2rem;
  margin-bottom: 0.3em;
}
.encabezado-modal .texto-central h3 {
  font-size: 1rem;
  margin-bottom: 0.2em;
}
.encabezado-modal .texto-central h4 {
  font-size: 0.8rem;
  margin-bottom: 0;
}

/********************************************************
  ÚNICO MEDIA QUERY UNIFICADO PARA MÓVILES ✅
  (incluye fix de scroll en sidebar)
********************************************************/
@media (max-width: 768px) {

  /* 1) Ajustes en .container para móvil */
  .container {
    max-width: 100%;
    margin: 10px;
    padding: 10px;
  }

  /* 2) Sidebar en móvil */
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    height: calc(100vh - 60px);
    width: 200px !important;
    transform: translateX(-100%);
    z-index: 1000;

    /* ✅ FIX: scroll real en móvil */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.mobile-active {
    transform: translateX(0);
  }

  /* ✅ OPCIONAL RECOMENDADO:
     que el UL del menú sea el que scrollee y el header "MEPI" quede visible */
  .sidebar .menu {
    /* 60 navbar ya está fuera; acá restamos aprox header de sidebar */
    max-height: calc(100vh - 60px - 56px);
    overflow-y: auto;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
  }

  /* 3) Wrapper y contenido en vertical */
  .wrapper { flex-direction: column; }
  .content { margin-left: 0; }

  .sidebar.mobile-active .menu-text {
    opacity: 1;
    pointer-events: auto;
  }

  /* 4) Modal base (ventanas modales pequeñas) */
  .modal-content {
    width: 90%;
    padding: 20px;
  }
  .modal-content h2 { font-size: 1.2rem; }
  .modal-content p { font-size: 0.9rem; }

  /* 5) Modal grande (#modal-generico) */
  #modal-generico .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 20px;
  }
  #modal-generico .modal-content h2 { font-size: 1.6rem; }

  /* 6) Ajuste principal: #print-container responsivo */
  #print-container {
    max-width: 100% !important;
    margin: 0 auto;
    font-family: Arial, sans-serif;
    line-height: 1.4;
  }

  /* 7) Forzar wrap para div flex inline dentro de print-container */
  #print-container div[style*="display: flex"] {
    flex-wrap: wrap !important;
  }

  /* 8) Sobrescribe anchos fijos inline */
  #print-container div[style*="width: 200px"] {
    width: 100% !important;
    min-width: auto !important;
  }

  /* 9) Forzar 100% en quien tenga flex:1 inline */
  #print-container div[style*="flex: 1"] {
    width: 100% !important;
  }

  /* Encabezado modal en móvil */
  .encabezado-modal {
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 5px;
  }
  .encabezado-modal > div {
    width: 100% !important;
    margin-bottom: 5px;
  }
  .encabezado-modal .logo-izq img,
  .encabezado-modal .logo-der img {
    width: 40px !important;
    height: auto !important;
  }
  .encabezado-modal .texto-central h2 { font-size: 1.1rem; }
  .encabezado-modal .texto-central h3 { font-size: 0.95rem; }
  .encabezado-modal .texto-central h4 { font-size: 0.85rem; }
}

/********************************************************
  Correcciones específicas para el modal de vinculación
********************************************************/
.modal-vinculacion input[type="text"] {
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.modal-vinculacion input[type="text"]:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 5px rgba(0,123,255,0.5);
}

.modal-vinculacion .resumen-entidad {
  margin-top: 12px;
  background: #f8f8f8;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #333;
}

.resumen-entidad { min-height: 110px; }

/* ===============================================
   Dropdown genérico (multiuso) — Estilo limpio
   =============================================== */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
}

.autocomplete-dropdown.visible { display: block; }

.autocomplete-dropdown .autocomplete-option {
  padding: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  transition: background-color 0.2s, color 0.2s;
}

.autocomplete-dropdown .autocomplete-option:hover,
.autocomplete-dropdown .autocomplete-option.highlighted {
  background-color: #007bff;
  color: white;
}

/********************************************************
  Mapa uniones
********************************************************/
#mapa-uniones {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 50px;
  justify-items: center;
  align-items: start;
  margin: 40px 0;
}

.union-bloque {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.entidad {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.entidad i {
  font-size: 40px;
  color: green;
}

.map-label {
  margin-top: 5px;
  font-size: 16px;
  font-weight: bold;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.flecha {
  font-size: 30px;
  color: #333;
  text-align: center;
}

.input-seleccionado {
  background-color: #d4edda !important;
  transition: background-color 0.8s ease;
}

/********************************************************
  Dropdowns específicos (Plantador / Iglesia Madre / Edición / Pastores)
  (mantengo tus IDs tal cual)
********************************************************/
#plantador-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 4px 4px;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: none;
}
#plantador-dropdown.visible { display:block; }

#plantador-dropdown .plantador-option {
  padding: 8px;
  cursor: pointer;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#plantador-dropdown .plantador-option.active,
#plantador-dropdown .plantador-option:hover {
  background:#007bff;
  color:#fff;
}

/* ─── Reutilizar estilo genérico de autocomplete ───────────────── */
#iglesia-madre-dropdown,
#plantador-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
}
#iglesia-madre-dropdown.visible,
#plantador-dropdown.visible { display: block; }

#iglesia-madre-dropdown .iglesia-option,
#plantador-dropdown .plantador-option {
  padding: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  transition: background-color 0.2s, color 0.2s;
}
#iglesia-madre-dropdown .iglesia-option:hover,
#iglesia-madre-dropdown .iglesia-option.highlighted,
#plantador-dropdown .plantador-option:hover,
#plantador-dropdown .plantador-option.highlighted {
  background-color: #007bff;
  color: #fff;
}

/* ── Dropdown de edición para Iglesia Madre y Plantador ── */
#edit-iglesia-madre-dropdown,
#edit-plantador-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
}
#edit-iglesia-madre-dropdown.visible,
#edit-plantador-dropdown.visible { display: block; }

/* Opciones */
#edit-iglesia-madre-dropdown .distrito-option,
#edit-plantador-dropdown .distrito-option {
  padding: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
#edit-iglesia-madre-dropdown .distrito-option:hover,
#edit-plantador-dropdown .distrito-option:hover,
#edit-iglesia-madre-dropdown .distrito-option.highlighted,
#edit-plantador-dropdown .distrito-option.highlighted {
  background-color: #007bff;
  color: #fff;
}

/* ─── Estilo para el autocomplete de Pastores ───────────────── */
#pastor-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
}
#pastor-dropdown.visible { display: block; }

#pastor-dropdown .plantador-option {
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  transition: background-color 0.2s, color 0.2s;
}
#pastor-dropdown .plantador-option:hover,
#pastor-dropdown .plantador-option.highlighted {
  background-color: #007bff;
  color: #fff;
}

/* =========================================================
   PATCH: Sidebar menú con scroll REAL (móvil + desktop)
   - Hace que la sidebar sea columna
   - Header fijo arriba
   - El UL .menu es el que scrollea
========================================================= */

/* Asegura scroll del menú en general */
.sidebar{
  display: flex;
  flex-direction: column;
  overflow: hidden; /* el scroll lo tendrá .menu */
}

/* Header NO scrollea */
.sidebar-header{
  flex: 0 0 auto;
}

/* El menú SÍ scrollea */
.sidebar .menu{
  flex: 1 1 auto;
  min-height: 0;            /* 🔑 clave para que overflow funcione en flex */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  overscroll-behavior: contain;
}

/* =========================================================
   FIX DEFINITIVO: Sidebar scrollea en móvil (header sticky)
   Pegar AL FINAL de style.css
========================================================= */

@media (max-width: 768px) {
  /* La sidebar debe poder scrollear */
  #sidebar.sidebar {
    display: block !important;                 /* evita conflictos con flex */
    height: calc(100vh - 60px) !important;
    max-height: calc(100vh - 60px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  /* Header fijo dentro del scroll */
  #sidebar .sidebar-header {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  /* El UL NO debe limitar el scroll (lo hace la sidebar) */
  #sidebar .menu {
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: 20px;
  }
}

/* =========================================================
   FIX DSI: Acciones en tabla (botones apilables y scroll en móvil)
   - Desktop: botones envuelven (wrap) y quedan ordenados
   - Móvil: la celda de acciones scrollea horizontal si no caben
========================================================= */

/* 1) Botones pequeños (si no existe tu estilo, lo crea) */
.btn-small{
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.btn-small.btn-danger{
  background: #dc3545;
}

/* 2) Celda de acciones: wrap para que no se amontonen */
.tabla-mepi td:last-child{
  white-space: normal; /* permite salto */
}

/* 3) Hacemos que los botones se comporten como “chips” y envuelvan */
.tabla-mepi td:last-child button{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px 6px 4px 0 !important;
  vertical-align: middle;
}

/* 4) Móvil: la columna acciones no desaparece y es usable */
@media (max-width: 768px){

  /* La tabla completa puede scrollear (si ya usas tabla-responsive, mejor) */
  .tabla-mepi{
    min-width: 720px; /* fuerza scroll horizontal de tabla si es necesario */
  }

  /* La celda Acciones: scrollea horizontal SOLO los botones */
  .tabla-mepi td:last-child{
    max-width: 220px;            /* ajusta si querés */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;         /* en móvil mejor en fila + scroll */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  /* Botones un poquito más compactos */
  .btn-small{
    padding: 6px 8px;
    font-size: 11px;
  }
}

/* =========================================================
   FIX: no pisar Bootstrap .form-control con reglas propias
========================================================= */

/* Si el input/select/textarea tiene .form-control, que use Bootstrap */
.form-group input.form-control,
.form-group select.form-control,
.form-group textarea.form-control{
  padding: .375rem .75rem !important;
  border: 1px solid #ced4da !important;
  border-radius: .375rem !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  background-color: #fff !important;
}

/* Focus estilo Bootstrap */
.form-group input.form-control:focus,
.form-group select.form-control:focus,
.form-group textarea.form-control:focus{
  border-color: #86b7fe !important;
  outline: 0 !important;
  box-shadow: 0 0 0 .25rem rgba(13,110,253,.25) !important;
}

/* En dark-mode, si querés mantener coherencia visual */
.dark-mode .form-group input.form-control,
.dark-mode .form-group select.form-control,
.dark-mode .form-group textarea.form-control{
  background-color: #2a2a2a !important;
  border-color: #555 !important;
  color: #f4f4f4 !important;
}
.dark-mode .form-group input.form-control::placeholder{
  color: #b8b8b8 !important;
}

