/* ==========================================
   14. 日曆組件 (Calendar Component)
   ========================================== */
#calendar-modal,
#calendar-modal * {
    -webkit-user-select: none !important;
    user-select: none !important;
}

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.cal-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 8px;
    transition: background 0.2s;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.cal-title {
    font-weight: 600;
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px 0;
    row-gap: 12px;
    column-gap: 0;
    -webkit-user-select: none !important;
    user-select: none !important;
    touch-action: none !important;
    position: relative;
    contain: layout paint;
}

.cal-days.is-dragging {
    cursor: grab;
}

.cal-day-cell {
    position: relative;
    z-index: 1;
    padding: 16px 0;
    text-align: center;
    cursor: pointer;
    border-radius: 14px;
    font-size: 18px;
    transition: background-color 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
        color 0.18s ease,
        border-radius 0.18s ease,
        transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.2s ease;
    font-weight: 500;
    box-sizing: border-box;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent;
}

/* 僅選中單一日期 */
.cal-day-cell.selected:not(.range-start):not(.range-end) {
    background: var(--primary) !important;
    color: #FAF6EE !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 12px rgba(154, 135, 30, 0.45);
}

/* 區間拖曳與劃選：起始格 */
.cal-day-cell.range-start {
    background: var(--primary) !important;
    color: #FAF6EE !important;
    font-weight: 700;
    border-top-left-radius: 14px !important;
    border-bottom-left-radius: 14px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    box-shadow: 0 4px 12px rgba(154, 135, 30, 0.45);
    z-index: 2;
}

/* 區間拖曳與劃選：結束格 */
.cal-day-cell.range-end {
    background: var(--primary) !important;
    color: #FAF6EE !important;
    font-weight: 700;
    border-top-right-radius: 14px !important;
    border-bottom-right-radius: 14px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    box-shadow: 0 4px 12px rgba(154, 135, 30, 0.45);
    z-index: 2;
}

/* 起訖為同一天時維持完全四角圓角 */
.cal-day-cell.range-start.range-end {
    border-radius: 14px !important;
}

/* 區間中間單元格：柔和黃色色塊連續平接 */
.cal-day-cell.range-between {
    background: rgba(154, 135, 30, 0.24) !important;
    color: var(--primary) !important;
    font-weight: 600;
    border-radius: 0 !important;
    box-shadow: none !important;
    z-index: 1;
}

/* 週邊界自然平滑銜接處理：每週首日（週日）與末日（週六）統一以 14px 導角銜接 */
.cal-day-cell:nth-child(7n+1).range-between {
    border-top-left-radius: 14px !important;
    border-bottom-left-radius: 14px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.cal-day-cell:nth-child(7n).range-between {
    border-top-right-radius: 14px !important;
    border-bottom-right-radius: 14px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

/* 若起始日在每週末日（週六），向右無同行相連單元格，右側收整圓角 */
.cal-day-cell:nth-child(7n).range-start {
    border-radius: 14px !important;
}

/* 若結束日在每週首日（週日），向左無同行相連單元格，左側收整圓角 */
.cal-day-cell:nth-child(7n+1).range-end {
    border-radius: 14px !important;
}

/* 當跨月時，當月首日或末日為 range-between 的邊界圓角處理 */
.cal-day-cell.range-between.range-month-start {
    border-top-left-radius: 14px !important;
    border-bottom-left-radius: 14px !important;
}

.cal-day-cell.range-between.range-month-end {
    border-top-right-radius: 14px !important;
    border-bottom-right-radius: 14px !important;
}

/* 拖曳劃選過程端點微縮放與高亮回饋（點擊無縮放，還原原始狀態） */
.cal-days.is-dragging .cal-day-cell.range-start,
.cal-days.is-dragging .cal-day-cell.range-end {
    transform: scale(1.04) translateZ(0);
}

