/* Calendar Main */
#calendar {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    padding: 40px;
    width: 45%;
    max-width: 100%;
    overflow-x: hidden;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
    box-sizing: border-box;
}

#calendar-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    cursor: pointer;

    /* Button-like appearance */
    padding: 10px 16px;
    border: 2px solid #2196F3;
    border-radius: 8px;
    background-color: #f5faff;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    gap: 10px;
}

#calendar-title:hover {
    background-color: #e3f2fd;
    border-color: #1976D2;
}

/* Visibility is owned SOLELY by check_user_in_selection.js (the `hidden`
   class), exactly like every other edit pill — the icon ships with
   class="menu-icon hidden", so it stays hidden for logged-out visitors and
   non-owners and is revealed only for the profile owner.
   Previously this pill was gated on the calendar's `.hide-icon` collapse flag
   plus `display: inline !important`. That `.hide-icon` rule had the highest
   specificity, so the pill followed the calendar's open/closed state instead
   of ownership: it was hidden for everyone while `.hide-icon` was present, and
   visible to everyone once removed. Because the initial auto-open path never
   removed `.hide-icon`, owners got no "edit dates" button at all. Dropping the
   `!important` lets the ownership `hidden` gate win, and removing the
   `.hide-icon`/`.is-visible` overrides makes it behave in every calendar state
   and entry path. */
#calendar-menu-icon {
  font-size: 24px;
  cursor: pointer;
  color: #333;
  transition: color 0.3s ease;
  flex-shrink: 0;
  margin-left: auto;
  display: inline-flex;   /* default shown; the `hidden` class (owner gate) overrides */
}

#calendar-menu-icon:hover {
    color: #ff9800;
}

#calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Keep initial hidden state */
#calendar-header,
.date-grid {
    display: none; /* Initially hidden */
}

#month-year {
    font-size: 20px;
    font-weight: bold;
}

#prev-month,
#next-month {
    font-size: 24px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #333;
}

#prev-month:hover,
#next-month:hover {
    color: #ff9800;
}

.date-grid {
    /* Layout is ready even when hidden */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

.date-grid div {
    padding: 15px;
    text-align: center;
    background: #b4d7f3;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
    min-width: 0; /* Prevent overflow on mobile */
    box-sizing: border-box;
    position: relative;          /* for cross pseudo-element */
    background-origin: padding-box;
    background-clip: padding-box;
}

.date-grid div:hover {
    background: #ff9800;
}

.date-grid.stretch-mode {
    max-height: 600px;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Today variants (no default orange) -------------------------------- */
.today {} /* marker only */

/* Today when NOT selected: use normal day colors; keep cross */
.today-unselected {} 

/* Today when selected: color comes from .black-day/.blue-days etc.; hide cross via rule below */
.today-selected {}

/* Light blue days */
.blue-days {
    background-color: #2196F3 !important;
    color: white;
}
.blue-days:hover { background-color: #1976D2 !important; }

/* Optional singular alias */
.blue-day { background-color: #2196F3; color: white; }
.blue-day:hover { background-color: #1976D2; }

/* Selected (dark) */
.black-day {
    background-color: #000 !important;
    color: white;
}
.black-day:hover { background-color: #333 !important; }

/* Day view highlight */
.date-grid div.orange-day {
    background-color: orange !important;
    color: white !important;
    border-radius: 50%;
}
.date-grid div.orange-day:hover { background-color: darkorange !important; }

/* --- Cross for UNSELECTED days ----------------------------------------- */
/* JS should add 'unselected-day' to cells that are NOT selected */
.unselected-day::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 48%;
    height: 48%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: .45;

    /* draw two thin diagonal lines */
    background-image:
      linear-gradient(45deg,
        transparent calc(50% - 1.5px),
        rgba(255,255,255,.9) calc(50% - 1.5px),
        rgba(255,255,255,.9) calc(50% + 1.5px),
        transparent calc(50% + 1.5px)),
      linear-gradient(-45deg,
        transparent calc(50% - 1.5px),
        rgba(255,255,255,.9) calc(50% - 1.5px),
        rgba(255,255,255,.9) calc(50% + 1.5px),
        transparent calc(50% + 1.5px));
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

/* never show the cross on selected/highlight cells */
.black-day::after,
.orange-day::after,
.today-selected::after { content: none; }

/* (Optional) if you use 'green-days' outside selection mode */
.green-days {
    background-color: #9fd0ff !important; /* slightly lighter than default */
    color: white;
}
.green-days:hover { background-color: #86c4ff !important; }

/* --- Unavailable (crossed-out) day cells -------------------------------- */
/* In view mode every non-bookable day carries .unselected-day AND
   aria-disabled="true" (set in buildGrid.js); available blue days and all
   edit-mode cells do NOT, so this targets only the unavailable cells.
   Requested look: white fill, blue border, blue centre X. */
.date-grid div.unselected-day[aria-disabled="true"] {
    background-color: #ffffff !important;   /* beats .green-days' !important fill */
    border: 2px solid #2196F3;              /* box-sizing:border-box already set, so no overflow */
    color: #2196F3;                         /* keep the date number readable on white */
}
/* Not bookable, so don't flip to the orange hover — stay white. */
.date-grid div.unselected-day[aria-disabled="true"]:hover {
    background-color: #ffffff !important;
}
/* Recolour the X from white to blue and make it crisp on the white fill. */
.date-grid div.unselected-day[aria-disabled="true"]::after {
    opacity: 1;
    background-image:
      linear-gradient(45deg,
        transparent calc(50% - 1.5px),
        #2196F3 calc(50% - 1.5px),
        #2196F3 calc(50% + 1.5px),
        transparent calc(50% + 1.5px)),
      linear-gradient(-45deg,
        transparent calc(50% - 1.5px),
        #2196F3 calc(50% - 1.5px),
        #2196F3 calc(50% + 1.5px),
        transparent calc(50% + 1.5px));
}

/* Itinerary lists */
#second-itinerary li {
    cursor: pointer;
    transition: background 0.3s ease-in-out;
}
#second-itinerary li:hover { background: rgba(100, 200, 255, 0.3); }
#second-itinerary li.selected {
    background: rgba(50, 150, 255, 0.5);
    font-weight: bold;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #calendar {
        width: 100% !important;
        padding: 20px !important;
        margin-bottom: 20px;
        order: -1;
        opacity: 1 !important;
        display: block !important;
    }

    #calendar-title {
        font-size: 20px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    #calendar-header {
        position: relative;
        height: 40px;
        margin-bottom: 20px;
    }

    #month-year {
        font-size: 18px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
        white-space: nowrap;
    }

    #prev-month,
    #next-month {
        position: absolute;
        top: 0;
        font-size: 20px;
        background: transparent;
        border: none;
        cursor: pointer;
    }
    #prev-month { left: 0; }
    #next-month { right: 0; }

    .date-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .date-grid div {
        padding: 12px;
        font-size: 14px;
    }
}