/* ======================================================
   theme.css - Corporate Clean Theme
   ขาว + น้ำเงินเข้ม/ฟ้า ตาม Design Style ที่ Lock ไว้
   ====================================================== */

:root {
    --brand-navy:   #0B2447;
    --brand-blue:   #1B6FC9;
    --brand-blue-lt:#E8F1FC;
    --brand-bg:     #F5F7FA;
    --brand-white:  #FFFFFF;
    --brand-border: #E2E6EC;
}

body {
    background-color: var(--brand-bg);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    padding-bottom: 76px; /* กันพื้นที่ Bottom Nav มือถือ */
}

body.admin-layout {
    padding-bottom: 0;
}

/* ---------- Top Navbar ---------- */
.app-navbar {
    background-color: var(--brand-navy);
}

/* ---------- Mobile Page Padding (ตาม UI Guideline: ~16px) ---------- */
.app-content {
    padding: 16px;
}

.page-title {
    color: var(--brand-navy);
    font-weight: 600;
    margin-bottom: 16px;
}

/* ---------- Card เมนูหลัก (มือถือ) ---------- */
.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--brand-white);
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    padding: 18px 8px;
    text-decoration: none;
    color: var(--brand-navy);
    font-size: 14px;
    font-weight: 500;
    min-height: 90px;
    transition: box-shadow .15s ease;
}
.menu-card:hover, .menu-card:active {
    box-shadow: 0 2px 10px rgba(11,36,71,.12);
    color: var(--brand-blue);
}
.menu-card i { font-size: 26px; color: var(--brand-blue); }

.section-heading {
    color: var(--brand-navy);
    font-weight: 600;
    margin-top: 8px;
}

/* ---------- Placeholder Card (หน้า Template ที่ยังไม่มี Logic จริง) ---------- */
.placeholder-card {
    border: 1px dashed var(--brand-border);
    border-radius: 10px;
    background: var(--brand-white);
}

/* ---------- Bottom Navigation (มือถือ: ผู้แจ้ง / ช่าง) ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    background: var(--brand-white);
    border-top: 1px solid var(--brand-border);
    box-shadow: 0 -2px 8px rgba(0,0,0,.05);
    z-index: 1030;
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px;
    min-height: 56px;
    color: #6C7A93;
    text-decoration: none;
    font-size: 11px;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--brand-blue); font-weight: 600; }

/* ---------- Desktop Sidebar (ผู้ดูแลระบบ) ---------- */
.app-shell { display: flex; }
.app-sidebar {
    width: 240px;
    min-height: calc(100vh - 56px);
    background: var(--brand-white);
    border-right: 1px solid var(--brand-border);
    padding: 16px 0;
}
.sidebar-section { margin-bottom: 18px; }
.sidebar-section-label {
    padding: 4px 20px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8996AC;
    font-weight: 600;
}
.sidebar-link {
    display: block;
    padding: 9px 20px;
    color: var(--brand-navy);
    text-decoration: none;
    font-size: 14px;
}
.sidebar-link:hover { background: var(--brand-blue-lt); }
.sidebar-link.active {
    background: var(--brand-blue-lt);
    color: var(--brand-blue);
    font-weight: 600;
    border-right: 3px solid var(--brand-blue);
}
.admin-layout .app-content { flex: 1; padding: 24px; }

/* ---------- Badge สถานะงานซ่อม (5 สถานะ ตาม Workflow ที่ Lock) ---------- */
.badge-status-pending      { background: #6C7A93; }
.badge-status-inprogress   { background: var(--brand-blue); }
.badge-status-waitingparts { background: #E0922B; }
.badge-status-completed    { background: #1E9E5A; }
.badge-status-cancelled    { background: #C0392B; }

/* ---------- Touch Target ตาม UI Guideline (ปุ่ม/Input >= 46-48px) ---------- */
.btn, .form-control, .form-select { min-height: 46px; }
.btn-lg { min-height: 48px; }

/* ---------- เพิ่มโดยหัวข้อ "แจ้งซ่อมใหม่" (reporter/new_repair.php) ---------- */
/* แนบรูปภาพอาการ */
.upload-box {
    border: 2px dashed var(--brand-border);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    color: #6C7A93;
    cursor: pointer;
    background: #F9FAFB;
    margin: 0;
    transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--brand-blue); }

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}
.photo-preview-item { position: relative; }
.photo-preview-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--brand-border);
    display: block;
}
.photo-preview-remove {
    position: absolute;
    top: -6px; right: -6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #C0392B;
    color: #fff;
    border: none;
    font-size: .8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- เพิ่มโดยหัวข้อ "งานของฉัน (รายการ)" (reporter/my_repairs.php) ---------- */
.status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.status-tab {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--brand-white);
    border: 1px solid var(--brand-border);
    color: var(--brand-navy);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.status-tab.active {
    background: var(--brand-navy);
    border-color: var(--brand-navy);
    color: #fff;
}

.repair-card-link { text-decoration: none; color: inherit; display: block; }
.repair-card {
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    transition: box-shadow .15s ease;
}
.repair-card-link:hover .repair-card,
.repair-card-link:active .repair-card {
    box-shadow: 0 2px 10px rgba(11,36,71,.10);
}

.info-chip {
    display: inline-block;
    background: #EEF1F5;
    color: #4B5768;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
}

.badge-priority-high   { background: #FBE4E1; color: #C0392B; }
.badge-priority-normal { background: #EDEFF3; color: #5A6472; }

/* ---------- เพิ่มโดยหัวข้อ "รายละเอียดงาน (มุมมองผู้แจ้ง)" (reporter/repair_detail.php) ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -17px; top: 4px; bottom: -18px;
    width: 2px;
    background: var(--brand-border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: -22px; top: 2px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--brand-blue);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--brand-blue);
}

/* ---------- เพิ่มโดยหัวข้อ Admin: หมวดหมู่เรื่องแจ้ง (admin/categories.php) ---------- */
.data-table-card {
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--brand-white);
}
.data-table-card table thead th {
    background: var(--brand-blue-lt);
    color: var(--brand-navy);
    font-size: 13px;
    font-weight: 600;
    border-bottom: none;
    white-space: nowrap;
}
.data-table-card table td { vertical-align: middle; }

.badge-active   { background: #1E9E5A; }
.badge-inactive { background: #8996AC; }

/* ---------- เพิ่มโดยหัวข้อ Admin: จัดการเครื่องจักร (admin/assets.php) ---------- */
/* Status เครื่องจักรมี 3 ค่า (Active/Inactive/Decommissioned) ต่างจาก
   badge-active/badge-inactive ที่ใช้กับ IsActive แบบ Binary ของ Categories/
   Locations — แต่ใช้ Class ชื่อเดียวกัน 2 ตัวแรกได้เลยเพราะความหมายตรงกัน
   (Active = เขียว, Inactive = เทา) เพิ่มแค่ค่าที่ 3 */
.badge-decommissioned { background: #6C4F63; }

/* ---------- เพิ่มโดยหัวข้อ Admin: แดชบอร์ด (admin/dashboard.php) ---------- */
.stat-card {
    border: 1px solid var(--brand-border);
    border-radius: 12px;
    background: var(--brand-white);
    padding: 18px;
    height: 100%;
}
.stat-card .stat-label {
    font-size: 13px;
    color: #6C7A93;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--brand-navy);
}
.stat-card .stat-value.stat-danger {
    color: #C0392B;
}

/* ---------- เพิ่มโดยหัวข้อ Priority 4 ระดับ (เดิมมีแค่ 2: ปกติ/สูง) ---------- */
/* ไล่ระดับความเข้ม: ปกติ (เทาอ่อน) -> สูง (แดงอ่อน เดิม) -> เร่งด่วน (ส้มทึบ)
   -> เร่งด่วนที่สุด (แดงทึบ+ตัวหนา) ให้เห็นความต่างชัดตั้งแต่มองแวบแรก */
.badge-priority-urgent   { background: #E8590C; color: #FFFFFF; }
.badge-priority-critical { background: #C0392B; color: #FFFFFF; font-weight: 700; }

/* ---------- เพิ่มโดยหัวข้อ แก้ Scroll ขยับเอง หลังกดเลขที่งานใน Dashboard ---------- */
/* รอบแรกปิดแค่ #repeat-assets ไม่พอ (ยังขยับสลับขึ้น/ลงได้ทั้ง 2 ทิศทาง) —
   วิเคราะห์ใหม่: คอลัมน์ขวา (รายละเอียดงาน) เนื้อหาสั้น/ยาวไม่เท่ากันในแต่ละ
   งาน (บางงานมีรูปหลายรูป+ประวัติยาว, บางงานสั้นไม่มีรูปเลย) ทำให้ความสูงรวม
   ของหน้าขยับขึ้นลงได้จริงตามเนื้อหา — ถ้าหน้าสั้นลงจนต่ำกว่าตำแหน่งที่ Anchor
   ควรเลื่อนไปถึง Browser จะ "ดึงกลับ" ตำแหน่ง Scroll เองเพราะเลื่อนเกินความสูง
   จริงของหน้าไปไม่ได้ (อธิบายได้ทั้ง 2 ทิศทางที่เจอ: งานสั้น = หน้าสั้นลง =
   ขยับขึ้น, งานยาว = หน้ายาวขึ้น = ขยับลง) แก้ 2 ทาง:
   1) ปิด overflow-anchor ทั้งหน้า (กว้างกว่าเดิมที่ปิดแค่ #repeat-assets)
   2) บังคับความสูงขั้นต่ำให้ Section นี้ กันหน้าสั้นเกินไปจนกระทบตำแหน่ง Scroll */
html, body {
    overflow-anchor: none;
}
#repeat-assets {
    overflow-anchor: none;
    min-height: 520px;
}

/* ---------- เพิ่มโดยหัวข้อ แท็บใหญ่ Dashboard (งานตามสถานะ / เครื่องจักรซ่อมซ้ำ) ---------- */
.nav-pills .nav-link.active {
    background-color: var(--brand-navy);
}
.nav-pills .nav-link:not(.active) {
    color: var(--brand-navy);
}
