/* ── CALENDAR CONTAINER ──────────────────────────────────────────── */
.calendar-container {
  background-color: #0a1f4d; /* Azul profundo elegante */
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  color: #F9FAFB;
  font-family: 'Inter', sans-serif;
  border: none;
}

/* ── HEADER ─────────────────────────────────────────────────────── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px; /* Reducido */
  background-color: transparent;
}
.calendar-header h2 {
  font-size: 24px; /* Reducido de 36px */
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0;
}
.calendar-header h2 span {
  color: #9CA3AF;
  font-weight: 400;
}
.calendar-stats { display: none; }

.calendar-controls { display: flex; align-items: center; gap: 8px; }

.nav-btn, .today-btn {
  width: 36px; height: 36px; /* Reducido */
  border-radius: 10px;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid #374151;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover, .today-btn:hover { background: rgba(55, 65, 81, 0.8); }

.today-btn {
  width: auto;
  padding: 0 14px;
  font-size: 13px; /* Reducido */
  font-weight: 600;
}

/* ── LEYENDA (Oculta para mantener el clon limpio) ──────────────── */
.cal-legend { display: none; }

/* ── WEEKDAYS ────────────────────────────────────────────────────── */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  padding: 0 32px 8px; /* Reducido */
  background-color: transparent;
  border: none;
}
.weekday {
  text-align: center;
  font-size: 12px; /* Reducido */
  font-weight: 500;
  color: #9CA3AF;
  text-transform: none;
  letter-spacing: normal;
}

/* ── GRID ────────────────────────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  padding: 0 32px 24px; /* Reducido */
}

/* ── DAY CARD ────────────────────────────────────────────────────── */
.cal-day {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  height: 80px; /* Reducido un 20% (de 100px a 80px) */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
  color: #fff;
  margin: 0;
}

.cal-day:hover {
  background: rgba(255, 255, 255, 0.1);
  z-index: 5;
}

/* Número del día */
.cal-day-num {
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Hover de HOY (borde blanco sutil) */
.cal-day.cal-today {
  border: 1.5px solid rgba(255,255,255,0.4);
}

/* ── FERIADO BLOQUEADO ─────────────────────────────────────────── */
.cal-day.cal-feriado-blocked {
  background: rgba(31, 41, 55, 0.9);
  cursor: not-allowed;
  pointer-events: none;
}
.cal-day[data-title]:hover::after {
  content: attr(data-title);
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: rgba(10, 15, 30, 0.98);
  color: #fff;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── FERIADOS NACIONALES (Línea) ────────────────────────────────── */
.holiday-container {
  position: absolute;
  bottom: 12px;
  width: 80%;
  border-bottom: 2px solid;
  text-align: center;
}
.holiday-text {
  position: absolute;
  top: -16px;
  left: 0;
  width: 100%;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── EVENT (Visita Programada) ──────────────────────────────────── */
.cal-day.event-blue {
  background: linear-gradient(135deg, #60A5FA, #3B82F6);
  border: none;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 12px;
  z-index: 1;
}

.cal-day.event-blue:not(.block-prev) {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}
.cal-day.event-blue:not(.block-next) {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* ── EVENT (Visita Completada) ──────────────────────────────────── */
.cal-day.event-completed {
  background: linear-gradient(135deg, #2DD4BF, #0891b2);
  border: none;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 12px;
  z-index: 1;
}

.cal-day.event-completed:not(.block-prev) {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}
.cal-day.event-completed:not(.block-next) {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  box-shadow: 0 4px 15px rgba(8, 145, 178, 0.3);
}

/* ── EVENT (Visita Reprogramada) ──────────────────────────────────── */
.cal-day.event-reprogrammed {
  background: linear-gradient(135deg, #f472b6, #db2777); /* Pink shades */
  border: none;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 12px;
  z-index: 1;
}
.cal-day.event-reprogrammed:not(.block-prev) { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.cal-day.event-reprogrammed:not(.block-next) { border-top-right-radius: 12px; border-bottom-right-radius: 12px; box-shadow: 0 4px 15px rgba(219, 39, 119, 0.3); }

/* ── EVENT-SECOND (Diferenciador 2ª Visita) ─────────────────────── */
.cal-day.event-second::after {
  content: '2ª';
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
  z-index: 2;
}

.cal-day.event-second {
  border: 1px dashed rgba(255, 255, 255, 0.4) !important;
}

/* ── RESPONSIVE PARA CELULARES ──────────────────────────────────── */
@media (max-width: 768px) {
  .calendar-weekdays { gap: 4px; padding: 0 16px 8px; }
  .calendar-grid { 
    gap: 4px; /* Gap bien chiquito para ganar espacio */
    padding: 0 16px 16px;
  }
  
  .cal-day { 
    aspect-ratio: 1 / 1 !important; 
    height: auto !important;
    min-height: 0 !important;
    padding: 6px 2px; 
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  
  .cal-day-empty { 
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
  }

  /* Desactivar spanning horizontal en mobile */
  .cal-day.event-blue {
    grid-column: span 1 !important; 
    padding: 6px;
    margin-bottom: 0px;
    justify-content: center !important;
    align-items: center !important;
  }

  /* Los redondos de los bloques los forzamos para que siempre se vean bien */
  .cal-day.event-blue:not(.block-prev),
  .cal-day.event-blue:not(.block-next),
  .cal-day.event-blue.block-prev,
  .cal-day.event-blue.block-next,
  .cal-day.event-completed:not(.block-prev),
  .cal-day.event-completed:not(.block-next),
  .cal-day.event-completed.block-prev,
  .cal-day.event-completed.block-next,
  .cal-day.event-reprogrammed:not(.block-prev),
  .cal-day.event-reprogrammed:not(.block-next),
  .cal-day.event-reprogrammed.block-prev,
  .cal-day.event-reprogrammed.block-next {
    border-radius: 8px !important;
  }

  .cal-day-num { font-size: 16px; margin-bottom: 4px; }
  .day-number-event { font-size: 10px; margin-bottom: 2px; }
  
  .event-title { 
    font-size: 10.5px; 
    -webkit-line-clamp: 2; 
    line-clamp: 2;
    margin-top: 4px;
    line-height: 1.1;
    font-weight: 700;
  }
  
  .event-time { font-size: 8px; font-weight: 700; opacity: 0.9; }
  .event-meta { margin-top: 4px; gap: 4px; }

  .event-badge-count {
    bottom: 2px;
    right: 2px;
    font-size: 7.5px;
    padding: 1px 3px;
  }

  /* Feriados en mobile */
  .holiday-text { font-size: 7px; top: -12px; }
  .holiday-container { bottom: 6px; width: 90%; }
}

/* Fix para pantallas MUY chiquitas (iPhone SE, etc) */
@media (max-width: 380px) {
  .calendar-header h2 { font-size: 20px; }
  .weekday { font-size: 11px; }
  .event-time { display: none; } /* Ocultar hora si ya no hay espacio */
  .event-icon { margin-right: 0; }
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.event-icon {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.9);
  color: #3498DB;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  flex-shrink: 0;
}
.event-time {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.day-number-event {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  align-self: flex-end; /* Top right corner */
  line-height: 1;
  margin-bottom: auto;
}

.event-details {
  width: 100%;
}
.event-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-badge-count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.event-more {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}

/* ── SUMMARY ────────────────────────────────────────────────────── */
.calendar-summary { padding: 0 12px 12px; }

/* ── RESPONSIVE MÓVIL ────────────────────────────────────────────── */
@media (max-width: 768px) {
  #view-calendario {
    min-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
  }
  #view-calendario .calendar-container {
    flex: 1;
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    display: flex;
    flex-direction: column;
  }
  #view-calendario .calendar-grid { flex: 1; }

  .cal-day        { height: 65px; padding: 5px 6px; border-radius: 9px; }
  .cal-day-empty  { height: 65px; }
  .cal-day-num    { font-size: 12px; }
  .cal-day.cal-today .cal-day-num {
    width: 22px; height: 22px; font-size: 11px;
  }
  .cal-badge      { font-size: 8px; padding: 1px 4px; }
  .cal-badges     { gap: 2px; }
  .cal-day[data-title]:hover::after { font-size: 9px; }

  .calendar-header  { padding: 12px 14px; margin-bottom: 4px !important; }
  .calendar-header h2 { font-size: 20px; }
  .calendar-controls { width: auto; justify-content: flex-end; margin-top: 0; }
  .calendar-weekdays { padding: 4px 10px; gap: 6px; }
  .calendar-grid     { padding: 0 10px 10px; gap: 6px; display: grid; grid-template-columns: repeat(7, 1fr) !important; }
  .cal-legend        { padding: 6px 10px; gap: 10px; }
  .cal-legend-item   { font-size: 10px; }

  /* MÓVIL: Indicador tipo iOS/Moderno */
  .cal-programada-mobile {
    position: relative;
    background: rgba(255, 255, 255, 0.03) !important;
  }
  .cal-dot-indicator {
    width: 6px;
    height: 6px;
    background: #60A5FA;
    border-radius: 50%;
    margin-top: 4px;
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.6);
  }
  .cal-badge-mobile {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #FF4757;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    min-width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}