/* =========================================================
   ไฟล์: assets/style.css (Update v3 - High Contrast)
   หน้าที่: ปรับธีมสีทหารแบบ High Contrast (ตัวหนังสือสว่างชัดเจน)
   ========================================================= */

:root {
    /* 1. ชุดสีหลัก */
    --theme-bg-color: #6d7f35;
    /* สีพื้นหลังของปุ่ม/แถบ (เขียวทหารเข้ม) */
    --theme-text-color: #d4e157;
    /* สีตัวหนังสือหัวข้อ/ลิงก์ (เขียวมะนาวสว่าง) - แก้มองไม่เห็น */

    /* 2. สีพื้นหลังเว็บ */
    --bg-dark: #1a1a1a;
    /* พื้นหลังเว็บ (ดำเทา) */
    --card-bg: #2b2b2b;
    /* พื้นหลังการ์ด */
    --input-bg: #333333;
    /* พื้นหลังช่องกรอกข้อมูล */

    /* 3. สีตัวหนังสือทั่วไป */
    --text-body: #f1f1f1;
    /* สีตัวหนังสือเนื้อหาปกติ (ขาวเกือบสุด) */
    --text-muted: #bbbbbb;
    /* สีตัวหนังสือรอง (เทาสว่าง) - แก้จากเทามืด */
    /* สีตัวหนังสือรอง (เทาสว่าง) - แก้จากเทามืด */
}


/* --- ตั้งค่าพื้นฐาน (Base) --- */
body {
    font-family: 'Prompt', sans-serif;
    background-color: var(--bg-dark) !important;
    color: var(--text-body) !important;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    color: var(--theme-text-color) !important;
    /* บังคับหัวข้อเป็นสีสว่าง */
    font-weight: 600;
}

label {
    color: var(--theme-text-color) !important;
    /* บังคับป้ายกำกับเป็นสีสว่าง */
    font-weight: 500;
}

a {
    color: var(--theme-text-color);
    text-decoration: none;
    transition: 0.3s;
}

a:hover {
    color: #fff;
    text-shadow: 0 0 5px rgba(212, 225, 87, 0.5);
}

/* --- แก้บั๊ก Input/Select (บังคับพื้นหลังเข้ม ตัวหนังสือขาว) --- */
.form-control,
.form-select,
textarea {
    background-color: var(--input-bg) !important;
    border: 1px solid #555 !important;
    color: #fff !important;
    /* ตัวหนังสือขาว */
}

.form-control:focus,
.form-select:focus {
    background-color: #404040 !important;
    border-color: var(--theme-text-color) !important;
    color: #fff !important;
    box-shadow: 0 0 0 0.25rem rgba(212, 225, 87, 0.25) !important;
}

::placeholder {
    color: #999 !important;
    /* Placeholder สีเทาสว่างขึ้น */
    opacity: 1;
}

/* ช่องที่ถูกปิดใช้งาน (Disabled) */
.form-control:disabled,
.form-select:disabled {
    background-color: #222 !important;
    color: #777 !important;
    border-color: #333 !important;
    cursor: not-allowed;
}

/* --- ธีมคลาสสำหรับ Bootstrap (Overrides) --- */

/* สีตัวหนังสือธีม */
.text-primary-theme {
    color: var(--theme-text-color) !important;
}

/* พื้นหลังธีม (Navbar, Header) */
.bg-primary-theme {
    background-color: var(--theme-bg-color) !important;
    color: white !important;
}

.bg-secondary-dark {
    background-color: var(--card-bg) !important;
}

.border-primary-theme {
    border-color: var(--theme-bg-color) !important;
}

/* --- ปุ่มกด (Buttons) --- */
.btn-primary-theme {
    background-color: var(--theme-bg-color);
    border-color: var(--theme-bg-color);
    color: white !important;
    /* ตัวหนังสือในปุ่มต้องขาว */
    font-weight: 600;
}

.btn-primary-theme:hover {
    background-color: #556b2f;
    /* เขียวเข้มขึ้นเมื่อชี้ */
    color: white !important;
    border-color: #556b2f;
}

/* แก้สีปุ่ม Outline ให้ชัดขึ้น */
.btn-outline-primary-theme {
    color: var(--theme-text-color);
    border-color: var(--theme-text-color);
}

.btn-outline-primary-theme:hover {
    background-color: var(--theme-text-color);
    color: #000;
}

/* --- การ์ดและตาราง --- */
.card {
    background-color: var(--card-bg);
    border: 1px solid #444;
}

.card-hover:hover {
    transform: translateY(-5px);
    transition: transform 0.3s;
    border-color: var(--theme-text-color) !important;
    /* ขอบเรืองแสงสีสว่าง */
}

.table-dark {
    background-color: var(--card-bg);
    color: var(--text-body);
}

.table-dark th {
    color: var(--theme-text-color);
    /* หัวตารางสีสว่าง */
}

/* แก้สีตัวหนังสือสีเทาของ Bootstrap (text-muted) ให้สว่างขึ้นบนพื้นดำ */
.text-muted {
    color: var(--text-muted) !important;
}

/* Datepicker Fix */
.flatpickr-calendar {
    background: var(--card-bg);
    border-color: #444;
}

/* --- Progress Bar --- */
.progress {
    height: 25px;
    background-color: #333;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.progress-bar {
    background-color: var(--primary-theme);
    /* สีเขียวทหาร */
    color: white;
    font-weight: bold;
    line-height: 25px;
    transition: width 0.4s ease;
}

/* --- Upload Preview Grid --- */
.preview-img-container {
    position: relative;
    width: 100%;
    padding-top: 100%;
    /* Square Ratio 1:1 */
    background-color: #000;
    border: 1px solid #555;
    border-radius: 4px;
    overflow: hidden;
}

.preview-img-container img,
.preview-img-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 22px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
}

.btn-remove-img:hover {
    background: red;
}

/* --- View Report: Image Overlay --- */
.img-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #444;
}

.img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.2s;
    cursor: pointer;
}

/* แสดงปุ่มเมื่อเอาเมาส์ชี้ (เฉพาะ PC) */
@media (hover: hover) {
    .img-wrapper:hover .img-overlay {
        opacity: 1;
    }
}

/* บนมือถือให้แสดงปุ่มดาวน์โหลดเล็กๆ มุมขวาล่างแทน */
.btn-dl-float {
    position: absolute;
    bottom: 5px;
    right: 5px;
    z-index: 5;
    opacity: 0.8;
}

/* Checkbox เลือกรูป */
.img-checkbox {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 20px;
    height: 20px;
    z-index: 10;
    accent-color: var(--primary-theme);
    cursor: pointer;
}

/* Lightbox (Modal) */
.lightbox-img {
    max-height: 85vh;
    object-fit: contain;
}

/* 1. Global Font Size Increase */
body {
    font-size: 1rem !important;
    /* Standard 16px */
}

/* --- Table Truncate Fix --- */
.text-truncate-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* display: block; removed to fix table row background issues */
    vertical-align: middle;
}

@media (min-width: 768px) {
    .text-truncate-cell {
        max-width: 300px;
    }
}

.highlight-word {
    background-color: #ffeb3b;
    color: #000;
    font-weight: bold;
    padding: 0 2px;
    border-radius: 2px;
}

@media (min-width: 1200px) {
    .text-truncate-cell {
        max-width: 450px;
    }
}