/**
 * Estilos fijos para la barra de búsqueda superior (search nav bar).
 * Se aplican en todas las páginas para que la barra se vea igual
 * tanto en el navbar principal como en content-header u otras zonas.
 * No dependen del padre .navbar-light / .navbar-dark.
 */

/* Drawer historial: 40% del ancho de la página */
.custom-drawer {
  width: 40% !important;
  max-width: 100vw !important;
}

@media (max-width: 768px) {
  .custom-drawer {
    width: 90% !important;
  }
}

/* Bloque de búsqueda: apariencia consistente en cualquier contexto */
.navbar-search-block {
  position: absolute;
  padding: 0 1rem;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: none;
  justify-content: center;
  flex-direction: column;
  background-color: transparent !important;
}

.navbar-search-block.navbar-search-open {
  display: flex !important;
}

.navbar-search-block .input-group {
  width: 100%;
}

/* Input y botones: mismos colores en todas las páginas (estilo navbar claro) */
.navbar-search-block .form-control-navbar,
.navbar-search-block .btn-navbar {
  background-color: #dadfe4 !important;
  border-color: #ced4da !important;
  color: rgba(0, 0, 0, 0.6) !important;
  transition: none;
}

.navbar-search-block .form-control-navbar {
  border-right-width: 0 !important;
}

.navbar-search-block .btn-navbar {
  background-color: #dadfe4 !important;
  border-left-width: 0 !important;
}

/* Iconos fa-search y fa-times siempre visibles (evitar mismo color que fondo en dashboard) */
.navbar-search-block .btn-navbar i,
.navbar-search-block .btn-navbar .fas,
.navbar-search-block .btn-navbar .fa-search,
.navbar-search-block .btn-navbar .fa-times {
  color: #495057 !important;
}

a.nav-link[data-widget="navbar-search"] i,
a.nav-link[data-widget="navbar-search"] .fas,
a.nav-link[data-widget="navbar-search"] .fa-search {
  color: #495057 !important;
}

.navbar-search-block .form-control-navbar + .input-group-append {
  margin-left: 0;
}

/* Placeholder */
.navbar-search-block .form-control-navbar::placeholder {
  color: rgba(0, 0, 0, 0.6) !important;
}

.navbar-search-block .form-control-navbar::-webkit-input-placeholder {
  color: rgba(0, 0, 0, 0.6) !important;
}

.navbar-search-block .form-control-navbar::-moz-placeholder {
  color: rgba(0, 0, 0, 0.6) !important;
}

.navbar-search-block .form-control-navbar:-ms-input-placeholder {
  color: rgba(0, 0, 0, 0.6) !important;
}

/* Focus: mismo aspecto en todas las páginas */
.navbar-search-block .form-control-navbar:focus,
.navbar-search-block .form-control-navbar:focus + .input-group-append .btn-navbar {
  background-color: #d3d9df !important;
  border-color: #c7ced5 !important;
  color: rgba(0, 0, 0, 0.6) !important;
  outline: 0;
  box-shadow: none !important;
}

.navbar-search-block .form-control-navbar:focus {
  border-right-width: 0 !important;
}

/* Tamaño y alineación del input-group dentro del bloque */
.navbar-search-block .input-group .form-control {
  min-height: calc(1.5em + 0.5rem + 2px);
}

.navbar-search-block .input-group-sm .form-control {
  min-height: calc(1.5em + 0.25rem + 2px);
}

/* ==========================================================================
   Botones Historial y Plantillas (FORMULARIOS) - Estilos fijos
   Para que la card de opciones y el botón lateral se vean igual en todas las páginas.
   ========================================================================== */

/* Card de opciones: Análisis inicial, Historial del paciente, Contenido multimedia */
.paciente-header-container .card.bg-light2,
.card.bg-light2.d-flex.flex-fill {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
}

.paciente-header-container .card.bg-light2 > div,
.card.bg-light2.d-flex.flex-fill > div {
  flex: 1 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 1rem !important;
  border-bottom: 1px solid #ddd !important;
  cursor: pointer !important;
}

.paciente-header-container .card.bg-light2 > div:last-child,
.card.bg-light2.d-flex.flex-fill > div:last-child {
  border-bottom: none !important;
}

.paciente-header-container .card.bg-light2 > div:nth-child(1),
.card.bg-light2.d-flex.flex-fill > div:nth-child(1) {
  background-color: rgba(155, 155, 155, 0.3) !important;
}

.paciente-header-container .card.bg-light2 > div:nth-child(2),
.card.bg-light2.d-flex.flex-fill > div:nth-child(2) {
  background-color: rgba(102, 102, 102, 0.3) !important;
}

.paciente-header-container .card.bg-light2 > div:nth-child(3),
.card.bg-light2.d-flex.flex-fill > div:nth-child(3) {
  background-color: rgba(137, 144, 162, 0.4) !important;
}

.paciente-header-container .card.bg-light2 > div > div,
.card.bg-light2.d-flex.flex-fill > div > div {
  font-weight: bold !important;
  font-size: 1.2rem !important;
  text-align: center !important;
}

#opcHistorialPaciente,
#opcAlergiasDiscapacidades,
#opcContenidoMultimedia {
  cursor: pointer !important;
}

/* Botón lateral FORMULARIOS (Plantillas) */
.formularios-toggle-btn {
  position: fixed !important;
  right: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px 0 0 8px !important;
  padding: 20px 10px !important;
  cursor: pointer !important;
  z-index: 998 !important;
  box-shadow: -2px 0 8px rgba(37, 99, 235, 0.3) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  writing-mode: vertical-rl !important;
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.1em !important;
  min-height: 100px !important;
}

.formularios-toggle-btn:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
  box-shadow: -3px 0 12px rgba(37, 99, 235, 0.4) !important;
  padding-left: 12px !important;
}

.formularios-toggle-btn.drawer-open {
  right: calc(550px - 2px) !important;
}

/* Drawer de formularios (cabecera) */
.formularios-drawer-header {
  background: linear-gradient(135deg, #154360 0%, #1a5276 100%) !important;
  color: #fff !important;
  padding: 18px 20px !important;
  font-weight: 600 !important;
  font-size: 1rem !important;
}

/* ==========================================================================
   Botones Historia y Plantillas en resultados de búsqueda (navbar)
   Solo clases navbar-paciente-ver-historia / navbar-paciente-ver-plantillas.
   Colores fijos: base, hover y active. !important para anular cualquier otro estilo.
   ========================================================================== */

/* Base común: aspecto botón pequeño (incluye botón atrás y acciones en plantillas) */
.navbar-paciente-ver-historia,
.navbar-paciente-ver-plantillas,
#navbar-plantillas-back,
.navbar-search-item-actions button {
  display: inline-block !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
  text-align: center !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
  cursor: pointer !important;
  border-radius: 0.2rem !important;
  transition: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Historia + Atrás plantillas + botones en .navbar-search-item-actions: azul fijo */
.navbar-paciente-ver-historia,
#navbar-plantillas-back,
.navbar-search-item-actions button {
  background-color: transparent !important;
  border: 1px solid #007bff !important;
  color: #007bff !important;
}

.navbar-paciente-ver-historia:hover,
#navbar-plantillas-back:hover,
.navbar-search-item-actions button:hover {
  background-color: #007bff !important;
  border-color: #007bff !important;
  color: #fff !important;
}

.navbar-paciente-ver-historia:active,
.navbar-paciente-ver-historia:focus,
#navbar-plantillas-back:active,
#navbar-plantillas-back:focus,
.navbar-search-item-actions button:active,
.navbar-search-item-actions button:focus {
  background-color: #0056b3 !important;
  border-color: #0056b3 !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Plantillas: verde fijo */
.navbar-paciente-ver-plantillas {
  background-color: transparent !important;
  border: 1px solid #28a745 !important;
  color: #28a745 !important;
}

.navbar-paciente-ver-plantillas:hover {
  background-color: #28a745 !important;
  border-color: #28a745 !important;
  color: #fff !important;
}

.navbar-paciente-ver-plantillas:active,
.navbar-paciente-ver-plantillas:focus {
  background-color: #1e7e34 !important;
  border-color: #1e7e34 !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}

/* ==========================================================================
   Drawer historial – sección Historia clínica: filtros adaptativos y estilos fijos
   #verExpedienteDrawer / #paciente-expediente
   ========================================================================== */

#verExpedienteDrawer .drawer-historial-filtros,
#paciente-expediente .drawer-historial-filtros {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.5rem 1rem !important;
  align-items: flex-end !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col,
#paciente-expediente .drawer-historial-filtro-col {
  flex: 1 1 120px !important;
  min-width: 0 !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col.drawer-historial-filtro-top,
#paciente-expediente .drawer-historial-filtro-col.drawer-historial-filtro-top {
  flex: 1 1 calc(50% - 0.5rem) !important;
  min-width: 260px !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col.drawer-historial-filtro-plantilla,
#paciente-expediente .drawer-historial-filtro-col.drawer-historial-filtro-plantilla {
  flex: 2.4 1 360px !important;
  min-width: 320px !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col.drawer-historial-filtro-actions,
#paciente-expediente .drawer-historial-filtro-col.drawer-historial-filtro-actions {
  flex: 1 1 100% !important;
  min-width: 140px !important;
}

#verExpedienteDrawer .drawer-historial-btns,
#paciente-expediente .drawer-historial-btns {
  display: flex !important;
  gap: 0.5rem !important;
  flex-wrap: wrap !important;
}

/* Labels – siempre iguales */
#verExpedienteDrawer .drawer-historial-label,
#paciente-expediente .drawer-historial-label {
  display: block !important;
  font-size: 0.875rem !important;
  color: #6c757d !important;
  margin-bottom: 0.25rem !important;
  font-weight: 400 !important;
}

/* Selects – forzar apariencia (padding-right para que el texto no tape la flecha) */
#verExpedienteDrawer .drawer-historial-select,
#paciente-expediente .drawer-historial-select,
#verExpedienteDrawer #filtroTipoIngreso,
#verExpedienteDrawer #filtroUsuario,
#verExpedienteDrawer #filtroFormulario,
#paciente-expediente #filtroTipoIngreso,
#paciente-expediente #filtroUsuario,
#paciente-expediente #filtroFormulario {
  display: block !important;
  width: 100% !important;
  min-height: calc(1.5em + 0.5rem + 2px) !important;
  padding: 0.25rem 0.5rem !important;
  padding-right: 1.75rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  color: #212529 !important;
  background-color: #fff !important;
  border: 1px solid #ced4da !important;
  border-radius: 0.25rem !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col .select2-container,
#paciente-expediente .drawer-historial-filtro-col .select2-container {
  width: 100% !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col .select2-selection--single,
#paciente-expediente .drawer-historial-filtro-col .select2-selection--single {
  min-height: calc(1.5em + 0.5rem + 2px) !important;
}

#verExpedienteDrawer .drawer-historial-filtro-col .select2-selection__rendered,
#paciente-expediente .drawer-historial-filtro-col .select2-selection__rendered {
  line-height: calc(1.5em + 0.5rem) !important;
}

/* Selects deshabilitados mientras cargan opciones (como Sede: solo disabled + texto "Cargando...") */
#verExpedienteDrawer #filtroTipoIngreso:disabled,
#verExpedienteDrawer #filtroUsuario:disabled,
#verExpedienteDrawer #filtroFormulario:disabled,
#paciente-expediente #filtroTipoIngreso:disabled,
#paciente-expediente #filtroUsuario:disabled,
#paciente-expediente #filtroFormulario:disabled {
  cursor: wait !important;
  background-color: #e9ecef !important;
  color: #6c757d !important;
}

#verExpedienteDrawer .drawer-historial-select:focus,
#paciente-expediente .drawer-historial-select:focus,
#verExpedienteDrawer #filtroTipoIngreso:focus,
#verExpedienteDrawer #filtroUsuario:focus,
#verExpedienteDrawer #filtroFormulario:focus {
  border-color: #86b7fe !important;
  outline: 0 !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Inputs fecha – forzar apariencia */
#verExpedienteDrawer .drawer-historial-input,
#paciente-expediente .drawer-historial-input,
#verExpedienteDrawer #filtroFechaInicio,
#verExpedienteDrawer #filtroFechaFin,
#paciente-expediente #filtroFechaInicio,
#paciente-expediente #filtroFechaFin {
  display: block !important;
  width: 100% !important;
  min-height: calc(1.5em + 0.5rem + 2px) !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  color: #212529 !important;
  background-color: #fff !important;
  border: 1px solid #ced4da !important;
  border-radius: 0.25rem !important;
}

#verExpedienteDrawer .drawer-historial-input:focus,
#paciente-expediente .drawer-historial-input:focus,
#verExpedienteDrawer #filtroFechaInicio:focus,
#verExpedienteDrawer #filtroFechaFin:focus {
  border-color: #86b7fe !important;
  outline: 0 !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Botón Filtrar – verde fijo */
#verExpedienteDrawer .drawer-historial-btn-filtrar,
#paciente-expediente .drawer-historial-btn-filtrar,
#verExpedienteDrawer #btnAplicarFiltros,
#paciente-expediente #btnAplicarFiltros {
  background-color: #28a745 !important;
  border: 1px solid #28a745 !important;
  color: #fff !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  border-radius: 0.25rem !important;
  cursor: pointer !important;
}

#verExpedienteDrawer .drawer-historial-btn-filtrar:hover,
#paciente-expediente .drawer-historial-btn-filtrar:hover,
#verExpedienteDrawer #btnAplicarFiltros:hover,
#paciente-expediente #btnAplicarFiltros:hover {
  background-color: #218838 !important;
  border-color: #1e7e34 !important;
  color: #fff !important;
}

#verExpedienteDrawer .drawer-historial-btn-filtrar:active,
#verExpedienteDrawer .drawer-historial-btn-filtrar:focus,
#paciente-expediente .drawer-historial-btn-filtrar:active,
#paciente-expediente .drawer-historial-btn-filtrar:focus,
#verExpedienteDrawer #btnAplicarFiltros:active,
#verExpedienteDrawer #btnAplicarFiltros:focus,
#paciente-expediente #btnAplicarFiltros:active,
#paciente-expediente #btnAplicarFiltros:focus {
  background-color: #1e7e34 !important;
  border-color: #1c7430 !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Botón Limpiar – secundario fijo */
#verExpedienteDrawer .drawer-historial-btn-limpiar,
#paciente-expediente .drawer-historial-btn-limpiar,
#verExpedienteDrawer #btnLimpiarFiltros,
#paciente-expediente #btnLimpiarFiltros {
  background-color: #fff !important;
  border: 1px solid #6c757d !important;
  color: #6c757d !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  border-radius: 0.25rem !important;
  cursor: pointer !important;
}

#verExpedienteDrawer .drawer-historial-btn-limpiar:hover,
#paciente-expediente .drawer-historial-btn-limpiar:hover,
#verExpedienteDrawer #btnLimpiarFiltros:hover,
#paciente-expediente #btnLimpiarFiltros:hover {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: #fff !important;
}

#verExpedienteDrawer .drawer-historial-btn-limpiar:active,
#verExpedienteDrawer .drawer-historial-btn-limpiar:focus,
#paciente-expediente .drawer-historial-btn-limpiar:active,
#paciente-expediente .drawer-historial-btn-limpiar:focus,
#verExpedienteDrawer #btnLimpiarFiltros:active,
#verExpedienteDrawer #btnLimpiarFiltros:focus,
#paciente-expediente #btnLimpiarFiltros:active,
#paciente-expediente #btnLimpiarFiltros:focus {
  background-color: #5a6268 !important;
  border-color: #545b62 !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}

/* ==========================================================================
   Drawer historial – paginación: enlaces que funcionan y página actual visible
   ========================================================================== */

#verExpedienteDrawer #paginacionHistorico,
#paciente-expediente #paginacionHistorico {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 0.5rem !important;
}

#verExpedienteDrawer #paginationLinks,
#paciente-expediente #paginationLinks {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 2px !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

#verExpedienteDrawer #paginationLinks .page-item,
#paciente-expediente #paginationLinks .page-item {
  list-style: none !important;
}

#verExpedienteDrawer #paginationLinks .page-link,
#paciente-expediente #paginationLinks .page-link {
  display: block !important;
  padding: 0.375rem 0.75rem !important;
  font-size: 0.875rem !important;
  color: #0d6efd !important;
  background-color: #fff !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 0.25rem !important;
  cursor: pointer !important;
  text-decoration: none !important;
}

#verExpedienteDrawer #paginationLinks .page-link:hover,
#paciente-expediente #paginationLinks .page-link:hover {
  background-color: #e9ecef !important;
  border-color: #dee2e6 !important;
  color: #0a58ca !important;
}

/* Página actual: siempre visible */
#verExpedienteDrawer #paginationLinks .page-item.active .page-link,
#paciente-expediente #paginationLinks .page-item.active .page-link {
  z-index: 1 !important;
  color: #fff !important;
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  cursor: default !important;
}

#verExpedienteDrawer #paginationLinks .page-item.active .page-link:hover,
#paciente-expediente #paginationLinks .page-item.active .page-link:hover {
  color: #fff !important;
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
}

/* Anterior/Siguiente deshabilitados */
#verExpedienteDrawer #paginationLinks .page-item.disabled .page-link,
#paciente-expediente #paginationLinks .page-item.disabled .page-link {
  color: #6c757d !important;
  background-color: #fff !important;
  border-color: #dee2e6 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
