/* Mobile-first: base variables */
:root {
  --slot-height: 80px;
  --time-col-width: 70px;
  --touch-shadow: 0 0 0 2px rgba(13, 110, 253, 0.12);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f5f7fb;
  min-height: 100vh;
}

.bg-soft {
  background: #f5f7fb;
}

.navbar {
  border-bottom: 1px solid #eef1f5;
  background: #0d47a1 !important;
}

.navbar .nav-link,
.navbar .navbar-brand,
.navbar span {
  color: #fff !important;
}

/* Barra inferior mobile (no altera escritorio) */
.mobile-bottom-nav {
  background: #ffffff;
  border-top: 1px solid #e6e9ef;
  z-index: 1030;
}

.mobile-bottom-nav .nav-link {
  color: #6c757d;
  font-weight: 600;
  padding: 0.55rem 0.25rem;
}

.mobile-bottom-nav .nav-link span {
  display: block;
  font-size: 0.75rem;
}

.mobile-bottom-nav .nav-link.active {
  color: #0d47a1;
}

.card {
  border: 1px solid #e6e9ef;
  border-radius: 12px;
}

.badge {
  font-weight: 600;
  letter-spacing: 0.1px;
}

.list-group-item {
  border-left: 0;
  border-right: 0;
}

.list-group-item:first-child {
  border-top: 0;
}

.list-group-item:last-child {
  border-bottom: 0;
}

.btn {
  min-height: 48px;
  border-radius: 10px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.dropdown-item {
  min-height: 44px;
}

.btn-outline-primary.active {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.table thead th {
  white-space: nowrap;
}

.schedule-wrapper {
  border: 1px solid #e6e9ef;
  border-radius: 0.5rem;
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.schedule-wrapper table {
  margin: 0;
  table-layout: fixed;
  border-collapse: collapse;
  width: 100%;
  min-width: 780px;
}

.schedule-wrapper th,
.schedule-wrapper td {
  padding: 0;
}

.schedule-wrapper thead th {
  text-align: center;
  vertical-align: middle;
  background: #f8f9fb;
  position: sticky;
  top: 0;
  z-index: 2;
}

.schedule-wrapper tbody tr {
  height: var(--slot-height, 80px);
}

.time-col {
  width: var(--time-col-width);
  min-width: var(--time-col-width);
  max-width: var(--time-col-width);
  background: #f8f9fb;
  font-size: 12px;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 3;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.04);
}

.day-col {
  width: calc((100% - var(--time-col-width)) / 7);
  min-width: 120px;
  font-size: 13px;
}

.time-col small {
  font-size: 12px;
  color: #555;
}

.schedule-cell {
  min-width: 120px;
  vertical-align: top;
  background: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.2s ease;
  position: relative;
  height: var(--slot-height, 80px);
  overflow: visible;
  padding: 0;
  touch-action: manipulation;
}

.schedule-cell:hover {
  background: #f1f5ff;
}

.schedule-cell:active {
  background: #e8f1ff;
}

.schedule-item {
  border: 1px solid #e6e9ef;
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  background: #cfe8ff;
  color: #0b3c6f;
  font-weight: 600;
  font-size: 0.9rem;
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  z-index: 2;
  pointer-events: auto;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.schedule-item:active {
  transform: translateY(1px);
  box-shadow: var(--touch-shadow);
}

.schedule-cell.selected {
  background: #d9f7d9 !important;
}

.schedule-cell .add-label {
  opacity: 0;
  transition: opacity 0.15s ease;
  display: block;
  text-align: center;
}

.schedule-cell:hover .add-label {
  opacity: 1;
}

.touch-active {
  box-shadow: var(--touch-shadow);
  background-color: #f3f6ff !important;
}

.navbar .touch-active {
  background-color: rgba(255, 255, 255, 0.15) !important;
}

.logo-floating {
  position: fixed;
  bottom: 12px;
  left: 12px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

/* Mobile-first: hide floating logo on tablets/phones */
@media (max-width: 991.98px) {
  .logo-floating {
    display: none;
  }
}

/* Mobile-first: layout tuning for phones */
@media (max-width: 767.98px) {
  .schedule-wrapper {
    border-radius: 0.75rem;
  }

  .schedule-wrapper table {
    min-width: 920px;
  }

  .schedule-wrapper tbody tr {
    height: 88px;
  }

  /* Espacio para la barra inferior fija en mobile */
  body {
    padding-bottom: 76px;
  }

  .mobile-bottom-nav .nav-link {
    font-size: 0.95rem;
  }

  .btn,
  .form-control,
  .form-select {
    font-size: 1rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* Mobile-first: smallest screens refinements */
@media (max-width: 575.98px) {
  .table {
    font-size: 0.95rem;
  }

.schedule-item {
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
}
}

/* ============================================
   ESTILOS: Tarjetas de pacientes
   ============================================
   Agregado: 2024-12-02
   Propósito: Efecto hover para tarjetas clickeables
   ============================================ */

.hover-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15) !important;
}

/* Estado activo al hacer click */
.hover-card:active {
  transform: translateY(-2px);
}

/* ============================================
   ESTILOS: Timeline de Ficha Clínica
   ============================================
   Agregado: 2024-12-02
   Propósito: Visualización cronológica de atenciones médicas
   ============================================ */

/* Contenedor principal del timeline */
.timeline-item {
  position: relative;
}

/* Marcador visual (punto + línea) */
.timeline-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 24px;
}

/* Punto circular del timeline */
.timeline-dot {
  width: 16px;
  height: 16px;
  background: #0d6efd; /* Azul Bootstrap primary */
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(13, 110, 253, 0.4);
  z-index: 2;
  flex-shrink: 0;
}

/* Línea conectora entre puntos */
.timeline-line {
  width: 2px;
  flex-grow: 1;
  background: linear-gradient(
    to bottom, 
    #0d6efd 0%, 
    #dee2e6 100%
  );
  margin-top: 4px;
  min-height: 20px;
}

/* Efecto hover en las tarjetas del timeline */
.timeline-item .card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-item .card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

/* Responsividad: en móvil, reducir gap */
@media (max-width: 576px) {
  .timeline-item .d-flex {
    gap: 1rem !important;
  }
  
  .timeline-dot {
    width: 12px;
    height: 12px;
    border-width: 2px;
  }
}

/* ============================================
   ESTILOS: Badges del timeline
   ============================================ */

/* Badge del profesional con mejor contraste */
.timeline-item .badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35em 0.65em;
}

/* ============================================
   ESTILOS: Alertas en timeline
   ============================================ */

/* Alerta de próxima visita más compacta */
.timeline-item .alert-warning {
  background-color: #fff3cd;
  border-color: #ffc107;
  color: #856404;
}

.timeline-item .alert-warning small {
  font-size: 0.875rem;
}

/* ============================================
   ESTILOS: Loading states
   ============================================ */

/* Spinner de carga */
.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}

/* ============================================
   ESTILOS: Formulario del modal
   ============================================ */

/* Mejorar legibilidad de labels */
.modal-body .form-label {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

/* Textareas con altura consistente */
.modal-body textarea.form-control {
  resize: vertical;
  min-height: calc(1.5em + 0.75rem + 2px);
}

/* Focus states más visibles */
.modal-body .form-control:focus,
.modal-body .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

/* ============================================
   ESTILOS: Mejoras de accesibilidad
   ============================================ */

/* Mejor contraste en texto muted */
.text-muted {
  color: #6c757d !important;
}

/* Links con mejor indicación visual */
a:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* Botones con estados disabled claros */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   MEJORAS MOBILE-FIRST - VERSION 3.2.0
   ============================================
   Agregado: 2025-12-04
   Propósito: Mejoras para vista móvil de agenda y pacientes
   ============================================ */

/* Mobile day-column view for agenda */
.mobile-day-selector {
  display: none; /* Hidden on desktop */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.mobile-day-selector::-webkit-scrollbar {
  height: 4px;
}

.mobile-day-selector::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.mobile-day-selector .day-btn {
  min-width: 80px;
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #495057;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.mobile-day-selector .day-btn.active {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

.mobile-day-selector .day-btn:not(.active):hover {
  background: #f8f9fa;
}

/* Patient list view styles */
.patients-list-view {
  width: 100%;
}

.patients-list-view .table {
  margin-bottom: 0;
}

.patients-list-view .table-hover tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.patients-list-view .table-hover tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.05);
}

.patients-list-view .table-hover tbody tr:active {
  background-color: rgba(13, 110, 253, 0.1);
}

/* View toggle buttons */
.view-toggle-buttons .btn {
  min-width: 44px;
}

.view-toggle-buttons .btn i {
  font-size: 1.25rem;
}

/* ============================================
   RESPONSIVE: Mobile breakpoint (< 768px)
   ============================================ */
@media (max-width: 767px) {
  /* Show mobile day selector */
  .mobile-day-selector {
    display: flex;
  }

  /* Hide inactive day columns in weekly view */
  .schedule-wrapper .day-col:not(.active-mobile-day) {
    display: none;
  }

  .schedule-wrapper .day-col.active-mobile-day {
    width: calc(100% - var(--time-col-width)) !important;
    min-width: auto;
  }

  /* Remove horizontal scroll when showing single day */
  .schedule-wrapper table {
    min-width: 100%;
  }

  /* Increase touch targets for mobile */
  .schedule-cell {
    min-height: 88px;
  }

  /* Compact week navigation */
  #week-range-label {
    font-size: 0.75rem;
    flex: 1 0 100%;
    text-align: center;
    margin-top: 0.5rem;
  }

  /* Hide text labels on small buttons, show icons only */
  .btn .d-none.d-sm-inline {
    display: none !important;
  }

  /* Stack patient card actions vertically */
  .hover-card .d-flex.gap-2 {
    flex-direction: column;
  }

  /* Compact table for patient list view */
  .patients-list-view .table {
    font-size: 0.875rem;
  }

  .patients-list-view .table th,
  .patients-list-view .table td {
    padding: 0.5rem 0.25rem;
  }

  .patients-list-view .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Full-screen modals on mobile */
  .modal-fullscreen-sm-down {
    max-width: 100%;
    margin: 0;
  }

  .modal-fullscreen-sm-down .modal-content {
    height: 100vh;
    border-radius: 0;
  }

  /* Larger form controls for touch */
  .modal .form-control,
  .modal .form-select {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 48px;
  }
}

/* ============================================
   RESPONSIVE: Small phones (< 576px)
   ============================================ */
@media (max-width: 575px) {
  /* Even more compact spacing */
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Smaller badges */
  .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  /* Compact cards */
  .card-body {
    padding: 0.75rem;
  }

  /* Smaller schedule items */
  .schedule-item {
    font-size: 0.75rem;
    padding: 0.25rem 0.35rem;
  }

  /* Mobile navigation adjustments */
  .mobile-bottom-nav .nav-link {
    padding: 0.5rem 0.125rem;
    font-size: 0.875rem;
  }

  .mobile-bottom-nav .nav-link i {
    font-size: 1.25rem;
  }

  .mobile-bottom-nav .nav-link span {
    font-size: 0.65rem;
  }
}

/* ============================================
   RESPONSIVE: Tablets (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
  /* Show all days but with slightly smaller columns */
  .day-col {
    min-width: 100px;
  }

  .schedule-item {
    font-size: 0.85rem;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  /* Hide navigation and non-essential elements */
  .navbar,
  .mobile-bottom-nav,
  .logo-floating,
  .btn,
  .mobile-day-selector {
    display: none !important;
  }

  /* Show all schedule columns */
  .schedule-wrapper .day-col {
    display: table-cell !important;
  }

  /* Remove shadows and backgrounds */
  .card,
  .shadow-sm {
    box-shadow: none !important;
    border: 1px solid #dee2e6 !important;
  }

  /* Optimize for paper */
  body {
    padding-bottom: 0;
    background: #fff;
  }

  .schedule-wrapper {
    page-break-inside: avoid;
  }
}

/* ================================
   FIX: Header sticky al hacer scroll
   ================================ */

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #fff;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 1rem !important;
}

.sticky-header-mobile {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #fff;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* ================================
   Agenda Diaria: Cards de citas
   ================================ */

.appointment-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid #e0e0e0;
  border-left: 4px solid #0d6efd;
}

.appointment-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.appointment-card .card-title {
  color: #0d6efd;
  font-size: 1rem;
  font-weight: 600;
}

.appointment-card .appointment-info p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: #495057;
}

.appointment-card .appointment-info strong {
  color: #212529;
  font-weight: 600;
}

.appointment-card .appointment-info i {
  width: 20px;
  text-align: center;
}

.appointment-card hr {
  border-top: 2px solid #f0f0f0;
}

/* ================================
   HITO 2: Vista mobile día por día en agenda semanal
   ================================ */

/* En mobile (<768px), ocultar todas las columnas de día excepto la activa */
@media (max-width: 767px) {
  #weekly-view .day-col {
    display: none;
  }

  /* Mostrar solo la columna del día activo (controlado por JS con clase) */
  #weekly-view .day-col.active-mobile-day {
    display: table-cell !important;
  }

  /* La columna de hora siempre visible */
  #weekly-view .time-col {
    display: table-cell;
  }

  /* Asegurar que el label muestre el día en mobile */
  #week-range-label {
    font-size: 0.875rem;
    font-weight: 500;
  }

  /* FIX: Botones con misma altura en mobile */
  #daily-view .btn,
  #daily-view .form-control,
  #daily-view .form-select,
  #weekly-view .btn,
  #weekly-view .form-control,
  #weekly-view .form-select {
    height: 38px !important;
    min-height: 38px;
  }

  /* Agenda diaria mobile: botones en una línea */
  #daily-view .d-flex.flex-wrap {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Date picker ocupa espacio flexible */
  #daily-date-picker {
    flex-grow: 1;
    max-width: none !important;
    min-width: 120px;
  }

  /* Botones cuadrados tienen tamaño fijo */
  #daily-prev-day,
  #daily-next-day,
  #refresh-today {
    flex-shrink: 0;
  }

  /* Botón Hoy tiene tamaño automático */
  #daily-today-btn {
    flex-shrink: 0;
  }

  /* Selectores de box mobile */
  #boxFilterMobile {
    min-width: 120px !important;
    width: auto !important;
  }
}

/* ============================================ */
/* HEADER AGENDA COMPACTO v4.1.1 */
/* ============================================ */
.hl-agenda-header-compact {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s ease;
}

.hl-agenda-header-compact:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Contenedor principal - Mobile: columnas, Desktop: fila */
.hl-agenda-buttons-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

/* Toggle de vistas - botones pegados */
.hl-agenda-toggle {
  gap: 0;
  width: 100%;
}

.hl-agenda-toggle .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right-width: 0.5px;
}

.hl-agenda-toggle .btn:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 0.5px;
}

.hl-agenda-toggle .btn {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Botón nueva cita */
.hl-new-appointment-btn {
  width: 100%;
}

/* DESKTOP: Todo en una fila con espacios */
@media (min-width: 768px) {
  .hl-agenda-buttons-container {
    flex-direction: row;
    gap: 1rem;
    align-items: stretch;
  }

  .hl-agenda-toggle {
    flex: 0 0 auto;
    width: auto;
    min-width: 320px;
  }

  .hl-new-appointment-btn {
    flex: 1;
    min-width: 200px;
  }
}

/* MOBILE: Ajustes responsivos */
@media (max-width: 767px) {
  .hl-agenda-header-compact {
    padding: 0.75rem !important;
  }

  .hl-agenda-toggle .btn {
    font-size: 0.9rem;
    min-height: 44px;
  }
}

/* ============================================ */
/* UNIFICACIÓN DE CARDS v4.1.0 */
/* ============================================ */
.hl-card {
  background: #ffffff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  height: 100%;
}

.hl-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
  border-color: #0d6efd;
}

.hl-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.5rem;
}

.hl-card-subtitle {
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 0.75rem;
}

.hl-card-info {
  font-size: 0.875rem;
  color: #495057;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.hl-card-info i {
  color: #0d6efd;
  font-size: 1rem;
}

.hl-card-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e6e9ef;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Badges en cards */
.hl-card .badge {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  font-weight: 600;
}

/* ============================================ */
/* TOOLBAR AGENDA TIPO RESERVO v4.1.0 */
/* ============================================ */
.hl-agenda-toolbar {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s ease;
}

.hl-agenda-toolbar:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Zona izquierda: icono + título */
.hl-agenda-toolbar-left {
  min-width: 140px;
}

.hl-agenda-toolbar-left i {
  flex-shrink: 0;
}

.hl-agenda-toolbar-left h5 {
  color: #212529;
  font-size: 1.15rem;
  white-space: nowrap;
}

/* Zona central: navegación semanal */
.hl-agenda-toolbar-center {
  padding: 0 1rem;
}

.hl-agenda-toolbar-center #week-range-label,
.hl-agenda-toolbar-center #week-range-label-mobile {
  min-width: 120px;
  text-align: center;
}

/* Zona derecha: filtros */
.hl-agenda-toolbar-right {
  min-width: 200px;
}

/* Responsive: móvil */
@media (max-width: 767px) {
  .hl-agenda-toolbar {
    padding: 1rem !important;
  }

  .hl-agenda-toolbar-left h5 {
    font-size: 1rem;
  }
}

/* Ajustes para mantener sticky headers */
.sticky-header,
.sticky-header-mobile {
  position: sticky;
  top: 0;
  background: #f5f7fb;
  z-index: 10;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* ============================================ */
/* TOOLBAR V2 - TIPO AGENDAPRO v4.2.0 */
/* ============================================ */
.hl-agenda-toolbar-v2 {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s ease;
}

.hl-agenda-toolbar-v2:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Toggle Ver por profesional / Ver por box */
.hl-view-mode-toggle {
  border-radius: 8px;
}

.hl-view-mode-toggle .btn {
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.hl-view-mode-toggle .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.hl-view-mode-toggle .btn:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.hl-view-mode-toggle .btn.active {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

/* Buscador de pacientes */
#patient-search-wrapper .dropdown-menu,
#patient-search-wrapper-mobile .dropdown-menu {
  position: absolute;
  z-index: 1000;
  display: none;
  width: 100%;
}

#patient-search-wrapper .dropdown-menu.show,
#patient-search-wrapper-mobile .dropdown-menu.show {
  display: block;
}

#patient-search-results .dropdown-item,
#patient-search-results-mobile .dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

#patient-search-results .dropdown-item:hover,
#patient-search-results-mobile .dropdown-item:hover {
  background-color: #f8f9fa;
}

#patient-search-results .dropdown-item:last-child,
#patient-search-results-mobile .dropdown-item:last-child {
  border-bottom: none;
}

/* Iconos de acciones (estados, profesionales) */
.hl-agenda-toolbar-v2 .btn[data-bs-toggle="dropdown"] {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* Dropdown de estados de cita */
#appointment-statuses-menu .badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  padding: 0;
  display: inline-block;
}

/* Dropdown de profesionales */
#professionals-list-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Responsive: Mobile */
@media (max-width: 767px) {
  .hl-agenda-toolbar-v2 {
    padding: 0.75rem !important;
  }

  .hl-view-mode-toggle .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }

  /* Buscador en mobile - ancho completo */
  #patient-search-wrapper-mobile {
    width: 100%;
  }

  #patient-search-agenda-mobile {
    width: 100% !important;
  }
}

/* Responsive: Tablet */
@media (min-width: 768px) and (max-width: 991px) {
  .hl-agenda-toolbar-v2 {
    gap: 0.5rem;
  }

  .hl-view-mode-toggle .btn {
    font-size: 0.8rem;
  }
}

/* ============================================
   REPORTES: Estilos Mobile-First
   ============================================
   Mejoras de UX para tablas de reportes en mobile
   ============================================ */

/* Optimización de scroll horizontal en tablas */
.table-responsive {
  -webkit-overflow-scrolling: touch; /* Smooth scrolling en iOS */
  border-radius: 0.375rem; /* Bordes redondeados */
}

/* Mobile: Mejor espaciado en cards de KPIs */
@media (max-width: 767px) {
  /* Cards de KPIs más compactos en mobile */
  .card-body h4 {
    font-size: 1.5rem;
  }

  .card-body small {
    font-size: 0.75rem;
  }

  /* Tabs de navegación más grandes (mejor touch) */
  #reports-tabs .nav-link {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  /* Filtros: stack en una columna */
  .card-body .row.g-2 > div {
    margin-bottom: 0.5rem;
  }

  /* Tablas: texto más pequeño pero legible */
  .table-sm {
    font-size: 0.85rem;
  }

  .table-sm th,
  .table-sm td {
    padding: 0.5rem 0.35rem;
  }

  /* Badges más compactos */
  .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
  }

  /* Evitar que textos largos rompan el diseño */
  .table td {
    white-space: nowrap;
  }

  /* Botón aplicar filtros más prominente */
  #btn-apply-income-filters,
  #btn-apply-resumen-filters {
    padding: 0.6rem 1rem;
    font-weight: 600;
  }
}

/* Scrollbar styling para mejor UX */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #ced4da;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #adb5bd;
}

/* ============================================
   HORALY-REPORTES-CAJA-RAPIDA: Botones de Acción Rápida
   ============================================ */

/* Estilo base para botones de acción en reportes */
.action-btn-payment {
  white-space: nowrap;
  transition: all 0.2s ease;
}

/* Asegurar que los botones sean accesibles en mobile (48px+ según WCAG 2.1) */
.action-btn-payment {
  min-height: 36px;
  min-width: 36px;
}

/* Feedback visual al hacer hover en desktop */
@media (min-width: 768px) {
  .action-btn-payment:hover {
    transform: scale(1.05);
  }
}

/* Optimizaciones para mobile */
@media (max-width: 767px) {
  /* Botones de acción: solo íconos en mobile, ocultar texto */
  .action-btn-payment .d-none.d-md-inline {
    display: none !important;
  }

  /* Aumentar tamaño de toque en mobile para accesibilidad */
  .action-btn-payment {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
  }

  /* Iconos más grandes en mobile */
  .action-btn-payment i {
    font-size: 1.1rem;
  }
}

/* Animación de feedback visual cuando se actualiza una fila */
@keyframes highlightRow {
  0% {
    background-color: #d1e7dd;
  }
  100% {
    background-color: transparent;
  }
}

.table-success {
  animation: highlightRow 2s ease-in-out;
}

/* ============================================
   FICHA CLÍNICA - Bloque Clínico A (UX Mejorado)
   ============================================
   Estilos específicos para la página de ficha clínica
   Mobile-first, optimizado para pantallas táctiles
   ============================================ */

/* Encabezado del paciente */
.ficha-clinica-header {
  border-top: 4px solid var(--bs-primary);
}

.ficha-clinica-pet-name {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--bs-dark);
  line-height: 1.2;
}

.ficha-clinica-pet-info .badge {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
}

.ficha-clinica-owner-info h6 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Botones de acción principales */
.ficha-clinica-actions .btn {
  min-height: 44px; /* WCAG 2.1 - área táctil mínima */
  font-weight: 500;
}

.ficha-clinica-actions .btn-lg {
  min-height: 52px;
  font-size: 1.1rem;
}

/* Timeline clínico */
.ficha-clinica-timeline .card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Marcadores del timeline */
.timeline-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--bs-primary);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--bs-primary);
  z-index: 1;
}

.timeline-line {
  width: 2px;
  flex-grow: 1;
  background-color: #dee2e6;
  margin-top: 4px;
}

/* Cards del timeline */
.timeline-card {
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.timeline-card:hover {
  border-left-color: var(--bs-primary);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12) !important;
  transform: translateY(-2px);
}

/* v5.1.7: Registros de solo lectura (profesionales viendo atenciones de otros) */
.timeline-card.readonly-record {
  background-color: #f8f9fa;
  opacity: 0.95;
}

.timeline-card.readonly-record:hover {
  border-left-color: #6c757d;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08) !important;
  transform: none;
}

.timeline-card .card-body {
  padding: 1.25rem;
}

/* Responsive para mobile */
@media (max-width: 767px) {
  /* Encabezado más compacto */
  .ficha-clinica-pet-name {
    font-size: 1.5rem;
  }

  .ficha-clinica-pet-info .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    margin-bottom: 0.25rem;
  }

  /* Botones de acción apilados */
  .ficha-clinica-actions {
    margin-top: 1rem;
  }

  .ficha-clinica-actions .btn {
    width: 100%;
  }

  /* Timeline más compacto */
  .timeline-item {
    margin-bottom: 1.5rem !important;
  }

  .timeline-card .card-body {
    padding: 1rem;
  }

  .timeline-marker {
    margin-right: 0.75rem;
  }

  .timeline-dot {
    width: 12px;
    height: 12px;
  }

  /* Ocultar hint de "Click en una atención" en mobile */
  .ficha-clinica-timeline small.text-muted {
    display: none;
  }
}

/* Tablets */
@media (min-width: 768px) and (max-width: 991px) {
  .ficha-clinica-pet-name {
    font-size: 1.65rem;
  }

  .timeline-card .card-body {
    padding: 1.15rem;
  }
}

/* Desktop grande */
@media (min-width: 1200px) {
  .ficha-clinica-pet-name {
    font-size: 2rem;
  }

  /* Layout en 2 columnas si hay suficiente espacio */
  .ficha-clinica-header .col-lg-8 {
    flex: 0 0 auto;
    width: 70%;
  }

  .ficha-clinica-header .col-lg-4 {
    flex: 0 0 auto;
    width: 30%;
  }
}
