/* calendar grid */
.cal-day-label {
  display: none;
  font-size: 13px;
  font-weight: 600;
  color: #777;
  margin-bottom: 4px;
}

@media screen and (max-width: 768px) {
  .cal-day-label {
    display: block;
  }
}

.cal-calendar {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
}
.cal-calendar th,
.cal-calendar td {
  border: 1px solid #ddd;
  vertical-align: top;
  padding: 8px;
  height: 140px;
  width: 14.28%;
}

/* day number */
.cal-calendar .cal-date-number {
  font-weight: bold;
  margin-bottom: 6px;
}

/* event pill: wrap text */
.cal-event {
  display: block;
  margin: 4px 0;
  padding: 4px 6px;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 3px;
  word-wrap: break-word;
  white-space: normal;
}

/* legend */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 14px;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  margin-right: 20px;
  margin-bottom: 6px;
}
.cal-legend-color {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 1px solid #ccc;
}

/* selector form */
.cal-nav-select {
  margin-bottom: 12px;
}
.cal-nav-select select {
  margin-right: 6px;
  padding: 4px;
}
.cal-nav-select button {
  padding: 4px 8px;
  cursor: pointer;
}

/* prev/next nav */
.cal-nav {
  text-align: right;
  margin-top: 12px;
}
.cal-nav a {
  margin-left: 12px;
  text-decoration: none;
  font-weight: bold;
}
.cal-event-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.cal-event-link:hover .cal-event {
  opacity: 0.9;
}
/* Responsive calendar */
@media screen and (max-width: 768px) {
  .cal-calendar {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 0;
  }

  .cal-calendar thead,
  .cal-calendar tbody,
  .cal-calendar th,
  .cal-calendar td,
  .cal-calendar tr {
    display: block;
    width: 100%;
  }

  .cal-calendar thead {
    display: none; /* Optional: hide weekday headers on small screens */
  }

  .cal-calendar tr {
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    overflow: hidden;
  }

  .cal-calendar td {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    min-height: auto;
    height: auto;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 12px;
  }

  .cal-date-number {
    font-size: 16px;
    margin-bottom: 6px;
    color: #333;
  }

  .cal-event {
    font-size: 14px;
    margin: 4px 0;
    width: 100%;
  }

  .cal-nav-select,
  .cal-nav,
  .cal-legend {
    padding: 0 8px;
  }
}

/* ===== Modal styles for CAL ===== */
.cal-event.cal-event-trigger {
  display: block;
  border: 0;
  cursor: pointer;
  text-align: left;
}

/* CAL modal: full viewport and centered */
.cal-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;   /* guarantees full viewport */
  display: none;
  z-index: 2147483647;           /* above everything */
  justify-content: center;       /* horizontal center */
  align-items: center;           /* vertical center */
}

.cal-modal[aria-hidden='false'] { display: flex; }

.cal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.cal-modal-dialog {
  position: relative;
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  z-index: 999999999999999999999;           /* above backdrop */
}

.cal-modal-close {
  position: absolute;
  right: 10px;
  top: 8px;
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}


/* Optional: focus ring for accessibility */
.cal-modal-dialog:focus,
.cal-modal-close:focus {
  outline: 2px solid #1f4170;
  outline-offset: 2px;
}

/* Prevent background scroll while open (if you add body.no-scroll) */
body.no-scroll {
  overflow: hidden;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .cal-modal-dialog {
    width: 94vw;
    padding: 18px;
    max-height: 88vh;
  }
}
/* Force centered modal even if inline CSS exists */
.cal-modal {
  justify-content: center !important;
  align-items: center !important;
}

.cal-modal[aria-hidden='false'] {
  display: flex !important;
}

.cal-modal-dialog {
  margin: 0 !important;               /* no top margin */
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow: auto;
  z-index: 2147483647;
}
