/* ════════════════════════════════════════════════════════════════
   ms-ui.css — ดีไซน์กลางแบบ pomnaka (Modern SaaS / Liquid Glass) ในโทนส้ม-ดำ
   โหลดต่อจาก theme.css + app.css → ทับสไตล์เดิมทุกหน้า (แก้ที่นี่ที่เดียว)
   ใช้ตัวแปรสีจาก theme.css: --brand --brand-600 --brand-700 --brand-soft --ink
   ════════════════════════════════════════════════════════════════ */
:root {
    --ms-bg: linear-gradient(160deg, #f6eee7 0%, #fbf8f5 45%, #f3ebe4 100%);
    --ms-card: rgba(255,255,255,.82);
    --ms-card-border: rgba(255,255,255,.95);
    --ms-shadow: 0 0 0 .5px rgba(255,255,255,.6), 0 10px 34px -6px rgba(23,18,13,.10), 0 3px 10px rgba(23,18,13,.05), inset 0 1.5px 0 rgba(255,255,255,.95);
    --ms-text: #1e293b;
    --ms-muted: #64748b;
    --ms-label: #94a3b8;
}
body { font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif; background: var(--ms-bg) fixed; color: var(--ms-text); }
.btn, .form-control, .form-select, .table, .modal, .dropdown-menu { font-family: inherit; }
h1, h2, h3, h4, h5, h6 { color: var(--ms-text); }
/* ไอคอน Lucide ทั่วไป = ขนาดตามตัวอักษร (กฎเฉพาะจุดด้านล่างทับได้) */
svg.lucide { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex-shrink: 0; }
.card-body h6 svg.lucide, .data-card-head svg.lucide, h6 svg.lucide { width: 16px; height: 16px; color: var(--brand-600); margin-right: 4px; }
.chip svg.lucide { width: 15px; height: 15px; }
.empty-row svg.lucide { width: 34px; height: 34px; display: block; margin: 0 auto 6px; opacity: .45; }

/* ══ Topbar — กระจกขาว ══ */
.ict-topbar {
    background: rgba(255,255,255,.72); backdrop-filter: blur(16px) saturate(1.6); -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border-bottom: 1px solid rgba(255,255,255,.8); box-shadow: 0 6px 20px -14px rgba(23,18,13,.25);
}
.ict-content { padding: 24px 26px; }
@media (max-width: 768px) { .ict-content { padding: 16px; } }

/* ══ Sidebar — ดำอุ่น + ไอคอน Lucide + active ไล่สีส้ม ══ */
.ict-sidebar { background: linear-gradient(180deg, #1c1611 0%, #17120d 100%); }
.ict-brand { display: flex; align-items: center; gap: 10px; }
.ict-brand .brand-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #fb923c, #ea580c); box-shadow: 0 6px 14px -6px rgba(249,115,22,.8); }
.ict-item, .ict-group { border-radius: 12px; font-weight: 500; }
.ict-item.active { background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%); box-shadow: 0 8px 18px -10px rgba(249,115,22,.9); }
.ict-ic { display: inline-flex; align-items: center; justify-content: center; }
.ict-ic svg { width: 18px; height: 18px; }
.ict-sub a.active { background: rgba(249,115,22,.18); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }

/* ══ Page Header — กล่องไอคอนไล่สี + ชื่อหน้า + คำอธิบาย ══ */
.ms-page-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.ms-page-header .ph-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.ms-page-header .ph-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ms-page-icon {
    width: 52px; height: 52px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(249,115,22,.12) 0%, rgba(249,115,22,.24) 100%);
    color: var(--brand-600); border-radius: 14px; box-shadow: 0 4px 10px rgba(249,115,22,.12);
}
.ms-page-icon svg { width: 24px; height: 24px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--ms-text); letter-spacing: -.02em; margin: 0; line-height: 1.15; }
.page-subtitle { font-size: .85rem; color: var(--ms-muted); margin: .15rem 0 0; }
@media (max-width: 767.98px) {
    .ms-page-icon { width: 44px; height: 44px; border-radius: 12px; }
    .page-title { font-size: 1.25rem; }
}

/* ══ การ์ด (Soft Card) — data-card / card / filter-card / kpi ══ */
.data-card, .card, .ms-card {
    background: var(--ms-card) !important; border: 1px solid var(--ms-card-border) !important;
    border-radius: 1.4rem !important; box-shadow: var(--ms-shadow) !important; overflow: hidden;
}
.card.border-0.shadow-sm { box-shadow: var(--ms-shadow) !important; }
.data-card-head, .card-header {
    background: rgba(255,255,255,.5) !important; border-bottom: 1px solid rgba(148,163,184,.15) !important;
    font-size: .82rem; font-weight: 700; letter-spacing: .3px; color: var(--ms-muted); padding: 14px 20px;
}
.card-body { padding: 1.35rem 1.4rem; }
.card-body h6, .widget-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--ms-muted); }
.card-body h5 { font-weight: 700; }
/* การ์ดที่มี Search Dropdown เปิดอยู่ → ไม่ตัดแผง */
:is(.data-card, .card, .filter-card):has(.gss.open) { overflow: visible !important; position: relative; z-index: 20; }

/* ══ Filter Card — แถบกรองมาตรฐาน ══ */
.filter-card {
    background: var(--ms-card) !important; border: 1px solid var(--ms-card-border) !important; border-radius: 1.25rem !important;
    box-shadow: var(--ms-shadow) !important; padding: 1rem 1.15rem !important; margin-bottom: 1.4rem !important; position: relative; z-index: 5; overflow: visible !important;
}
.filter-label, .filter-card .form-label { font-size: .72rem; font-weight: 700; color: var(--ms-label); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .35rem; display: block; }
.filter-card .form-select, .filter-card .form-control, .filter-card .gss-btn {
    background-color: rgba(255,255,255,.85); border: 1px solid rgba(23,18,13,.09); border-radius: .6rem; font-size: .875rem;
}

/* ══ ช่องกรอก ══ */
.form-control, .form-select { border-radius: .65rem; border-color: rgba(23,18,13,.12); }
.form-label { font-weight: 600; color: #334155; font-size: .88rem; }
.form-text { color: var(--ms-label); }
.input-group-text { border-radius: .65rem; background: rgba(255,255,255,.7); }

/* ══ ปุ่ม — แคปซูล (pill) + เงานุ่ม + กดยุบ ══ */
.btn { font-weight: 600; letter-spacing: .01em; transition: transform .12s ease, box-shadow .15s ease, background .15s ease, filter .15s ease; }
.btn:not(.rounded-circle):not(.btn-close) { border-radius: 999px !important; }
.btn:not(.rounded-circle):active { transform: scale(.97); }
.btn-group > .btn:not(.btn-close) { border-radius: 0 !important; }
.btn-group > .btn:not(.btn-close):first-child { border-radius: 999px 0 0 999px !important; }
.btn-group > .btn:not(.btn-close):last-child { border-radius: 0 999px 999px 0 !important; }
.input-group > .btn { border-radius: 0 !important; }
.input-group > .btn:last-child { border-top-right-radius: .65rem !important; border-bottom-right-radius: .65rem !important; }
.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-dark { border: none !important; box-shadow: 0 2px 10px -2px rgba(23,18,13,.22); }
.btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-warning:hover, .btn-info:hover, .btn-dark:hover { box-shadow: 0 5px 16px -3px rgba(23,18,13,.30); }
.btn-primary { background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%) !important; color: #fff !important; }
.btn-success { background: linear-gradient(135deg, #22c55e 0%, #15803d 100%) !important; color: #fff !important; }
.btn-danger { background: linear-gradient(135deg, #f87171 0%, #dc2626 100%) !important; color: #fff !important; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled, .btn-primary.disabled { filter: grayscale(.25) opacity(.6); }
/* ปุ่มรอง / ยกเลิก → กระจกฝ้า */
.btn-white, .btn-outline-secondary {
    background: rgba(255,255,255,.62) !important; border: 1px solid rgba(255,255,255,.9) !important; color: #475569 !important;
    box-shadow: 0 2px 8px -2px rgba(23,18,13,.12);
}
.btn-white:hover, .btn-outline-secondary:hover { background: rgba(255,255,255,.95) !important; color: var(--ms-text) !important; }
.btn-light { background: rgba(255,255,255,.62) !important; border: 1px solid rgba(23,18,13,.08) !important; }
.btn-light:hover { background: #fff !important; }
/* outline ตามสี → กระจกสีจาง (hover = เติมสีเต็ม) */
.btn-outline-primary { background: rgba(249,115,22,.10) !important; border: 1px solid rgba(249,115,22,.38) !important; color: var(--brand-700) !important; }
.btn-outline-primary:hover { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
.btn-outline-success { background: rgba(22,163,74,.10) !important; border: 1px solid rgba(22,163,74,.38) !important; color: #15803d !important; }
.btn-outline-success:hover { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; }
.btn-outline-danger { background: rgba(220,38,38,.08) !important; border: 1px solid rgba(220,38,38,.35) !important; color: #b91c1c !important; }
.btn-outline-danger:hover { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }
.btn-outline-dark { background: rgba(23,18,13,.06) !important; border: 1px solid rgba(23,18,13,.25) !important; color: var(--ink) !important; }
.btn-outline-dark:hover { background: var(--ink) !important; color: #fff !important; }
.btn svg { width: 15px; height: 15px; vertical-align: -2px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn > svg + *, .btn > svg { margin-right: .15rem; }

/* ปุ่มไอคอนในตาราง (.ibtn) → สี่เหลี่ยมโค้งมนกระจกบาง สีไอคอนตามชนิด */
.ibtn {
    width: 34px; height: 34px; border-radius: .65rem; border: 1px solid rgba(23,18,13,.08); background: rgba(255,255,255,.75);
    box-shadow: 0 2px 8px -3px rgba(23,18,13,.16); color: #475569;
}
.ibtn svg { width: 15px; height: 15px; }
.ibtn-info { color: #0284c7; } .ibtn-info:hover { background: #0284c7; border-color: #0284c7; color: #fff; }
.ibtn-success { color: #16a34a; } .ibtn-success:hover { background: #16a34a; border-color: #16a34a; color: #fff; }
.ibtn-warning { color: #d97706; } .ibtn-warning:hover { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.ibtn-danger { color: #dc2626; } .ibtn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.ibtn-primary { color: var(--brand-600); } .ibtn-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ══ ตาราง (data-table / ms-table) — หัวเทา uppercase · ขอบมน · hover ส้มจาง ══ */
table.data-table, table.ms-table { border-collapse: separate !important; border-spacing: 0 !important; }
.data-table thead th, .ms-table thead th {
    background-color: #f8f6f4 !important; color: #6c757d !important; font-weight: 600 !important; text-transform: uppercase;
    font-size: .73rem; letter-spacing: .5px; border-bottom: 2px solid rgba(23,18,13,.05) !important; padding: .95rem .8rem; white-space: nowrap;
}
.data-table tbody td, .ms-table tbody td { padding: .85rem .8rem; vertical-align: middle; border-top: 0; border-bottom: 1px solid rgba(23,18,13,.05); background: transparent; }
.data-table tbody tr:last-child td, .ms-table tbody tr:last-child td { border-bottom: none !important; }
.data-table tbody tr:hover td, .ms-table tbody tr:hover td { background-color: #fff8f2; }
.data-table tbody tr:hover, .ms-table tbody tr:hover { background: transparent; }
.ms-table thead th:first-child { border-top-left-radius: .85rem; }
.ms-table thead th:last-child  { border-top-right-radius: .85rem; }
.ms-table tbody tr:last-child td:first-child { border-bottom-left-radius: .85rem; }
.ms-table tbody tr:last-child td:last-child  { border-bottom-right-radius: .85rem; }
.data-table tbody tr.row-wait td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.data-table tbody tr.row-wait { box-shadow: none; }
@media (max-width: 767.98px) {
    .data-table thead th, .data-table tbody td, .ms-table thead th, .ms-table tbody td { padding: .7rem .5rem; font-size: .84rem; }
}
/* DataTables */
.dataTables_wrapper { padding: 1rem 1.25rem; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { border-radius: .6rem; border: 1px solid rgba(23,18,13,.12); padding: .3rem .7rem; }
.page-link { border-radius: .55rem !important; margin: 0 2px; border: 1px solid rgba(23,18,13,.08); }
.page-item.active .page-link { background: linear-gradient(135deg, #fb923c, #ea580c); border-color: transparent; }

/* ══ ป้ายสถานะ / ชิป ══ */
.pill { box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.chip { background: var(--ms-card); border: 1px solid var(--ms-card-border); box-shadow: 0 4px 14px -8px rgba(23,18,13,.18); padding: 7px 15px; font-weight: 500; }
.chip:hover { border-color: rgba(249,115,22,.4); }
.chip.active { background: linear-gradient(135deg, #2a211a, #17120d); border-color: transparent; }
.tech-chip { border-radius: 999px; padding: 2px 9px; }
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }

/* ══ KPI — การ์ดตัวเลข (แบบ x-kpi-card) ══ */
.kpi-row { gap: 16px; }
.kpi {
    background: var(--ms-card) !important; border: 1px solid var(--ms-card-border) !important; border-left: 1px solid var(--ms-card-border) !important;
    border-radius: 1.25rem !important; box-shadow: var(--ms-shadow) !important; padding: 18px 20px; transition: transform .18s ease, box-shadow .18s ease; color: inherit;
}
a.kpi:hover { transform: translateY(-2px); }
.kpi .ic { width: 46px; height: 46px; border-radius: 13px; font-size: 1.25rem; background: rgba(249,115,22,.12); color: var(--brand-600); }
.kpi .ic svg { width: 22px; height: 22px; }
.kpi .meta .l { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--ms-label); margin-top: 4px; }
.kpi .meta .n { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.kpi.ink { background: linear-gradient(135deg, #2a211a 0%, #17120d 100%) !important; border-color: transparent !important; }
.kpi.ink .ic { background: rgba(249,115,22,.22); color: #fdba74; }
.kpi.ink .meta .l { color: #d8c7b8; }
.kpi.wait .ic { background: rgba(245,158,11,.14); color: #d97706; }
.kpi.done .ic { background: rgba(22,163,74,.13); color: #16a34a; }
.kpi.rate .ic { background: rgba(249,115,22,.13); color: var(--brand-600); }

/* ══ Modal — Liquid Glass 3D (ทุก modal) ══ */
.modal-content {
    position: relative; overflow: hidden; border-radius: 26px !important;
    background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,248,242,.80)) !important;
    -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,.7) !important;
    box-shadow: 0 24px 60px -14px rgba(23,18,13,.38), 0 8px 22px -8px rgba(23,18,13,.2), inset 0 1px 1px rgba(255,255,255,.95) !important;
}
@supports (overflow: clip) { .modal-content { overflow: clip; } }
.modal-content::after { content: ''; position: absolute; top: -70px; right: -50px; width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(249,115,22,.20), transparent 70%); filter: blur(8px); pointer-events: none; z-index: 0; }
.modal-header, .modal-body, .modal-footer { position: relative; z-index: 1; border-color: rgba(148,163,184,.18) !important; }
.modal-body { z-index: 3; }
.modal-title { font-weight: 700; }
.modal.fade .modal-dialog { transform: scale(.97) translateY(6px); transition: transform .18s ease-out, opacity .15s ease-out; }
.modal.show .modal-dialog { transform: none; }
.modal-backdrop { --bs-backdrop-bg: #17120d; --bs-backdrop-opacity: .42; }
.modal .btn-close { opacity: .9; border-radius: 50% !important; padding: .6rem !important; background-color: rgba(255,255,255,.65); box-shadow: 0 2px 6px -1px rgba(23,18,13,.2), inset 0 0 0 1px rgba(15,23,42,.06); }

/* ══ alert เดิม (ถ้ายังมี) ══ */
.alert { border-radius: 1rem; border: 1px solid transparent; box-shadow: 0 4px 14px -10px rgba(23,18,13,.3); }

/* ══ ไทม์ไลน์ / อื่น ๆ ══ */
.tl .tl-ic { color: var(--brand-600); background: #fff; border-color: rgba(249,115,22,.25); }
.tl .tl-ic svg { width: 15px; height: 15px; }
.list-group-item { background: transparent; }
hr { border-color: rgba(148,163,184,.3); opacity: 1; }
.thumb { border-radius: 10px; box-shadow: 0 2px 8px -3px rgba(23,18,13,.25); }
.empty-row { color: var(--ms-label); }

/* ══ มือถือ ══ */
@media (max-width: 576px) {
    .ict-topbar .ict-user-name { display: none; }
    .ms-page-header .ph-actions { width: 100%; }
}

/* ══ DataTables กลาง (ms-datatable.js) ══ */
.dataTables_wrapper { padding: 1rem 1.25rem 1.1rem; }
.dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_filter label { font-size: .85rem; color: var(--ms-muted); display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.dataTables_wrapper .dataTables_filter { text-align: right; }
.dataTables_wrapper .dataTables_filter input { width: 230px !important; margin: 0 !important; padding-left: 2rem !important; border-radius: 999px !important;
    background: rgba(255,255,255,.85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat .75rem center; }
.dataTables_wrapper .dataTables_info { font-size: .8rem; color: var(--ms-label); padding-top: 0 !important; }
.dataTables_wrapper .dataTables_paginate { display: flex; justify-content: flex-end; }
.dataTables_wrapper .pagination { margin: 0; gap: 2px; flex-wrap: wrap; }
.dataTables_wrapper .page-link { font-size: .82rem; padding: .3rem .65rem; color: var(--ms-muted); }
.dataTables_wrapper .table-responsive, .table-responsive .dataTables_wrapper { overflow: visible; }
table.dataTable thead > tr > th.sorting, table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc { padding-right: 26px; }
table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc { color: var(--brand-700) !important; }
table.dataTable thead > tr > th.sorting:before, table.dataTable thead > tr > th.sorting:after,
table.dataTable thead > tr > th.sorting_asc:before, table.dataTable thead > tr > th.sorting_asc:after,
table.dataTable thead > tr > th.sorting_desc:before, table.dataTable thead > tr > th.sorting_desc:after { opacity: .2; }
table.dataTable thead > tr > th.sorting_asc:before, table.dataTable thead > tr > th.sorting_desc:after { opacity: .9; color: var(--brand-600); }
table.dataTable { margin: 0 !important; }
table.dataTable.data-table thead th, table.dataTable.ms-table thead th { border-top: 0; }
table.dataTable tbody td.dataTables_empty { text-align: center; color: var(--ms-label); padding: 30px 0 !important; }
.data-card .dataTables_wrapper .row:first-child { margin-left: 0; margin-right: 0; }
/* ตัวกรองตามคอลัมน์ */
.dt-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .9rem; padding: .2rem 0 .8rem; margin-bottom: .6rem; border-bottom: 1px dashed rgba(148,163,184,.35); }
.dt-filter { display: flex; flex-direction: column; gap: .2rem; margin: 0; min-width: 150px; }
.dt-filter > span { font-size: .7rem; font-weight: 700; color: var(--ms-label); text-transform: uppercase; letter-spacing: .5px; }
.dt-filter .form-select { border-radius: 999px; font-size: .84rem; background-color: rgba(255,255,255,.85); }
.dt-filter.on .form-select { border-color: var(--brand); background-color: var(--brand-soft); color: var(--brand-700); font-weight: 600; }
.dt-reset { font-size: .8rem; }
@media (max-width: 576px) {
    .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_paginate { text-align: left; justify-content: flex-start; }
    .dataTables_wrapper .dataTables_filter input { width: 100% !important; }
    .dt-filter { min-width: calc(50% - .5rem); }
}
/* โลโก้โรงเรียนในกล่องแบรนด์ (ตั้งที่ ข้อมูลโรงเรียน) */
.brand-ic.brand-logo { background: #fff !important; padding: 3px; overflow: hidden; }
.brand-ic.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
