html {
    scroll-behavior: smooth;
}

.nav-link {
    transition: background-color 0.15s ease, color 0.15s ease;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 9999px;
}

/* ซ่อนไอคอน "แสดงรหัสผ่าน" (ตา) และปุ่ม clear ที่ Edge/IE ใส่ให้ input[type=password] อัตโนมัติ
   เพื่อไม่ให้ซ้อนทับกับปุ่มไอคอนรูปตาที่ทำเองในฟอร์ม login */
input::-ms-reveal,
input::-ms-clear {
    display: none;
}

/*
 * ธีมสีของระบบ (2026-08): เปลี่ยนจากโทนน้ำตาลทอง (Tailwind amber/yellow) เป็นโทนฟ้าเข้ม (Tailwind blue/sky)
 * ทุกจุดในระบบ - ไล่เฉดสี/โครงสร้าง gradient เดิมคงไว้เหมือนเดิมทุกประการ แค่เปลี่ยนตระกูลสี (hue) เท่านั้น
 * ตารางเทียบสี hex เดิม -> ใหม่ ที่ใช้ในไฟล์นี้ (อ้างอิงจากสเกลสีมาตรฐานของ Tailwind):
 *   amber-50  #fffbeb -> blue-50  #eff6ff   |  amber-700 #b45309 -> blue-700 #1d4ed8
 *   amber-100 #fef3c7 -> blue-100 #dbeafe   |  amber-800 #92400e -> blue-800 #1e40af
 *   amber-200 #fde68a -> blue-200 #bfdbfe   |  amber-900 #78350f -> blue-900 #1e3a8a
 *   amber-400 #d9a441 -> blue-400 #60a5fa   |  amber-600 #d97706 -> blue-600 #2563eb
 *   yellow-500 #eab308 -> sky-500 #0ea5e9   |  (สีเทากลาง #57534e/#d6d3d1 เป็นสีกลาง ไม่ใช่ส่วนของธีม จึงไม่แก้)
 * ถ้าจะเปลี่ยนธีมสีอีกครั้งในอนาคต ให้แก้ค่า hex ในไฟล์นี้ (SweetAlert2 ธีม) คู่กับคลาส Tailwind `amber-`/`yellow-`
 * (ตอนนี้เปลี่ยนเป็น `blue-`/`sky-` แล้ว) ในไฟล์ index.php/login.php และทุกไฟล์ใน assets/js/ ที่ index.php/login.php โหลดใช้
 * ให้ทั่วถึงระบบ SweetAlert2 (ปุ่ม/กล่องข้อความ) ให้เข้ากับธีมหลักของระบบ (header/ปุ่ม/ฟอร์ม) - border-radius ยึดตามสเกลของ Tailwind (rounded-lg/rounded-2xl)
 */
.swal2-popup {
    background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 55%, #bfdbfe 100%) !important;
    border: 1px solid #60a5fa;
    border-radius: 1rem !important; /* เท่ากับ Tailwind rounded-2xl */
}

/* ลดขนาดหน้าต่าง SweetAlert2 (แบบ modal) ทั้งระบบลง 20% - SweetAlert2 กำหนดขนาดทุกส่วน (ความกว้าง 32em, ไอคอน,
 * หัวข้อ, ปุ่ม, ช่องกรอก, ระยะห่าง) เป็นหน่วย em อิงจาก font-size ของ popup จึงลดที่เดียวแล้วย่อลงตามสัดส่วนทั้งหน้าต่าง
 * (ค่าเดิม 1rem -> 0.8rem) ต้องใช้ !important เพราะ SweetAlert2 ฉีด CSS ของตัวเองต่อท้าย <head> ทีหลังไฟล์นี้
 * ไม่รวม toast (มุมจอ) ที่มีขนาดของตัวเองอยู่แล้ว - ถ้าจะปรับขนาดอีกให้แก้ค่า font-size นี้ค่าเดียว (เช่น 0.9rem = ลด 10%) */
.swal2-popup.swal2-modal {
    font-size: 0.8rem !important;
}

.swal2-title {
    color: #1e3a8a !important;
}

.swal2-html-container {
    color: #57534e !important;
}

.swal2-confirm {
    background: linear-gradient(90deg, #1e40af, #1d4ed8 45%, #2563eb 75%, #0ea5e9) !important;
    border-radius: 0.5rem !important; /* เท่ากับ Tailwind rounded-lg */
    box-shadow: none !important;
}

.swal2-confirm:focus {
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.35) !important;
}

.swal2-cancel {
    background: #ffffff !important;
    color: #57534e !important;
    border: 1px solid #d6d3d1 !important;
    border-radius: 0.5rem !important;
    box-shadow: none !important;
}

.swal2-deny {
    background: #dc2626 !important;
    border-radius: 0.5rem !important;
    box-shadow: none !important;
}

.swal2-icon.swal2-question,
.swal2-icon.swal2-info {
    border-color: #1d4ed8 !important;
    color: #1d4ed8 !important;
}

.swal2-icon.swal2-warning {
    border-color: #1d4ed8 !important;
    color: #1d4ed8 !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #1e40af !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border-color: rgba(29, 78, 216, 0.3) !important;
}

.swal2-timer-progress-bar {
    background: #1d4ed8 !important;
}

/* toast (การแจ้งเตือนในระบบ) ให้เป็นโทนเดียวกัน แต่พื้นหลังทึบกว่าเพื่ออ่านง่ายบนมุมจอ */
.swal2-toast.swal2-popup {
    background: #eff6ff !important;
    border: 1px solid #60a5fa;
    border-radius: 0.75rem !important; /* เท่ากับ Tailwind rounded-xl */
}

/* ===== เส้นขอบการ์ด/ตารางทั้งระบบ (เดิมการ์ดสีขาวไม่มีเส้นขอบ/เส้นคั่นแถวสีฟ้าอ่อนมาก กลืนกับพื้นหลังสีเทา) =====
 * ใช้กับเนื้อหาทุกหน้าใน <main id="app"> จากที่เดียว (ไม่ต้องแก้คลาสทีละไฟล์ - หน้าใหม่ในอนาคตได้ผลอัตโนมัติ)
 * - การ์ดสีขาวที่มีเงา (bg-white + shadow*) ทุกใบ: เส้นขอบสีเทา gray-300 (#d1d5db)
 *   ยกเว้นวงกลม (rounded-full) เช่น ปุ่มกลมของสวิตช์เปิด/ปิด ที่เส้นขอบจะทำให้ขนาด/ตำแหน่งเพี้ยน
 * - แถวตาราง: เส้นคั่นแถวสีเทา gray-200 (#e5e7eb) และเส้นใต้หัวตารางสีเทา gray-300 - มีผลเฉพาะแถวที่มีคลาส border-b อยู่แล้ว
 *   (แค่เปลี่ยนสี ไม่เพิ่มเส้นให้ตารางที่ตั้งใจไม่มีเส้น)
 * selector มี #app จึงชนะคลาสสีขอบของ Tailwind (เช่น border-blue-50) โดยไม่ต้องใช้ !important
 * ถ้าจะปรับความเข้มทั้งระบบ แก้ค่าสีในกลุ่มนี้ที่เดียว */
#app .bg-white:is(.shadow, .shadow-sm, .shadow-md, .shadow-lg):not(.rounded-full) {
    border: 1px solid #d1d5db;
}

#app tbody > tr {
    border-color: #e5e7eb;
}

#app thead > tr {
    border-color: #d1d5db;
}

/* ===== แถบเลื่อนของ modal (ดู attachModalScrollbar ใน utils.js) =====
 * ซ่อนแถบเลื่อนจริงของ .modal-panel (ที่ยาวเต็มความสูงทับหัว/แถบปุ่มท้ายที่ฟิกไว้) แล้ววาดแถบเลื่อนบางๆ เองเฉพาะช่วง
 * เนื้อหาตรงกลาง ระหว่างใต้หัว modal ถึงเหนือแถบปุ่มท้าย - การเลื่อนด้วยล้อเมาส์/ทัชแพด/นิ้ว/คีย์บอร์ดยังเป็นของเบราว์เซอร์ตามปกติ */
.modal-panel-custom-scrollbar {
    scrollbar-width: none;
}

.modal-panel-custom-scrollbar::-webkit-scrollbar {
    display: none;
}

.modal-scroll-track {
    position: absolute;
    width: 8px;
    z-index: 60;
    display: none;
}

.modal-scroll-thumb {
    width: 100%;
    border-radius: 9999px;
    background-color: rgba(0, 0, 0, 0.22);
    cursor: grab;
    touch-action: none;
    transition: background-color 0.15s ease;
}

.modal-scroll-thumb:hover,
.modal-scroll-thumb.is-dragging {
    background-color: rgba(0, 0, 0, 0.38);
}

.modal-scroll-thumb.is-dragging {
    cursor: grabbing;
}

/* ===== เส้นขอบกล่องกรอกข้อมูลทั้งระบบ (input / select / textarea) =====
 * เดิมใช้สีเริ่มต้นของ Tailwind (gray-200 #e5e7eb) ซึ่งจางจนกลืนกับพื้น - เปลี่ยนเป็น gray-400 (#9ca3af)
 * ใช้ตัวเลือกระดับชื่อแท็ก (specificity 0,0,1) จึงชนะสีเริ่มต้นของ Tailwind แต่ "แพ้" คลาสสีของแต่ละช่องเสมอ
 * - สีตอนโฟกัส (focus:border-blue-500 / focus:border-amber-500 ฯลฯ) ยังทำงานตามเดิม
 * - ช่องที่กำหนดสีขอบเองด้วยคลาส (เช่น border-red-500 ตอน error) ยังใช้สีของตัวเอง
 * ไม่รวม checkbox/radio/file/range ใช้ทุกหน้า รวมถึงในหน้าต่าง (modal) และหน้า login */
input:where(:not([type="checkbox"], [type="radio"], [type="file"], [type="range"])),
select,
textarea {
    border-color: #9ca3af;
}

/* ===== พื้นหลังพื้นที่เนื้อหา (#app) - ลายตารางกราฟจางๆ สีฟ้า + แสงสีอ่อนที่มุมขวาบน/ซ้ายล่าง =====
 * ต่างจาก sidebar (ลายจุด/วงแหวน/คลื่น) และจางพอไม่รบกวนการอ่าน - ใส่เป็น background ของ #app เอง
 * (ไม่ใช่ element ลูก เพราะแต่ละหน้าแทนที่ innerHTML ของ #app ทั้งหมด) / ลายอยู่กับที่ขณะเลื่อนเนื้อหา (background-attachment: scroll) */
#app {
    background-color: #f3f4f6;
    background-image:
        radial-gradient(circle at 100% 0%, rgba(125, 211, 252, 0.22), transparent 38%),
        radial-gradient(circle at 0% 100%, rgba(165, 180, 252, 0.18), transparent 42%),
        linear-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px);
    background-size: auto, auto, 28px 28px, 28px 28px;
    background-attachment: scroll;
}

/* ===== แอนิเมชันเฟดเข้าเมื่อเปลี่ยนหน้า (คลิกเมนู sidebar/navbar - ใส่คลาสที่ #app ใน navigate() ของ app.js) =====
 * ใช้เฉพาะ opacity + เลื่อนขึ้นเล็กน้อย และจบที่ transform: none (ไม่ค้าง transform ไว้ที่ #app เพราะจะทำให้ element
 * position: fixed ด้านในอ้างอิงตำแหน่งผิด) ปิดแอนิเมชันให้ผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหวในระบบปฏิบัติการ */
@keyframes page-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
#app.page-fade-in {
    animation: page-fade-in 0.35s ease-out both;
}
@media (prefers-reduced-motion: reduce) {
    #app.page-fade-in { animation: none; }
}
