body { font-family: 'Kanit', sans-serif; }
/* ปรับแต่งปฏิทินให้เข้ากับฟอนต์และธีม */
.fc { font-family: 'Kanit', sans-serif; }
.fc-event { cursor: pointer; }
/* ลดช่องว่างในช่องปฏิทินให้กระชับขึ้น */
.fc-daygrid-event { padding: 2px 5px !important; margin: 2px 0 !important; }
.fc-daygrid-day-bottom { padding: 0 !important; margin-top: 0 !important; }
.fc-daygrid-day-frame { padding-bottom: 0px !important; }
.fc-daygrid-more-link { padding-left: 10px !important; font-size: 0.75rem !important; margin-top: -2px !important; margin-bottom: -10px !important; color: #a855f7 !important; }

/* ให้แถวแรกของงานเริ่มบรรทัดเดียวกับเลขวันที่ */
.fc-daygrid-day-top {
    text-align: right !important;
    height: 0 !important;
    padding: 0 !important;
    z-index: 2;
}
.fc-daygrid-day-number { 
    display: inline-block !important;
    padding: 2px 4px !important; 
}
.fc-daygrid-day-events {
    padding-top: 2px !important;
    padding-right: 25px !important; /* เว้นที่ให้เลขวันที่ทางขวา */
}

/* ให้แถวที่ hover หรือมีสีพิเศษ แสดงสีสม่ำเสมอ รวมทั้งช่องที่ sticky และ dropdown เฉพาะในตารางหลัก */
.dashboard-table tr { background-color: white; }
.dashboard-table tr.bg-red-50 { background-color: #fef2f2 !important; } /* สีแดงสำหรับงานด่วน */

/* กำหนดพื้นหลังทึบให้ช่องที่ sticky และ select เพื่อป้องกันการโปร่งแสง เฉพาะในตารางหลัก */
.dashboard-table td.sticky, .dashboard-table th.sticky, .dashboard-table select { 
    background-color: white !important; 
    opacity: 1 !important; 
}
.dashboard-table tr.bg-red-50 td.sticky, .dashboard-table tr.bg-red-50 select { 
    background-color: #fef2f2 !important; 
}
.dashboard-table tr:hover, .dashboard-table tr:hover td.sticky, .dashboard-table tr:hover select { 
    background-color: #f9fafb !important; 
}
.dashboard-table th.sticky { 
    background-color: #e5e7eb !important; /* bg-gray-200 ให้ตรงกับ header */
}
.dashboard-table select.text-center { text-align-last: center; }
.dashboard-table td.officer-cell { overflow: visible; }
/* Allow officer dropdown to escape the overflow-auto scroll container */
.officer-options { position: fixed !important; }



/* ปรับแต่งสีในปฏิทิน (FullCalendar) */
.fc-list-event-time { color: #374151 !important; font-weight: 700; }
.fc-event-done .fc-list-event-title, 
.fc-event-done .fc-event-title { 
    color: #9ca3af !important; /* ชื่องานสีเทา */
}
.fc-event-done .fc-list-event-dot {
    border-color: #22c55e !important; /* จุดยังคงเป็นสีเขียว */
}

/* Column Resizing */
th { position: relative; }
.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: rgba(0,0,0,0.05);
    cursor: col-resize;
    user-select: none;
    transition: background 0.2s;
}
.resizer:hover { background: rgba(59, 130, 246, 0.5); }
.resizing { border-right: 2px solid #3b82f6; }

/* Global Unified Scrollbar Style */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #D3D3D3; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #C0C0C0; }

/* File Popover */
.file-popover {
    position: absolute;
    z-index: 100;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    padding: 0.5rem;
    display: none;
}
.file-popover.active { display: block; }

/* สไตล์ Dropdown ให้เหมือนปุ่มของ FullCalendar (ปุ่มวันนี้) */
.fc-view-select {
    appearance: none;
    background-color: #2c3e50; /* FullCalendar 6 default primary */
    border: 1px solid #2c3e50;
    color: white;
    padding: 4px 24px 4px 12px;
    border-radius: 4px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    height: 32px;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3e%3cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 12px;
    transition: all 0.1s ease;
}
.fc-view-select:hover {
    background-color: #1e2b37;
    border-color: #1e2b37;
}
.fc-view-select:focus {
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.2);
}
/* Date Range Popover */
.date-range-popover {
    position: fixed;
    z-index: 9999;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px -8px rgba(0,0,0,0.18);
    padding: 1rem 1.25rem;
    min-width: 280px;
    display: none;
}
.date-range-popover.active { display: block; }
.fc-title-btn {
    background: none;
    border: none;
    font-family: 'Kanit', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.fc-title-btn:hover { background: #f3f4f6; }
.fc-title-btn svg { opacity: 0.45; }

/* ย่อปุ่ม Nav (Prev/Next) ลง 20% */
.fc .fc-button {
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
}
/* ยกเว้นปุ่ม title ให้ใหญ่กว่า */
.fc .fc-titleBtn-button {
    font-size: 1.3rem !important;
    padding: 2px 6px !important;
}
.fc .fc-toolbar-title {
    font-size: 1.1rem !important;
}
/* Save Confirm Popover */
.save-confirm-popover {
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%);
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    box-shadow: 0 8px 24px -4px rgba(0,0,0,0.15);
    padding: 0.6rem 0.85rem;
    display: none;
    white-space: nowrap;
    z-index: 100;
    align-items: center;
    gap: 0.5rem;
}
.save-confirm-popover.active { display: flex; }
.save-confirm-popover::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #e5e7eb;
}
.save-confirm-popover::before {
    content: '';
    position: absolute;
    left: calc(100% + 1px);
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: white;
}

.swal2-html-container {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important; /* 🔥 สำคัญ */
}

/* ปรับแต่งส่วนหัวข้อ (ตรงที่เมาส์ชี้ในรูป) */
.swal2-title {
    padding: 10px 30px 0px !important; /* ปรับ Padding ตามต้องการ (บน-ข้าง-ล่าง) */
    display: block !important;
    font-size: 1.5rem !important;      /* ถ้าอยากปรับขนาดตัวหนังสือหัวข้อ */
    color: #1e3a8a !important;        /* ถ้าอยากเปลี่ยนสี */
}

.swal2-actions {
    margin-top: 0px !important;     /* ปรับลดตามความเหมาะสม */
}

/* Calendar horizontal scroll on mobile */
@media (max-width: 768px) {
    /* ถอนความกว้างขั้นต่ำออกจากกล่องแม่เพื่อให้ส่วนหัวไม่หลุดจอ */
    #calendar {
        min-width: unset !important;
        overflow-x: auto !important; /* ให้ปฏิทินเลื่อนตัวเอง */
        /* ลบ display: block เพื่อไม่ให้ไปกวน Layout ของ FullCalendar */
    }

    /* ใส่ความกว้างขั้นต่ำไปที่ตัว "ตารางปฏิทิน" (ยกเว้นหน้าแสดงรายการ) */
    #calendar:not(.is-list-view) .fc-view-harness {
        min-width: 750px;
        min-height: 500px !important; /* บังคับความสูงเพื่อให้เนื้อหาไม่หาย */
    }

    /* ทำให้ส่วนหัว (Toolbar) ของปฏิทินเกาะจอด้านซ้ายตลอด (Sticky) */
    #calendar .fc-header-toolbar {
        position: sticky !important;
        left: 0;
        z-index: 100;
        background: #ffffff;
        width: 100% !important;
        max-width: calc(100vw - 32px) !important; /* หักระยะ padding ของกล่องขาว */
        padding-top: 10px;
        padding-bottom: 10px;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px;
        margin-bottom: 5px !important;
    }

    /* เฉพาะมุมมองสัปดาห์บนมือถือ ให้พยายามจัดให้อยู่แถวเดียวกัน */
    #calendar.is-week-view .fc-header-toolbar {
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 0px !important;
    }
    #calendar.is-week-view .fc-titleBtn-button {
        font-size: 1.3rem !important; /* ลดขนาดชื่อเดือนลงเล็กน้อย */
        padding: 0px 0px !important;
        white-space: nowrap;
    }
    #calendar.is-week-view .fc-toolbar-chunk:first-child .fc-button {
        padding: 5px 3px !important;
        font-size: 0.8rem !important;
    }
    #calendar.is-week-view .fc-view-select {
        font-size: 0.8rem !important;
        padding: 2px 16px !important;
    }
    #calendar.is-week-view .fc-header-toolbar .fas {
        font-size: 1.1rem !important;
    }
}
/* สำหรับไฮไลท์ในปฏิทินที่เร่งด่วน (Default / Week) */
.fc-event-urgent {
    animation: urgent-blink 2s infinite ease-in-out !important;
    box-shadow: none !important;
    border: none !important;    
}

.fc .fc-list-event.fc-event-urgent .fc-list-event-title,
.fc .fc-list-event.fc-event-urgent .fc-list-event-title a {
    color: #ef4444 !important;
    font-weight: 600 !important;
    animation: urgent-text-blink 2s infinite ease-in-out !important;

}


/* เฉพาะ เดือน และ รายการ: ให้เป็นตัวหนังสือสีแดงและกะพริบ โดยไม่มีพื้นหลัง */
.fc-dayGridMonth-view .fc-event-urgent,
.fc-list-view .fc-event-urgent {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.fc-dayGridMonth-view .fc-event-urgent .fc-event-main,
.fc-dayGridMonth-view .fc-event-urgent .fc-event-title,
.fc-list-view .fc-event-urgent .fc-list-event-title,
.fc-list-view .fc-event-urgent .fc-list-event-title a {
    color: #e53e3e !important;
    font-weight: bold !important;
}

.fc-dayGridMonth-view .fc-event-urgent,
.fc-list-view .fc-event-urgent {
    animation: urgent-text-blink 2s infinite ease-in-out !important;
}

.urgent-more-link {
    color: #ef4444 !important;
    font-weight: bold !important;
    animation: urgent-text-blink 2s infinite ease-in-out !important;
    text-decoration: underline !important;
}

@keyframes urgent-blink {
    0% { opacity: 1; filter: brightness(1.2); }
    50% { opacity: 0.6; filter: brightness(0.8); }
    100% { opacity: 1; filter: brightness(1.2); }
}

@keyframes urgent-text-blink {
    0% { opacity: 1; }
    50% { opacity: 0.2; }
    100% { opacity: 1; }
}

.overflow-x-auto.custom-scrollbar::-webkit-scrollbar {
    height: 6px;
}


@media print {

  /* 📄 บังคับ A4 + margin */
  @page {
    size: A4;
    margin: 0; /* 🔥 เทียบเท่า Margins: None */
  }

  html, body {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 0;
    background: white;
  }

  /* 📦 กล่องหลัก */
  .a4-page {
    width: 210mm;
    min-height: 297mm;

    padding: 15mm; /* 🔥 คุมระยะเอง */
    box-sizing: border-box;

    margin: 0 auto;

    box-shadow: none;
    border: none;
    background: white;
  }

  /* ❌ ซ่อน UI */
  .no-print,
  button {
    display: none !important;
  }

  /* 📝 ทำ input ให้เหมือน PDF */
  input,
  select,
  textarea {
    border: none;
    border-bottom: 1px dotted #9ca3af;
    background: transparent;
    box-shadow: none;

    color: #1e3a8a;
    font-weight: bold;
  }

  /* 🔧 กัน layout เพี้ยน */
  .a4-content {
    display: block;
    height: auto;
  }

  /* 📄 ตัดหน้า */
  .a4-page {
    page-break-after: always;
  }
}

.file-upload-input.has-files {
    color: black !important;
    opacity: 1 !important;
    font-weight: bold;
}

/* ===== Officer Multi-Select Widget ===== */
.officer-multi-select {
    position: relative;
    min-width: 180px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.875rem;
}

.officer-display {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 28px 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
    user-select: none;
}
.officer-display:hover {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.officer-multi-select.open .officer-display {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.officer-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.officer-placeholder {
    color: #9ca3af;
    white-space: nowrap;
    font-size: 0.8rem;
}

.officer-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 1px 6px 1px 8px;
    font-size: 0.775rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.officer-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #93c5fd;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.1s;
}
.officer-tag-remove:hover { color: #1d4ed8; }

.officer-arrow {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: #9ca3af;
    transition: transform 0.2s;
    flex-shrink: 0;
    pointer-events: none;
}
.officer-multi-select.open .officer-arrow {
    transform: translateY(-50%) rotate(180deg);
    color: #3b82f6;
}

.officer-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 24px -4px rgba(0,0,0,0.12);
    z-index: 200;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 220px;
    overflow-y: auto;
}
.officer-multi-select.open .officer-options { display: block; }

.officer-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
    transition: background 0.12s;
    gap: 8px;
}
.officer-option:hover { background: #eff6ff; color: #1d4ed8; }
.officer-option.selected { background: #f0f9ff; color: #1d4ed8; font-weight: 600; }

.officer-check {
    width: 16px;
    height: 16px;
    color: #3b82f6;
    flex-shrink: 0;
}
