/* =====================================================================
   ไฟล์: assets/css/calendar.css
   หน้าที่: หน้าตาของปฏิทิน (รายเดือน ภาคเรียน หน้าสาธารณะ) รายการกิจกรรมของวัน และฟอร์มกิจกรรม
   - สีกลุ่มงานส่งมาทางตัวแปร --event-color (ตั้งโดย CalendarCore.applyColors)
   - จอเล็ก (ต่ำกว่า 768px): ช่องวันที่แสดงเป็นจุดสี และดูรายละเอียดได้จากรายการใต้ปฏิทิน
   ===================================================================== */

/* ---------------------------------------------------------------------
   1) แถบหัวปฏิทิน
   --------------------------------------------------------------------- */
.calendar-card {
    padding: 1.25rem;
}

.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.9rem;
}

.calendar-heading {
    min-width: 0;
}

.calendar-title {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.25;
    color: var(--wbsp-blue-dark);
}

.calendar-subtitle {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--wbsp-red);
}

.calendar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* [ปรับปรุง] กล่องแถบกลุ่มงาน: เดิมเป็นพื้นฟ้าอ่อน ตอนนี้ภายในเป็นปุ่มเม็ดยาแถวเดียว (.filter-bar) จึงไม่ต้องมีพื้นหลัง */
.calendar-legend {
    margin-bottom: 0.9rem;
}

.calendar-legend:empty {
    display: none;
}

.legend-swatch.is-today {
    background: #fff;
    border: 2px solid var(--calendar-today-ring);
}

/* ---------------------------------------------------------------------
   2) ตารางเดือน — [เขียนใหม่] แถบกิจกรรมต่อเนื่องหลายวัน
   แต่ละสัปดาห์ (.cal-week) = ชั้นพื้นหลัง (.cal-week-bg: ช่องวันที่ 7 ช่อง คลิกได้)
                             + ชั้นเนื้อหา (.cal-week-content: CSS Grid 7 คอลัมน์ เลขวันที่ + แถบกิจกรรม)
   [ใช้ของเดิม] สีวันนี้ วันหยุด วันเสาร์-อาทิตย์ วันของเดือนอื่น และหัวตารางวันในสัปดาห์
   --------------------------------------------------------------------- */
.cal-month {
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface);
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-weekday {
    padding: 0.55rem 0.25rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
    background: var(--wbsp-blue);
}

.cal-weekday.is-weekend {
    background: var(--wbsp-blue-dark);
}

.cal-weekday-short {
    display: none;
}

/* หนึ่งสัปดาห์ */
.cal-week {
    position: relative;
    min-height: 118px;
    border-bottom: 1px solid var(--app-border);
}

.cal-week:last-child {
    border-bottom: 0;
}

/* ชั้นพื้นหลัง: ช่องวันที่ */
.cal-week-bg {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-day {
    min-width: 0;
    border-right: 1px solid var(--app-border);
    background: var(--app-surface);
    transition: background-color 0.15s ease;
}

.cal-day:last-child {
    border-right: 0;
}

.cal-month.is-interactive .cal-day {
    cursor: pointer;
}

.cal-month.is-interactive .cal-day:hover {
    background: var(--wbsp-blue-50);
}

.cal-day:focus-visible {
    z-index: 2;
    outline: 3px solid rgba(30, 58, 138, 0.45);
    outline-offset: -3px;
}

.cal-day.is-weekend {
    background: var(--calendar-weekend-bg);
}

.cal-day.is-holiday {
    background: var(--calendar-holiday-bg);
}

.cal-day.is-other-month {
    background: #F7F8FB;
}

.cal-day.is-today {
    box-shadow: inset 0 0 0 2px var(--calendar-today-ring);
}

/* ชั้นเนื้อหา: แถวที่ 1 = หัวช่องวันที่, แถวถัดไป = ช่องแถวของแถบกิจกรรม */
.cal-week-content {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: auto;
    align-content: start;
    row-gap: 3px;
    padding-bottom: 6px;
    pointer-events: none; /* คลิกทะลุไปที่ช่องวันที่ ยกเว้นแถบกิจกรรมและ "+ อีก n รายการ" */
}

.cal-day-head {
    min-width: 0;
    padding: 4px 5px 0;
}

.cal-day-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
}

.cal-day-number {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    padding: 0 4px;
    font-weight: 700;
    color: var(--app-text);
    border-radius: 999px;
}

.cal-day-head.is-red .cal-day-number {
    color: var(--wbsp-red);
}

.cal-day-head.is-other-month .cal-day-number {
    color: #A0A7B4;
}

.cal-day-head.is-today .cal-day-number {
    color: #fff;
    background: var(--wbsp-red);
}

.cal-today-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--wbsp-red);
}

.cal-holiday {
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--wbsp-red-dark);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cal-day-head.is-other-month .cal-holiday,
.cal-day-head.is-other-month .cal-dots {
    opacity: 0.55;
}

/* แถบกิจกรรม: พาดยาวหลายวัน ตัดคำด้วย ... เมื่อยาวเกิน */
.cal-bar {
    --event-color: #64748B;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    margin: 0 4px;
    padding: 1px 7px;
    overflow: hidden;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--app-text);
    background: #EEF1F6;
    background: color-mix(in srgb, var(--event-color) 16%, #fff);
    border-left: 4px solid var(--event-color);
    border-radius: 6px;
    pointer-events: auto;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.cal-bar:hover {
    filter: brightness(0.95);
}

/* กิจกรรมต่อมาจากสัปดาห์ก่อน / ต่อไปสัปดาห์ถัดไป: ชิดขอบตารางและตัดมุมโค้งด้านนั้น */
.cal-bar.continues-before {
    margin-left: 0;
    border-left-width: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-bar.continues-after {
    margin-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-bar-arrow {
    flex-shrink: 0;
    color: var(--event-color);
}

.cal-bar-time {
    flex-shrink: 0;
    font-weight: 700;
    color: var(--event-color);
}

.cal-bar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cal-bar-private {
    flex-shrink: 0;
    color: var(--app-text-muted);
}

.cal-month:not(.is-interactive) .cal-bar {
    cursor: default;
}

.cal-month:not(.is-interactive) .cal-bar:hover {
    filter: none;
}

.cal-more {
    padding-left: 8px;
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--wbsp-blue);
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: auto;
    cursor: pointer;
}

/* จุดสี (แสดงเฉพาะจอเล็ก) */
.cal-dots {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
}

.cal-dot {
    --event-color: #64748B;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--event-color);
}

.cal-dot-more {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--app-text-muted);
}

/* ---------------------------------------------------------------------
   3) รายการกิจกรรมใต้ปฏิทิน (Agenda)
   --------------------------------------------------------------------- */
.agenda-day + .agenda-day {
    margin-top: 1rem;
}

.agenda-date {
    margin-bottom: 0.4rem;
    font-weight: 700;
    color: var(--wbsp-blue-dark);
}

.agenda-list {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.agenda-item {
    --event-color: #64748B;
    display: flex;
    align-items: stretch;
    gap: 0.65rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    text-align: left;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
}

button.agenda-item:hover {
    background: var(--wbsp-blue-50);
}

.agenda-bar {
    width: 5px;
    border-radius: 3px;
    background: var(--event-color);
    flex-shrink: 0;
}

.agenda-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.agenda-title {
    font-weight: 600;
}

.agenda-meta {
    font-size: 0.9rem;
    color: var(--app-text-muted);
}

.agenda-private {
    color: var(--app-text-muted);
}

/* [เพิ่มใหม่] วันหยุดในรายการกิจกรรม (ตั้งค่า "แสดงในรายการกิจกรรม" ที่ ตั้งค่า > วันหยุด) */
.agenda-item.is-holiday {
    --event-color: var(--wbsp-red);
    background: var(--calendar-holiday-bg, var(--wbsp-red-50));
    border-color: var(--wbsp-red-100);
}

button.agenda-item.is-holiday:hover {
    background: var(--wbsp-red-100);
}

.agenda-item.is-holiday .agenda-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--wbsp-red-dark);
}

/* ---------------------------------------------------------------------
   4) หน้าต่างรายการกิจกรรมของวัน
   --------------------------------------------------------------------- */
.day-modal-subtitle {
    margin-top: 0.15rem;
    font-size: 0.95rem;
    color: var(--app-text-muted);
}

.day-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-item {
    --event-color: #64748B;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface);
}

.day-item-bar {
    width: 6px;
    border-radius: 3px;
    background: var(--event-color);
    flex-shrink: 0;
}

.day-item-content {
    flex: 1 1 260px;
    min-width: 0;
}

.day-item-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--wbsp-blue-dark);
}

.day-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.85rem;
    margin-top: 0.25rem;
    font-size: 0.9rem;
    color: var(--app-text-muted);
}

.day-item-description {
    margin-top: 0.4rem;
    font-size: 0.95rem;
    white-space: pre-line;
}

.day-item-actions {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

/* ---------------------------------------------------------------------
   5) ฟอร์มกิจกรรม
   --------------------------------------------------------------------- */
.event-form-section {
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
}

.event-form-legend {
    float: none;
    width: auto;
    margin: 0 0 0.5rem;
    padding: 0 0.35rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--wbsp-blue);
}

.event-date-preview {
    min-height: 1.6rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.95rem;
    color: var(--wbsp-blue-dark);
    background: var(--wbsp-blue-50);
    border-radius: var(--app-radius-sm);
}

.event-date-preview:empty {
    display: none;
}

.event-date-preview.is-error {
    color: var(--wbsp-red-dark);
    background: var(--wbsp-red-50);
}

.event-public-box {
    padding: 0.85rem 1rem;
    background: var(--wbsp-blue-50);
    border-radius: var(--app-radius-sm);
}

.event-form-footer {
    justify-content: space-between;
    gap: 0.75rem;
}

.event-save-hint {
    font-size: 0.92rem;
    color: var(--app-warning);
}

.event-save-hint.is-ready {
    color: var(--app-success);
}

.event-form-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ---------------------------------------------------------------------
   6) แท็บเล็ตและสมาร์ทโฟน
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .cal-week {
        min-height: 100px;
    }

    .cal-bar {
        font-size: 0.76rem;
        padding: 1px 5px;
    }

    .cal-bar-time {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .calendar-card {
        padding: 0.85rem;
    }

    .calendar-title {
        font-size: 1.35rem;
    }

    .calendar-nav {
        width: 100%;
    }

    .calendar-nav .btn {
        flex: 1 1 0;
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }
}

/* สมาร์ทโฟน: ปุ่มเลื่อนเดือน/ภาคเรียนแสดงเป็นลูกศรใหญ่ ส่วนปุ่ม "วันนี้" ยังมีข้อความ */
@media (max-width: 575.98px) {
    .calendar-nav-text {
        display: none;
    }

    .calendar-nav .btn .icon {
        width: 1.5em;
        height: 1.5em;
    }
}

@media (max-width: 767.98px) {

    .cal-weekday {
        padding: 0.4rem 0;
        font-size: 0.85rem;
    }

    .cal-weekday-full {
        display: none;
    }

    .cal-weekday-short {
        display: inline;
    }

    /* สมาร์ทโฟน: ซ่อนแถบกิจกรรม แสดงเป็นจุดสีใต้เลขวันที่ (ดูรายละเอียดจากรายการใต้ปฏิทิน) */
    .cal-week {
        min-height: 64px;
    }

    .cal-day-head {
        padding: 3px 2px 0;
        text-align: center;
    }

    .cal-day-top {
        justify-content: center;
    }

    .cal-day-number {
        min-width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .cal-today-badge,
    .cal-holiday,
    .cal-bar,
    .cal-more {
        display: none;
    }

    .cal-dots {
        display: flex;
        justify-content: center;
        margin-top: 2px;
    }

    .cal-day-head.has-events .cal-day-number {
        text-decoration: underline;
        text-decoration-thickness: 2px;
        text-underline-offset: 3px;
    }

    .event-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .event-form-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .event-form-buttons .btn-primary {
        grid-column: 1 / -1;
        order: -1;
    }

    .day-item-actions {
        width: 100%;
    }

    .day-item-actions .btn {
        flex: 1 1 0;
    }
}

/* ---------------------------------------------------------------------
   7) ปฏิทินภาคเรียน: ปุ่มเลือกเดือน และปุ่มเดือนก่อน/ถัดไปใต้ปฏิทิน
   --------------------------------------------------------------------- */
.semester-months {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.semester-month-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-height: 54px;
    padding: 0.35rem 0.25rem;
    font-weight: 600;
    color: var(--wbsp-blue-dark);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
}

.semester-month-button:hover {
    background: var(--wbsp-blue-50);
}

.semester-month-button.is-active {
    color: #fff;
    background: var(--wbsp-blue);
    border-color: var(--wbsp-blue);
    box-shadow: inset 0 -3px 0 var(--wbsp-red);
}

.semester-month-count {
    min-width: 26px;
    padding: 0 0.4rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--app-text-muted);
    background: #EEF1F6;
    border-radius: 999px;
}

.semester-month-count.has-events {
    color: #fff;
    background: var(--wbsp-red);
}

.semester-month-button.is-active .semester-month-count {
    color: var(--wbsp-blue-dark);
    background: #fff;
}

.semester-month-nav {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.semester-month-nav .btn {
    color: var(--wbsp-blue);
    border: 1px solid var(--app-border);
}

@media (max-width: 767.98px) {
    .semester-months {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .semester-month-nav .btn {
        flex: 1 1 0;
        font-size: 0.9rem;
    }
}

/* =====================================================================
   [เพิ่มใหม่] มุมมองภาพรวม (ปฏิทินย่อหลายเดือน) — assets/js/mini-calendar.js
   ใช้ใน: ภาพรวมปีการศึกษา (หน้าปฏิทินรายเดือน) และ ภาพรวมภาคเรียน (หน้าปฏิทินภาคเรียน)
   สีจุดกิจกรรมส่งมาทางตัวแปร --dot-color (ตั้งโดย MiniCalendar.applyColors)
   ===================================================================== */

/* ปุ่มสลับมุมมอง (Segmented Control) */
.calendar-viewbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.view-switch {
    display: inline-flex;
    padding: 4px;
    background: var(--wbsp-blue-50);
    border: 1px solid var(--wbsp-blue-100);
    border-radius: 999px;
}

.view-switch-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 40px;
    padding: 0.3rem 1rem;
    font-weight: 600;
    color: var(--wbsp-blue);
    background: transparent;
    border: 0;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.view-switch-button:hover {
    background: var(--wbsp-blue-100);
}

.view-switch-button.is-active {
    color: #fff;
    background: var(--wbsp-blue);
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.25);
}

.view-switch-button:focus-visible {
    outline: 3px solid rgba(30, 58, 138, 0.35);
    outline-offset: 2px;
}

/* ตารางเดือนย่อ: ปีการศึกษา 4 / 3 / 2 / 1 คอลัมน์ตามความกว้างจอ, ภาคเรียนสูงสุด 3 คอลัมน์ */
.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.mini-cal-grid.is-semester {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-month {
    padding: 0.85rem 0.8rem 0.9rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mini-month.is-current {
    border-color: var(--wbsp-blue-100);
}

.mini-month.is-active {
    border-color: var(--wbsp-blue);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.mini-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.mini-month-title {
    padding: 0.1rem 0.3rem;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--wbsp-blue-dark);
    background: none;
    border: 0;
    border-radius: 6px;
}

button.mini-month-title:hover,
button.mini-month-title:focus-visible {
    color: var(--wbsp-blue);
    text-decoration: underline;
}

.mini-month-count {
    min-width: 1.8rem;
    padding: 0.05rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    color: var(--app-text-muted);
    background: var(--app-bg);
    border-radius: 999px;
}

.mini-month-count.has-events {
    color: #fff;
    background: var(--wbsp-red);
}

.mini-weekdays,
.mini-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.mini-weekdays {
    margin-bottom: 4px;
    padding: 3px 0;
    font-size: 0.74rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
    background: var(--wbsp-blue);
    border-radius: 6px;
}

.mini-weekdays .is-weekend {
    color: #FFD5D5;
}

/* ช่องวันที่: ตัวเลข + จุดสี (ความสูงคงที่ ไม่ให้ตารางบิดเมื่อมีจุดมาก/น้อย) */
.mini-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    min-height: 40px;
    padding: 4px 0 3px;
    font-size: 0.85rem;
    line-height: 1.2;
    color: var(--app-text);
    border-radius: 8px;
    outline: none;
}

.mini-day.is-blank {
    visibility: hidden;
}

.mini-day.is-weekend .mini-day-number {
    color: var(--wbsp-red);
}

.mini-day.is-holiday {
    background: var(--calendar-holiday-bg, #FDE8E8);
}

.mini-day.is-holiday .mini-day-number {
    font-weight: 700;
    color: var(--wbsp-red-dark);
}

.mini-day.has-events {
    background: var(--wbsp-blue-50);
}

.mini-day.has-events .mini-day-number {
    font-weight: 700;
    color: var(--wbsp-blue-dark);
}

.mini-day.is-holiday.has-events {
    background: linear-gradient(180deg, var(--calendar-holiday-bg, #FDE8E8) 0%, var(--wbsp-blue-50) 100%);
}

.mini-day.is-today {
    box-shadow: inset 0 0 0 2px var(--calendar-today-ring, var(--wbsp-red));
}

.mini-day.is-today .mini-day-number {
    color: var(--wbsp-red);
}

.mini-day[role="button"] {
    cursor: pointer;
}

.mini-day[role="button"]:hover {
    background: var(--wbsp-blue-100);
}

.mini-day[role="button"]:focus-visible {
    box-shadow: 0 0 0 2px var(--wbsp-blue);
}

.mini-dots {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 2px;
    height: 7px;
}

.mini-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    background: var(--dot-color, #64748B);
    border-radius: 50%;
}

.mini-dot-more {
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 7px;
    color: var(--app-text-muted);
}

.mini-tooltip .mini-dot {
    width: 9px;
    height: 9px;
}

/* [ปรับปรุง] ไอคอนสีหน้าข้อความ = สี่เหลี่ยมขอบมน (มาตรฐานเดียวกับแถบกลุ่มงาน) */
.mini-dot.is-square {
    border-radius: 2px;
}

/* กล่องสรุปเมื่อชี้เมาส์ (ตำแหน่งตั้งด้วยตัวแปรจาก JavaScript) */
.mini-tooltip {
    position: absolute;
    top: var(--tooltip-top, 0);
    left: var(--tooltip-left, 0);
    z-index: 1080;
    width: max-content;
    max-width: min(300px, calc(100vw - 16px));
    padding: 0.6rem 0.75rem;
    font-size: 0.86rem;
    color: #fff;
    background: var(--wbsp-blue-dark);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    pointer-events: none;
}

.mini-tooltip[hidden] {
    display: none;
}

.mini-tooltip-date {
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.mini-tooltip-holiday {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.25rem;
    color: #FFC9C9;
}

.mini-tooltip-list {
    display: grid;
    gap: 0.2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mini-tooltip-list li {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.mini-tooltip-list .mini-dot {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
    transform: translateY(-1px);
}

.mini-tooltip-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.mini-tooltip-time {
    color: #C7D2FE;
}

.mini-tooltip-empty,
.mini-tooltip-more {
    color: #C7D2FE;
}

@media (max-width: 1199.98px) {
    .mini-cal-grid,
    .mini-cal-grid.is-semester {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .mini-cal-grid,
    .mini-cal-grid.is-semester {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .calendar-viewbar,
    .view-switch {
        width: 100%;
    }

    .view-switch-button {
        flex: 1 1 0;
        justify-content: center;
        padding: 0.3rem 0.5rem;
        font-size: 0.92rem;
    }

    .mini-cal-grid,
    .mini-cal-grid.is-semester {
        grid-template-columns: 1fr;
    }

    .mini-day {
        min-height: 44px; /* ช่องใหญ่ขึ้นให้แตะง่ายบนมือถือ */
        font-size: 0.95rem;
    }
}

/* มุมมองภาพรวมใช้จอเต็มกว้าง: ไม่ต้องซ่อนรายการเหมือนตารางเดือนบนจอเล็ก */
@media print {
    .calendar-viewbar {
        display: none;
    }
}

/* =====================================================================
   [เพิ่มใหม่] แถบกลุ่มงานแถวเดียว (CalendarCore.filterBarHtml)
   แทน Legend เดิม + แถบสรุปจำนวน ใช้ทั้งปฏิทินรายเดือน ภาคเรียน มุมมองภาพรวม และหน้าสาธารณะ
   ไอคอนสี = .legend-swatch (สี่เหลี่ยมขอบมน จาก app.css) ทุกกลุ่มงาน
   ===================================================================== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 34px;
    padding: 0.2rem 0.6rem;
    font-size: 0.86rem;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 999px;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

button.filter-chip:hover {
    background: var(--wbsp-blue-50);
    border-color: var(--wbsp-blue-100);
}

button.filter-chip:focus-visible {
    outline: 3px solid rgba(30, 58, 138, 0.3);
    outline-offset: 1px;
}

.filter-chip .legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.filter-chip-count {
    font-weight: 700;
    color: var(--wbsp-blue-dark);
}

/* ปุ่ม "กิจกรรมทั้งหมด": น้ำเงินทึบเมื่อไม่ได้กรอง */
.filter-chip.is-total {
    color: var(--wbsp-blue);
    border-color: var(--wbsp-blue-100);
}

.filter-chip.is-total.is-active {
    color: #fff;
    background: var(--wbsp-blue);
    border-color: var(--wbsp-blue);
}

.filter-chip.is-total.is-active .filter-chip-count {
    color: #fff;
}

/* ปุ่มกลุ่มงานที่กำลังกรอง: ขอบหนาสีน้ำเงิน, กลุ่มอื่นจางลง */
.filter-chip.is-active:not(.is-total) {
    background: var(--wbsp-blue-50);
    border-color: var(--wbsp-blue);
    box-shadow: inset 0 0 0 1px var(--wbsp-blue);
}

.filter-chip.is-dimmed {
    opacity: 0.55;
}

.filter-chip.is-static {
    color: var(--app-text-muted);
    background: transparent;
    border-style: dashed;
}

/* สถานะพิเศษ (วันนี้ / ไม่แสดงต่อบุคคลภายนอก): ข้อความเรียบ ไม่ใช่ปุ่ม */
.filter-bar-divider {
    width: 1px;
    height: 22px;
    margin: 0 0.1rem;
    background: var(--app-border);
}

.filter-note {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.15rem;
    font-size: 0.84rem;
    white-space: nowrap;
    color: var(--app-text-muted);
}

.filter-note .legend-swatch.is-today {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* จอขนาดกลาง (ต่ำกว่า 1400px): ย่อคำนำหน้า "กลุ่มบริหาร" ให้แถบอยู่ในแถวเดียว (ชื่อเต็มอยู่ใน title) */
@media (max-width: 1399.98px) {
    .filter-chip-prefix {
        display: none;
    }
}

/* แท็บเล็ต/จอเล็ก: คงเป็นแถวเดียว กระชับขึ้น และเลื่อนดูด้านข้างได้ถ้ายาวเกินจอ */
@media (max-width: 1199.98px) {
    .filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.3rem;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .filter-bar > li {
        flex-shrink: 0;
    }

    .filter-chip {
        padding: 0.2rem 0.5rem;
        font-size: 0.84rem;
    }
}
