/* =========================================================================
   學校行事年曆專屬樣式 (assets/css/calendar.css)
   對應範本：calendar.php (Template Name: Calendar)
   ========================================================================= */

/* 主體背景與垂直間距 */
.cal-main {
    background-color: var(--bg-subtle, #f8fafc);
    padding: 2rem 0 3rem;
    min-height: 70vh;
}

@media (min-width: 640px) {
    .cal-main {
        padding: 3rem 0 4rem;
    }
}

.cal-stack,
.cal-months-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* 通用圓角卡片容器 */
.cal-card {
    background-color: #ffffff;
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

@media (min-width: 640px) {
    .cal-card {
        padding: 2rem;
    }
}

/* =========================================================================
   頁面介紹內文與舊版 W3 標籤兼容樣式
   ========================================================================= */
.cal-intro {
    width: 100%;
    color: #334155;
    font-size: 0.9rem;
    line-height: 1.75;
}

@media (min-width: 640px) {
    .cal-intro {
        font-size: 1rem;
    }
}

.cal-intro > * + * {
    margin-top: 1rem;
}

.cal-intro .w3-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    align-items: center;
}

.cal-intro .w3-quarter,
.cal-intro .w3-col.m3 {
    flex: 1 1 160px;
}

.cal-intro .w3-text-red {
    color: #dc2626;
    font-weight: 700;
}

.cal-intro .w3-text-blue {
    color: #2563eb;
    font-weight: 700;
}

.cal-intro .w3-khaki {
    background-color: #F3E59A;
    padding: 0.4rem 0.85rem;
    border-radius: 0.5rem;
    font-weight: 700;
    display: inline-block;
}

.cal-intro .w3-btn,
.cal-intro .w3-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background-color: var(--school-green, #4D602B);
    color: #ffffff !important;
    padding: 0.5rem 1.1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.cal-intro .w3-btn:hover,
.cal-intro .w3-button:hover {
    background-color: #3E4E22;
}

/* =========================================================================
   日曆顏色圖例列
   ========================================================================= */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    font-size: 0.8rem;
}

@media (min-width: 640px) {
    .cal-legend {
        font-size: 0.875rem;
    }
}

.cal-intro + .cal-legend {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

.cal-legend__label {
    font-weight: 700;
    color: #64748b;
}

.cal-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
}

.cal-legend__dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 9999px;
    display: inline-block;
    flex-shrink: 0;
}

.cal-legend__item--ph {
    color: #dc2626;
}

.cal-legend__item--ph .cal-legend__dot {
    background-color: #dc2626;
}

.cal-legend__item--sh {
    color: #2563eb;
}

.cal-legend__item--sh .cal-legend__dot {
    background-color: #2563eb;
}

.cal-legend__item--se {
    color: #1e293b;
    background-color: #F3E59A;
    padding: 0.2rem 0.65rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(252, 211, 77, 0.75);
}

.cal-legend__item--today {
    color: #ffffff;
    background-color: #9C27B0;
    padding: 0.2rem 0.65rem;
    border-radius: 0.375rem;
    box-shadow: 0 0 0 1px var(--school-gold, #DAA520), 0 1px 2px rgba(15, 23, 42, 0.08);
}

.cal-legend__item--today i {
    font-size: 0.68rem;
    color: var(--school-gold, #DAA520);
}

/* =========================================================================
   無資料空狀態
   ========================================================================= */
.cal-empty {
    background-color: #ffffff;
    border-radius: 1.5rem;
    padding: 3rem 1.5rem;
    text-align: center;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
    color: #64748b;
}

.cal-empty i {
    font-size: 2.25rem;
    color: #f59e0b;
    margin-bottom: 0.75rem;
    display: block;
}

.cal-empty__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
}

/* =========================================================================
   單月雙欄卡片（左：中文月份＋日曆表／右：英文月份＋活動清單）
   ========================================================================= */
.cal-month-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .cal-month-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        gap: 2.5rem;
    }

    .cal-month-col {
        grid-column: span 6 / span 6;
    }
}

.cal-month-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid rgba(77, 96, 43, 0.25);
}

.cal-month-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--school-green, #4D602B);
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

@media (min-width: 640px) {
    .cal-month-title {
        font-size: 1.5rem;
    }
}

.cal-month-title__bar {
    width: 0.375rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: var(--school-green, #4D602B);
    display: inline-block;
    flex-shrink: 0;
}

.cal-this-month-badge {
    background-color: #9C27B0;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.75rem;
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

/* =========================================================================
   月曆表格（消除底部白條空隙 + 假期/事項/今天顏色標示）
   ========================================================================= */
.cal-table-wrap {
    overflow: hidden;
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 2px solid var(--school-green, #4D602B);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.cal-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse !important;
    margin: 0 !important;
    text-align: left;
    font-size: 0.75rem;
}

@media (min-width: 640px) {
    .cal-table {
        font-size: 0.875rem;
    }
}

.cal-table thead tr {
    background-color: #f3f4f6;
    border-bottom: 2px solid var(--school-green, #4D602B);
}

.cal-table thead th {
    width: 14.2857%;
    padding: 0.5rem 0.375rem;
    font-weight: 700;
    color: var(--school-green, #4D602B);
    border-right: 1px solid rgba(77, 96, 43, 0.7);
}

@media (min-width: 640px) {
    .cal-table thead th {
        padding: 0.5rem;
    }
}

.cal-table thead th:last-child {
    border-right: none;
}

.cal-table thead th.is-sun {
    color: #dc2626;
}

.cal-table tbody tr {
    border-bottom: 1px solid rgba(77, 96, 43, 0.7);
}

.cal-table tbody tr:last-child {
    border-bottom: none;
}

/* 單雙數列斑馬底色 */
.cal-table tbody tr.is-odd {
    background-color: #F4F5F4;
}

.cal-table tbody tr.is-even {
    background-color: #D7E6D5;
}

.cal-table tbody td {
    height: 2.5rem;
    padding: 0 0.375rem;
    vertical-align: middle;
    border-right: 1px solid rgba(77, 96, 43, 0.7);
}

@media (min-width: 640px) {
    .cal-table tbody td {
        height: 2.75rem;
        padding: 0 0.5rem;
    }
}

.cal-table tbody td:last-child {
    border-right: none;
}

/* 格子狀態底色（今天日期優先於學校事項） */
.cal-table tbody td.is-empty {
    background-color: rgba(203, 213, 225, 0.75);
}

.cal-table tbody td.is-se {
    background-color: #F3E59A;
}

.cal-table tbody td.is-today {
    background-color: #9C27B0;
    box-shadow: inset 0 0 0 2px var(--school-gold, #DAA520);
}

/* 日期數字與循環週文字 */
.cal-day-num {
    font-weight: 700;
    color: var(--school-green, #4D602B);
}

.cal-day-num.is-ph {
    color: #dc2626;
}

.cal-day-num.is-sh {
    color: #2563eb;
}

.cal-table tbody td.is-today .cal-day-num {
    font-weight: 900;
    color: #ffffff;
}

.cal-cycle {
    font-size: 0.65rem;
    font-weight: 400;
    color: #475569;
    margin-left: 0.15rem;
}

@media (min-width: 640px) {
    .cal-cycle {
        font-size: 0.7rem;
    }
}

.cal-table tbody td.is-today .cal-cycle {
    color: #fde68a;
}

/* =========================================================================
   右欄：英文月份標題與當月活動清單
   ========================================================================= */
.cal-en-month-title {
    margin: 0 0 1rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid #e2e8f0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

@media (min-width: 640px) {
    .cal-en-month-title {
        font-size: 1.5rem;
    }
}

.cal-events-empty {
    font-size: 0.875rem;
    color: #94a3b8;
    padding: 2rem 1rem;
    text-align: center;
    background-color: #f8fafc;
    border-radius: 1rem;
    border: 1px dashed #e2e8f0;
}

.cal-events-list {
    font-size: 0.875rem;
}

.cal-event-row {
    display: flex;
    align-items: baseline;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    transition: background-color 0.18s ease;
}

.cal-event-row + .cal-event-row {
    border-top: 1px solid #f1f5f9;
}

.cal-event-row:hover {
    background-color: #f8fafc;
}

.cal-event-row.is-active {
    background-color: rgba(250, 245, 255, 0.95);
    border-left: 4px solid #9C27B0;
}

.cal-event-row__date {
    width: 5rem;
    flex-shrink: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--school-green, #4D602B);
}

@media (min-width: 640px) {
    .cal-event-row__date {
        width: 6rem;
    }
}

.cal-event-row.is-active .cal-event-row__date {
    color: #9C27B0;
}

.cal-event-row__title {
    flex: 1;
    color: #1e293b;
    font-weight: 500;
    line-height: 1.45;
}

.cal-event-today-badge {
    display: inline-block;
    margin-left: 0.375rem;
    background-color: #9C27B0;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    vertical-align: middle;
}