/* Calendar Grid Structure */
[class*="cal-cell"] {
  float: left;
  min-height: 1px;
}

.cal-row-fluid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}

.cal-row-fluid [class*="cal-cell"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

/* Responsive grid cells based on Bootstrap 5.3 */
.cal-row-fluid .cal-cell7 { width: 100%; }
.cal-row-fluid .cal-cell6 { width: 85.71428571%; }
.cal-row-fluid .cal-cell5 { width: 71.42857143%; }
.cal-row-fluid .cal-cell4 { width: 57.14285714%; }
.cal-row-fluid .cal-cell3 { width: 42.85714286%; }
.cal-row-fluid .cal-cell2 { width: 28.57142857%; }
.cal-row-fluid .cal-cell1 { width: 14.28571429%; }

/* Mobile responsive adjustments */
@media (max-width: 767.98px) {
  .cal-row-fluid .cal-cell1 {
    width: 25%; /* 4 days per row on small screens */
  }
  
  .cal-month-day {
    height: 60px !important;
  }
  
  span[data-cal-date] {
    margin-top: 5px;
    margin-right: 5px;
    font-size: 1em;
  }
  
  .cal-month-box .cal-day-today span[data-cal-date] {
    font-size: 1.2em;
  }
  
  #cal-week-box {
    display: none; /* Hide week box on mobile */
  }
  
  .events-list {
    max-height: 25px;
  }
}

@media (max-width: 575.98px) {
  .cal-row-fluid .cal-cell1 {
    width: 33.33333%; /* 3 days per row on extra small screens */
  }
}

/* Offsets */
.cal-week-box .cal-offset7,
.cal-row-fluid .cal-offset7,
.cal-row-fluid .cal-offset7:first-child { margin-left: 100%; }
.cal-week-box .cal-offset6,
.cal-row-fluid .cal-offset6,
.cal-row-fluid .cal-offset6:first-child { margin-left: 85.71428571%; }
.cal-week-box .cal-offset5,
.cal-row-fluid .cal-offset5,
.cal-row-fluid .cal-offset5:first-child { margin-left: 71.42857143%; }
.cal-week-box .cal-offset4,
.cal-row-fluid .cal-offset4,
.cal-row-fluid .cal-offset4:first-child { margin-left: 57.14285714%; }
.cal-week-box .cal-offset3,
.cal-row-fluid .cal-offset3,
.cal-row-fluid .cal-offset3:first-child { margin-left: 42.85714286%; }
.cal-week-box .cal-offset2,
.cal-row-fluid .cal-offset2,
.cal-row-fluid .cal-offset2:first-child { margin-left: 28.57142857%; }
.cal-week-box .cal-offset1,
.cal-row-fluid .cal-offset1,
.cal-row-fluid .cal-offset1:first-child { margin-left: 14.28571429%; }

/* Display utilities */
[class*="cal-cell"].hide,
.cal-row-fluid [class*="cal-cell"].hide { display: none; }

.d-none { display: none !important; }
.d-block { display: block !important; }

/* Utilities from Bootstrap 5.3 */
.float-start { float: left !important; }
.float-end { float: right !important; }

.cal-row-head [class*="cal-cell"]:first-child,
.cal-row-head [class*="cal-cell"] {
  min-height: auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-events-num {
  margin-top: 20px;
}

/* Calendar Day Styling */
.cal-month-day {
  position: relative;
  display: block;
  width: 100%;
  height: 100px;
  transition: background-color 0.2s ease;
}

#cal-week-box {
  position: absolute;
  width: 70px;
  left: -71px;
  top: -1px;
  padding: 8px 5px;
  cursor: pointer;
  border: 1px solid #dee2e6;
  border-right: 0;
  border-radius: 0.375rem 0 0 0.375rem;
  background-color: #f8f9fa;
  text-align: right;
}

#cal-day-tick {
  position: absolute;
  right: 50%;
  bottom: -21px;
  padding: 0 5px;
  cursor: pointer;
  z-index: 5;
  text-align: center;
  width: 26px;
  margin-right: -17px;
  border: 1px solid #dee2e6;
  border-top: 0;
  border-radius: 0 0 0.375rem 0.375rem;
  background-color: #e9ecef;
}

.cal-year-box #cal-day-tick {
  margin-right: -7px;
}

/* Slide box styling */
#cal-slide-box {
  position: relative;
}

#cal-slide-tick {
  position: absolute;
  width: 16px;
  margin-left: -7px;
  height: 9px;
  top: -1px;
  z-index: 1;
}

#cal-slide-tick.tick-month1 { left: 12.5%; }
#cal-slide-tick.tick-month2 { left: 37.5%; }
#cal-slide-tick.tick-month3 { left: 62.5%; }
#cal-slide-tick.tick-month4 { left: 87.5%; }
#cal-slide-tick.tick-day1 { left: 7.14285714%; }
#cal-slide-tick.tick-day2 { left: 21.42857143%; }
#cal-slide-tick.tick-day3 { left: 35.71428571%; }
#cal-slide-tick.tick-day4 { left: 50%; }
#cal-slide-tick.tick-day5 { left: 64.28571429%; }
#cal-slide-tick.tick-day6 { left: 78.57142857%; }
#cal-slide-tick.tick-day7 { left: 92.85714286%; }

/* Events styling */
.events-list {
  position: absolute;
  bottom: 0;
  left: 0;
  overflow: hidden;
  max-height: 47px;
  padding-left: 5px;
}

#cal-slide-content ul {
  margin-bottom: 0;
  padding-left: 0;
  list-style: none;
}

/* Week box styling */
.cal-week-box {
  position: relative;
}

.cal-week-box [data-event-class] {
  white-space: nowrap;
  height: 30px;
  margin: 1px;
  line-height: 30px;
  text-overflow: ellipsis;
  overflow: hidden;
  padding-left: 10px;
}

.cal-week-box .cal-column {
  position: absolute;
  height: 100%;
  z-index: -1;
  border-left: 1px solid #dee2e6;
}

.cal-week-box .arrow-before,
.cal-week-box .arrow-after {
  position: relative;
}

.cal-week-box .arrow-after:after {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  right: 0;
  border-top: 15px solid #fff;
  border-left: 8px solid;
  border-bottom: 15px solid #fff;
}

.cal-week-box .arrow-before:before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  left: 1px;
  border-top: 15px solid transparent;
  border-left: 8px solid #fff;
  border-bottom: 15px solid transparent;
}

/* Day box styling */
#cal-day-box {
  text-wrap: none;
}

#cal-day-box .cal-day-hour-part {
  height: 30px;
  box-sizing: border-box;
  border-bottom: thin dashed #dee2e6;
}

#cal-day-box .cal-day-hour .day-highlight {
  height: 30px;
}

#cal-day-box .cal-hours {
  font-weight: bold;
}

#cal-day-box .cal-day-hour:nth-child(odd) {
  background-color: #f8f9fa;
}

#cal-day-box #cal-day-panel {
  position: relative;
  padding-left: 60px;
}

#cal-day-box #cal-day-panel-hour {
  position: absolute;
  width: 100%;
  margin-left: -60px;
}

#cal-day-box .day-event {
  position: relative;
  max-width: 200px;
  overflow: hidden;
}

#cal-day-box .day-highlight {
  line-height: 30px;
  padding-left: 8px;
  padding-right: 8px;
  box-sizing: border-box;
  border: 1px solid #ced4da;
  margin: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Event colors */
.day-highlight:hover,
.day-highlight {
  background-color: #e9ecef;
}

.day-highlight.dh-event-important,
.day-highlight.dh-event-important:hover {
  background-color: #f8d7da;
  border: 1px solid #dc3545 !important;
}

.day-highlight.dh-event-warning,
.day-highlight.dh-event-warning:hover {
  background-color: #fff3cd;
  border: 1px solid #ffc107 !important;
}

.day-highlight.dh-event-info,
.day-highlight.dh-event-info:hover {
  background-color: #cff4fc;
  border: 1px solid #0dcaf0 !important;
}

.day-highlight.dh-event-inverse,
.day-highlight.dh-event-inverse:hover {
  background-color: #f8f9fa;
  border: 1px solid #212529 !important;
}

.day-highlight.dh-event-success,
.day-highlight.dh-event-success:hover {
  background-color: #d1e7dd;
  border: 1px solid #198754 !important;
}

.day-highlight.dh-event-special,
.day-highlight.dh-event-special:hover {
  background-color: #e2d9f3;
  border: 1px solid #6f42c1 !important;
}

/* Event indicators */
.event {
  display: inline-block;
  background-color: #6c757d;
  width: 12px;
  height: 12px;
  margin-right: 2px;
  margin-bottom: 2px;
  box-shadow: inset 0 0 5px 0 rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  border: 1px solid #fff;
}

.event-block {
  display: block;
  background-color: #6c757d;
  width: 20px;
  height: 100%;
}

.cal-event-list .event.float-start {
  margin-top: 3px;
}

.event-important { background-color: #dc3545; }
.event-info { background-color: #0dcaf0; }
.event-warning { background-color: #ffc107; }
.event-inverse { background-color: #212529; }
.event-success { background-color: #198754; }
.event-special { background-color: #6f42c1; }

/* Header styling */
.cal-row-head [class*="cal-cell"]:first-child,
.cal-row-head [class*="cal-cell"] {
  font-weight: bold;
  text-align: center;
  border: 0;
  padding: 5px 0;
}

.cal-row-head [class*="cal-cell"] small {
  font-weight: normal;
}

/* Hover states */
.cal-year-box .row-fluid:hover,
.cal-row-fluid:hover {
  background-color: #f8f9fa;
}

[class*="cal-cell"]:hover {
  background-color: #e9ecef;
}

/* Border management */
.cal-year-box [class*="span"],
.cal-month-box [class*="cal-cell"] {
  min-height: 100px;
  border-right: 1px solid #dee2e6;
  position: relative;
}

.cal-year-box [class*="span"] {
  min-height: 60px;
}

.cal-year-box .row-fluid [class*="span"]:last-child,
.cal-month-box .cal-row-fluid [class*="cal-cell"]:last-child {
  border-right: 0;
}

.cal-year-box .row-fluid,
.cal-month-box .cal-row-fluid {
  border-bottom: 1px solid #dee2e6;
  margin-left: 0;
  margin-right: 0;
}

.cal-year-box .row-fluid:last-child,
.cal-month-box .cal-row-fluid:last-child {
  border-bottom: 0;
}

.cal-month-box,
.cal-year-box,
.cal-week-box {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
}

/* Date display */
span[data-cal-date] {
  font-size: 1.2em;
  font-weight: normal;
  opacity: 0.5;
  cursor: pointer;
  transition: all 0.3s ease-in-out;
  margin-top: 15px;
  margin-right: 15px;
}

span[data-cal-date]:hover {
  opacity: 1;
}

.cal-day-outmonth span[data-cal-date] {
  opacity: 0.1;
  cursor: default;
}

/* Special day styling */
.cal-day-today {
  background-color: rgba(25, 135, 84, 0.1);
}

.cal-day-today span[data-cal-date] {
  color: #198754;
}

.cal-month-box .cal-day-today span[data-cal-date] {
  font-size: 1.5em;
}

.cal-day-holiday span[data-cal-date] {
  color: #6f42c1;
}

.cal-day-weekend span[data-cal-date] {
  color: #dc3545;
}

/* Slide content */
#cal-slide-content {
  padding: 20px;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.8);
  box-shadow: inset 0 0 15px 0 rgba(0, 0, 0, 0.5);
}

#cal-slide-content:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

#cal-slide-content a.event-item {
  color: #fff;
  font-weight: normal;
  line-height: 22px;
  text-decoration: none;
}

#cal-slide-content a.event-item:hover {
  color: #fff;
  text-decoration: underline;
}

/* Links */
a.cal-event-week {
  text-decoration: none;
  color: #212529;
}

/* Badge colors updated to BS5 */
.badge.bg-danger {
  background-color: #dc3545;
}

/* Mejoras generales de responsividad */
@media (max-width: 991.98px) {
  /* Ajustes para tablets */
  .cal-month-day {
    height: 85px;
  }
  
  span[data-cal-date] {
    margin-top: 10px;
    margin-right: 10px;
    font-size: 1.1em;
  }
  
  .events-list {
    max-height: 35px;
  }
}

@media (max-width: 767.98px) {
  /* Ajustes para móviles */
  .cal-row-fluid .cal-cell1 {
    width: 33.33333%; /* 3 días por fila en pantallas pequeñas */
  }
  
  .cal-month-day {
    height: 60px;
  }
  
  span[data-cal-date] {
    margin-top: 5px;
    margin-right: 5px;
    font-size: 1em;
  }
  
  .cal-month-box .cal-day-today span[data-cal-date] {
    font-size: 1.2em;
  }
  
  #cal-week-box {
    display: none; /* Ocultar caja de semana en móvil */
  }
  
  .events-list {
    max-height: 25px;
  }
  
  /* Mejorar la navegación en móvil */
  .btn-group {
    margin-bottom: 10px;
    display: flex;
    width: 100%;
  }
  
  .btn-group button {
    flex: 1;
    padding: 8px 5px;
    font-size: 0.9rem;
  }
  
  /* Ajustar el modal para móviles */
  .modal-dialog {
    margin: 10px;
  }
  
  /* Mejorar la visualización de eventos */
  #eventlist .list-group-item {
    padding: 8px;
    font-size: 0.9rem;
  }
}

@media (max-width: 575.98px) {
  /* Ajustes para móviles muy pequeños */
  .cal-row-fluid .cal-cell1 {
    width: 50%; /* 2 días por fila en pantallas muy pequeñas */
  }
  
  .cal-month-day {
    height: 50px;
  }
  
  /* Ajustar botones de navegación */
  .btn-group button {
    font-size: 0.8rem;
    padding: 6px 3px;
  }
  
  /* Reducir tamaño de los textos en general */
  body {
    font-size: 14px;
  }
  
  /* Optimizar el formulario de evento para pantallas pequeñas */
  .modal-content {
    padding: 10px;
  }
  
  .form-label {
    font-size: 0.9rem;
    margin-bottom: 3px;
  }
  
  .form-control, .form-select {
    font-size: 0.9rem;
    padding: 5px 8px;
  }
  
  /* Ajustar tamaño de las tarjetas */
  .card-body {
    padding: 10px;
  }
}

/* Mejoras para modo día y semana */
@media (max-width: 767.98px) {
  #cal-day-box .cal-day-hour-part {
    height: 25px;
  }
  
  #cal-day-box .day-highlight {
    line-height: 25px;
    padding-left: 5px;
    padding-right: 5px;
  }
  
  #cal-day-box #cal-day-panel {
    padding-left: 40px;
  }
  
  #cal-day-box #cal-day-panel-hour {
    margin-left: -40px;
  }
  
  #cal-day-box .cal-hours {
    font-size: 0.9em;
    width: 40px;
    text-align: center;
  }
}

/* Estilos de orientación para dispositivos móviles */
@media (orientation: landscape) and (max-width: 767.98px) {
  .cal-row-fluid .cal-cell1 {
    width: 20%; /* 5 días por fila en modo horizontal */
  }
}
<!-- CSS Updates for index_new.php: Add this inside your existing <style> tag -->
@media (max-width: 767.98px) {
    /* Improve calendar day cells for touch */
    .cal-month-day {
        height: 60px !important;
        min-height: 60px !important;
    }
    
    /* Make date numbers more visible */
    span[data-cal-date] {
        font-size: 1.1em !important;
        margin-top: 5px !important;
        margin-right: 5px !important;
        opacity: 0.8 !important;
    }
    
    /* Improve event dots visibility */
    .event {
        width: 8px !important;
        height: 8px !important;
    }
    
    /* Smaller event list height to avoid crowding */
    .events-list {
        max-height: 26px !important;
    }
    
    /* Make buttons more touch-friendly */
    .btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
    
    /* Improve modal form usability */
    .modal-content {
        padding: 10px;
    }
    
    .form-control, .form-select {
        height: 44px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
    
    /* Improve form labels visibility */
    .form-label {
        font-weight: bold;
        margin-bottom: 0.3rem;
    }
    
    /* Better form spacing */
    .mb-3 {
        margin-bottom: 1rem !important;
    }
    
    /* Improved modal headers for mobile */
    .modal-header h5 {
        font-size: 1.1rem;
    }
    
    /* Better card appearance on small screens */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Week view improvements */
    #cal-day-box .cal-day-hour-part {
        height: 45px !important;
    }
    
    /* Improve text truncation */
    .day-highlight {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Add new CSS for swipe support visual indicator */
.swipe-hint {
    display: none;
    text-align: center;
    padding: 8px;
    background-color: rgba(0,0,0,0.05);
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #666;
}

@media (max-width: 767.98px) {
  /* Arreglar la visualización de días de la semana */
  .cal-row-head {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
  }
  
  .cal-row-head [class*="cal-cell"] {
    width: 14.28% !important; /* 1/7 del ancho total para cada día */
    font-size: 0.8rem;
    padding: 5px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Arreglar el grid principal del calendario */
  .cal-row-fluid {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
  }
  
  .cal-row-fluid .cal-cell1 {
    width: 14.28% !important; /* Siempre 7 días por fila */
    flex: 0 0 14.28%;
  }
  
  /* Hacer las celdas más compactas pero usables */
  .cal-month-day {
    height: 50px !important;
    min-height: 50px !important;
    padding: 0;
  }
  
  /* Mejorar visibilidad de los números de día */
  span[data-cal-date] {
    font-size: 1rem !important;
    margin: 2px !important;
    opacity: 0.9 !important;
    font-weight: bold;
  }
  
  /* Mejorar visualización de eventos */
  .events-list {
    max-height: 20px !important;
    padding-left: 2px;
  }
  
  .event {
    width: 6px !important;
    height: 6px !important;
    margin-right: 1px !important;
  }
  
  /* Asegurar que el calendario no se desborde */
  .cal-month-box {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  /* Mejorar indicador de deslizamiento */
  .swipe-hint {
    padding: 5px;
    font-weight: bold;
  }
}

/* Manejar pantallas muy pequeñas */
@media (max-width: 359px) {
  .cal-row-head [class*="cal-cell"] {
    font-size: 0.7rem;
    padding: 3px 1px;
  }
  
  span[data-cal-date] {
    font-size: 0.9rem !important;
  }
}
/*************************/
/* Mejoras generales para el calendario */
.cal-month-day {
  transition: background-color 0.2s ease;
}

.cal-month-day:hover {
  background-color: rgba(0, 123, 255, 0.05);
}

/* Mejorar la visualización de hoy */
.cal-day-today {
  background-color: rgba(25, 135, 84, 0.15);
  border: 1px solid rgba(25, 135, 84, 0.3);
}

/* Mejorar la visualización de eventos */
.event {
  transition: transform 0.2s ease;
}

.cal-month-day:hover .event {
  transform: scale(1.2);
}

/* Añadir efecto sutil a la navegación entre meses */
[data-calendar-nav] {
  transition: all 0.3s ease;
}

@media (max-width: 767.98px) {
  /* Arreglar el tamaño y la organización de la botonera */
  .btn-group {
    width: 100%;
    margin-bottom: 10px;
  }
  
  .btn-group .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
  
  /* Asegurar que la vista de días de la semana sea correcta */
  .cal-row-head {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
  }
  
  .cal-row-head [class*="cal-cell"] {
    width: 14.28% !important;
    padding: 5px 2px;
    text-align: center;
    font-size: 0.8rem;
  }
  
  /* Ajustar el contenedor principal del calendario */
  .cal-month-box {
    width: 100%;
    overflow-x: hidden;
  }
  
  /* Arreglar filas del calendario */
  .cal-row-fluid {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
  }
  
  /* Establecer ancho fijo para cada día (7 días por semana) */
  .cal-row-fluid .cal-cell1 {
    width: 14.28% !important;
    flex: 0 0 14.28%;
    min-height: 50px;
  }
  
  /* Mejorar la presentación de la sección de "Eventos del mes" */
  .eventos-mes {
    margin-top: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
  }
  
  /* Mejorar el indicador de deslizamiento */
  .swipe-hint {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
    font-weight: 500;
  }
}