/* ===== LAYOUT AND COMMON STYLES ===== */
.calendar-home-header,
.calendar-current-month-title,
.calendar-headers {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 25px;
    gap: 10px;
}

.calendar-nav-home {
    margin: 0 auto 1%;
}

.calendar-current-month {
    font-size: 18px;
    font-weight: 700;
    margin: 1em auto 0;
}

.calendar-headers {
    align-items: center;
    margin: 10px 0;
    width: 100%;
}

.calendar-title {
    box-shadow: 2px 2px 5px grey;
    border-radius: 4px;
    color: #32415B;
    font-size: 22px;
    font-weight: bold;
    padding: 4px;
    text-align: center;
}

/* ===== YEAR SHORTCUTS ACCORDION ===== */
.year-shortcuts {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    margin: 0 0 8px 0;
    background: #fff;
}

.year-shortcuts > summary {
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
    list-style: none;
}

.year-shortcuts > summary::-webkit-details-marker {
    display: none;
}

.year-shortcuts > summary::after {
    content: '▸';
    float: right;
    transition: transform .15s ease;
}

.year-shortcuts[open] > summary::after {
    transform: rotate(90deg);
}

.months-row {
    padding: 6px 10px 10px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px 10px;
}

/* ===== CALENDAR LIST TABLE ===== */
.calendar-list-container {
    height: clamp(550px, 60vh, 900px);
    overflow-y: auto;
    position: relative;
}

.calendar-list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.calendar-list thead {
    background-color: #f4f4f4;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.calendar-list thead th {
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    background-color: #32415B;
    color: #fff;
    font-weight: bold;
    position: sticky;
    top: 0;
}

.calendar-list tbody tr:nth-child(even) {
    background-color: #fff;
}

.calendar-list tbody tr:nth-child(odd) {
    background-color: #eee;
}

.calendar-list tbody tr:hover {
    background-color: var(--glw-sc-list-highlight, #ffff99);
}

.calendar-list tbody td {
    padding: 5px;
    border: 1px solid #ddd;
    vertical-align: top;
}

.calendar-list td.list-date {
    text-align: center;
    vertical-align: middle;
}

.calendar-list .muted {
    font-weight: 300;
}

.calendar-list .textarea-day {
    width: 100%;
    height: auto;
    min-height: 50px;
    box-sizing: border-box;
    resize: none;
    border: none;
    background: transparent;
    padding: 5px;
    overflow: hidden;
    line-height: 1.2em;
}

.calendar-list .today-highlight {
    background-color: var(--glw-sc-list-today-highlight, #fae490) !important;
    color: var(--glw-sc-list-today-text, #000000) !important;
    font-weight: var(--glw-sc-list-today-weight, 700) !important;
}

#calendar-print-btn
{
    display: block;
    margin-top: 2em;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* ===== MOBILE STYLES (≤700px) ===== */
@media screen and (max-width: 700px) {
    .calendar-headers .prev-month {
        font-size: inherit;
    }

    .calendar-title {
        font-size: 1rem;
        padding: 6px;
    }

    /* Year shortcuts - accordion behavior */
    .year-shortcuts:not([open]) .months-row {
        display: none;
    }

    .calendar-headers .year-shortcuts {
        width: 90%;
        margin: 0 auto 8px;
        transition: width .15s ease;
    }

    .calendar-headers .year-shortcuts[open] {
        width: 95%;
    }

    .calendar-headers .year-shortcuts.future-2 {
        display: none !important;
    }

    .calendar-headers .year-prefix {
        display: none;
    }

    .calendar-headers .months-row a.prev-month {
        font-weight: 400 !important;
    }

    /* Hide original header link to avoid duplicates */
    .calendar-home-header .calendar-nav-home {
        display: none;
    }

    /* Mobile controls */
    .calendar-headers .year-shortcuts-controls {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex-wrap: nowrap;
        width: 100%;
        margin: 0.5rem 0;
    }

    .calendar-headers .year-shortcuts-controls .mobile-current-month-link {
        display: inline-block;
        text-decoration: none;
        background-color: #32415B;
        color: #fff;
        border: 1px solid #32415B;
        border-radius: 4px;
        padding: 6px 10px;
        font-weight: 600;
        line-height: 1.2;
    }

    .calendar-headers .year-shortcuts-controls .mobile-current-month-link:focus,
    .calendar-headers .year-shortcuts-controls .mobile-current-month-link:active {
        outline: 2px solid #000;
        outline-offset: 2px;
    }

    /* Hide table header on mobile */
    .calendar-list thead {
        display: none;
    }

    /* Convert table to cards */
    .calendar-list,
    .calendar-list tbody,
    .calendar-list tr,
    .calendar-list td {
        display: block;
        width: 100%;
    }

    .calendar-list tr.calendar-day-row {
        border: 1px solid #e5e5e5;
        border-radius: 6px;
        padding: 0.5rem 0.75rem;
        margin: 0 0 0.75rem 0;
        background: #fff;
    }

    .calendar-list td.list-date {
        font-size: 1.05rem;
        font-weight: 700;
        padding: 0.5rem 0 0.25rem 0;
    }

    .calendar-list tr.calendar-day-row.today-highlight {
        background-color: var(--glw-sc-list-today-highlight, #fae490) !important;
        color: var(--glw-sc-list-today-text, #000000) !important;
        font-weight: var(--glw-sc-list-today-weight, 700) !important;
    }

    .calendar-list tr.calendar-day-row.today-highlight td.list-date.today-highlight {
        background: transparent !important;
    }

    .calendar-list td[data-th] {
        padding: 0.5rem 0;
        text-align: center;
    }

    .calendar-list td[data-th]::before {
        content: attr(data-th);
        display: block;
        font-weight: 600;
        color: #333;
        margin: 0 0 0.25rem 0;
    }

    .calendar-list tr.muted-month {
        opacity: 0.75;
    }

    .calendar-list textarea.textarea-day {
        width: 100%;
        min-height: 4.5rem;
        box-sizing: border-box;
        font-size: 1rem;
    }
}

/* ===== DESKTOP STYLES (≥701px) ===== */
@media (min-width: 701px) {
    /* Responsive font sizing for month links */
    .calendar-headers .prev-month {
        font-size: clamp(0.75rem, 2vw, 1rem);
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        font-weight: normal;
    }

    /* Ensure all year shortcuts have consistent width and layout */
    .calendar-headers .year-shortcuts {
        border: 0;
        background: transparent;
        margin: 0 0 0 0;
        width: 100%;
        box-sizing: border-box;
    }

    .year-shortcuts > summary {
        display: none;
    }

    /* Make the year column wider - change from 5ch to wider first column */
    .calendar-headers .year-shortcuts .months-row {
        display: grid !important;
        padding: 0;
        margin: 0;
        width: 100%;
        grid-template-columns: 12ch repeat(12, minmax(0, 1fr)); /* Increased from 5ch to 8ch */
        gap: 0px 8px;
        box-sizing: border-box;
    }

    /* Hide mobile-only controls */
    .calendar-headers .js-year-expand-all,
    .calendar-headers .js-year-collapse-all,
    .calendar-headers .year-shortcuts-controls .mobile-current-month-link {
        display: none !important;
    }

    /* Year prefix styling - match the wider column */
    .calendar-headers .year-prefix {
        display: inline-block;
        margin-right: 0.5rem;
        font-weight: 600;
        white-space: nowrap;
        text-align: right;
        align-self: center;
        width: 8ch; /* Match the grid column width */
        box-sizing: border-box;
    }

    /* Rest of the styles remain the same... */
    .calendar-headers .year-shortcuts.current-year {
        position: relative;
        filter: none;
        margin: -10px 0 1px 0;
        width: 100%;
        background-color: rgba(238, 230, 221, 0.5);
    }

    /*
    .calendar-headers .year-shortcuts.current-year::before {
        content: '';
        position: absolute;
        top: -2px;
        left: -20px;
        right: -5px;
        bottom: -2px;
        background-color: rgba(238, 230, 221, 0.5);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        z-index: -1;
        pointer-events: none;
    }
    */

    .calendar-headers .year-shortcuts.previous-year,
    .calendar-headers .year-shortcuts.future-1,
    .calendar-headers .year-shortcuts.future-2 {
        margin: -10px 0 0 0;
        width: 100%;
        opacity: 0.9;
        filter: grayscale(30%);
        transition: opacity 0.3s ease, filter 0.3s ease;
    }


    .calendar-headers .year-shortcuts.previous-year:hover,
    .calendar-headers .year-shortcuts.future-1:hover,
    .calendar-headers .year-shortcuts.future-2:hover {
        opacity: 1;
        filter: grayscale(0%);
    }
}
