:root {
    --font-sans-serif: 'Kanit', "Segoe UI", Tahoma, sans-serif;
}

html,
body {
    font-family: var(--font-sans-serif) !important;
}

input,
button,
select,
textarea {
    font-family: var(--font-sans-serif) !important;
}

.ri-refresh-line {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.pagination .page-item.active .page-link,
.pagination .page-item .page-link.active {
    background-color: #605dff;
    border-color: #605dff;
    color: #fff;
    z-index: 0 !important;
}

/* ===== Project layout overrides (intern/am) ===== */
/* #1 fix: select2 hides the original <select> with this class but select2.min.css here
   is missing the rule, so the original select keeps full width and causes horizontal scroll. */
.select2-hidden-accessible {
    position: absolute !important;
    width: 1px !important;
    min-width: 1px !important;
    max-width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    border: 0 !important;
    white-space: nowrap !important;
}

/* เธเธฑเธเธชเธเธญเธฅเธฅเนเนเธเธงเธเธญเธ โ€” เนเธชเนเธ—เธตเน body เน€เธ—เนเธฒเธเธฑเนเธ (เธญเธขเนเธฒเนเธชเนเธ—เธตเน html)
   เน€เธเธฃเธฒเธฐ overflow-x:hidden เธ—เธตเน <html> เธเธฐเธ—เธณเนเธซเน <html> เธเธฅเธฒเธขเน€เธเนเธ scroll container เน€เธญเธ
   -> Bootstrap เธ—เธตเนเธฅเนเธญเธเธชเธเธญเธฅเธฅเนเธ•เธญเธเน€เธเธดเธ” modal เธ”เนเธงเธข overflow:hidden เธ—เธตเน <body> เธเธฐเธฅเนเธญเธเนเธกเนเธ–เธถเธ
   -> เธเธทเนเธเธซเธฅเธฑเธเธขเธฑเธเน€เธฅเธทเนเธญเธเนเธ”เน. เนเธชเนเธ—เธตเน body เธญเธขเนเธฒเธเน€เธ”เธตเธขเธงเธขเธฑเธเธเธฑเธเนเธเธงเธเธญเธเนเธ”เนเธเนเธฒเธ scroll propagation */
body {
    overflow-x: hidden;
    max-width: 100%;
}

/* เธฅเนเธญเธเธชเธเธญเธฅเธฅเนเธเธทเนเธเธซเธฅเธฑเธเธ•เธญเธเน€เธเธดเธ” modal โ€” เธเธฃเธญเธเธ—เธฑเนเธ <html> เนเธฅเธฐ <body> (Bootstrap เนเธชเน .modal-open เธ—เธตเน body) */
html:has(> body.modal-open),
body.modal-open {
    overflow: hidden !important;
}

/* #5 user profile pinned at the bottom of the sidebar
   (.sidebar-area already has position:fixed from the theme = containing block) */
.sidebar-user {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.sidebar-user .logout-btn {
    line-height: 0;
}

/* เน€เธงเนเธเธ—เธตเนเธ—เนเธฒเธขเธฅเธดเธชเธ•เนเน€เธกเธเธนเนเธซเนเธเนเธเธเธฅเนเธญเธเนเธเธฃเนเธเธฅเน (footer เธชเธนเธ ~75px) โ€” เนเธชเนเธ—เธตเน .menu-inner เธเธถเนเธเธญเธขเธนเนเนเธ
   เธเธทเนเธเธ—เธตเน scroll เธเธฃเธดเธเธเธญเธ SimpleBar (padding เธเธ .layout-menu เธ•เธฑเธงเธเธญเธเนเธกเนเน€เธเธดเนเธกเธเธทเนเธเธ—เธตเนเน€เธฅเธทเนเธญเธ) */
.layout-menu .menu-inner {
    padding-bottom: 92px;
}

/* #6 narrow the sidebar: theme default 260/250px -> 200px.
   scoped to >=1200px (where the sidebar is shown) so mobile off-canvas stays intact.
   the collapsed state ([sidebar-data-theme=sidebar-hide]) has higher specificity
   and is untouched. main-content padding-left keeps the ~12px gap (200 + 12 = 212). */
@media only screen and (min-width: 1200px) {
    body:not([sidebar-data-theme="sidebar-hide"]) .sidebar-area {
        width: 250px;
    }

    body:not([sidebar-data-theme="sidebar-hide"]) .main-content {
        padding-left: 250px !important;
    }
}

body[sidebar-data-theme="sidebar-hide"] .sidebar-area {
    width: 80px !important;
}

body[sidebar-data-theme="sidebar-hide"] .main-content {
    padding-left: 80px !important;
}

body[sidebar-data-theme="sidebar-hide"] .sidebar-area .menu-item .menu-link.active,
body[sidebar-data-theme="sidebar-hide"] .sidebar-area .menu-item.open>.menu-link {
    background-color: transparent !important;
    box-shadow: none !important;
}

body[sidebar-data-theme="sidebar-hide"] .sidebar-area .menu-item .menu-link.active .menu-icon,
body[sidebar-data-theme="sidebar-hide"] .sidebar-area .menu-item .menu-link:hover .menu-icon {
    color: #0066fe !important;
}

/* เธเนเธญเธเธเธตเธ”เธชเธตเธกเนเธงเธ/เธเนเธณเน€เธเธดเธเธ”เนเธฒเธเธเนเธฒเธเนเธ–เธเน€เธกเธเธน Active */
.sidebar-area .menu-item .menu-link.active::before,
.sidebar-area .menu-vertical .menu-item .menu-link.active::before,
body[sidebar-data-theme="sidebar-hide"] .sidebar-area .menu-item .menu-link.active::before {
    display: none !important;
    content: none !important;
}

/* เน€เธงเนเธเธฃเธฐเธขเธฐเธ”เนเธฒเธเธเธเธเธญเธเน€เธเธทเนเธญเธซเธฒ (เธซเธฅเธฑเธเน€เธญเธฒ breadcrumb header เธญเธญเธเธ—เธธเธเธซเธเนเธฒ เนเธกเนเธเธฑเนเธเธเธฒเธฃเนเธ”เธเธดเธ”เธเธเน€เธเธดเธเนเธ) */
.main-content {
    padding-top: 1.5rem;
}

/* ===== Global loading: spinner เธซเธกเธธเธเธเธฅเธฒเธเธเธญ (full-screen) โ€” เธ—เธธเธเธซเธเนเธฒ/เธ—เธธเธ ajax =====
   เธเธธเธกเธ”เนเธงเธข JS เนเธ loading.js: เนเธเธฅเนเธญเธฑเธ•เนเธเธกเธฑเธ•เธดเธ—เธธเธ ajax เนเธเธเธกเธต delay (เนเธซเธฅเธ”เน€เธฃเนเธงเธเธฐเนเธกเนเน€เธซเนเธ) */
#cpdth-loading {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(1px);
    z-index: 99999;
}

#cpdth-loading.show {
    display: flex;
}

#cpdth-loading .cpdth-loading-spinner {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
    color: #605DFF;
}

/* เธเธธเนเธกเธฃเธฐเธซเธงเนเธฒเธเนเธซเธฅเธ” */
.cpdth-btn-loading {
    opacity: 0.65;
    pointer-events: none;
}

/* DataTables: เธเนเธญเธเธเธฅเนเธญเธ "เธเธณเธฅเธฑเธเธ”เธณเน€เธเธดเธเธเธฒเธฃ..." เธเธฅเธฒเธเธ•เธฒเธฃเธฒเธ โ€” เนเธเน spinner เธเธฅเธฒเธเธเธญเนเธ—เธ */
.dataTables_processing {
    display: none !important;
}

/* #7 sidebar เนเธเธ (200px): เน€เธกเธเธนเธ—เธตเนเธเนเธญเธเธงเธฒเธกเธขเธฒเธง เน€เธเนเธ "เธเธณเธเธญเธขเธทเธเธขเธฑเธเธ•เธฑเธงเธ•เธเธเธนเนเนเธเนเธเธฒเธ"
   เนเธซเนเธ•เธฑเธ”เธเธฃเธฃเธ—เธฑเธ”เนเธ—เธเธเธฒเธฃเธ”เธฑเธเน€เธเธทเนเธญเธซเธฒเธเธเน€เธเธดเธ” scrollbar เนเธเธงเธเธญเธ, เธ•เธฃเธถเธ icon เนเธงเนเธเนเธฒเธข */
.sidebar-area .menu-vertical .menu-item .menu-link {
    display: flex;
    align-items: center;
    white-space: normal;
    position: relative;
}

.sidebar-area .menu-vertical .menu-item .menu-link .menu-icon {
    flex-shrink: 0;
}

.sidebar-area .menu-vertical .menu-item .menu-link .title {
    flex: 1 1 auto;
    min-width: 0;
}

/* badge เธเธฑเธเธเธณเธเธงเธ: เธ•เธฃเธถเธเธกเธธเธกเธเธงเธฒ-เธเธถเนเธเธเธฅเธฒเธ (เธญเธญเธเธเธญเธ flow) + เน€เธงเนเธเธ—เธตเนเธเธฑเนเธเธเธงเธฒเธเธญเธเธเนเธญเธเธงเธฒเธกเนเธกเนเนเธซเนเธ—เธฑเธ */
.sidebar-area .menu-vertical .menu-item .menu-link:has(.badge) .title {
    padding-right: 24px;
}

.sidebar-area .menu-vertical .menu-item .menu-link .badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.default-table-area thead th {
    white-space: nowrap;
    vertical-align: middle;
}

table.dataTable thead .dt-column-order::before,
table.dataTable thead .dt-column-order::after,
table.dataTable thead .sorting::before,
table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::before,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::before,
table.dataTable thead .sorting_desc::after {
    font-family: Arial, "Segoe UI Symbol", sans-serif !important;
}

.app-tabs {
    flex-wrap: nowrap;
}

.app-tabs .nav-item {
    flex: 1 1 0;
}

.app-tabs .nav-link {
    width: 100%;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    padding: .85rem 1rem;
}

/* ===== เธเธธเนเธก action เนเธเธ•เธฒเธฃเธฒเธ (เธเธฑเธ”เธเธฒเธฃ/เนเธเนเนเธ/เธฅเธ/เน€เธเธดเธ”เธ”เธน) โ€” เนเธญเธเธญเธ+เธเนเธญเธเธงเธฒเธก เน€เธ”เนเธเนเธฅเธฐเธญเนเธฒเธเธเนเธฒเธขเธเธงเนเธฒ btn-sm =====
   เนเธชเน class "table-action-btn" เธเธนเนเธเธฑเธ btn เธชเธตเน€เธ”เธดเธก (btn-warning/btn-danger/btn-secondary เธฏเธฅเธฏ) */
.table-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    font-weight: 600;
    font-size: .9rem;
    padding: .45rem .85rem;
    white-space: nowrap;
}

.table-action-btn .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

/* เธ•เธฑเธงเธญเธฑเธเธฉเธฃเธเธธเนเธก action เน€เธเนเธเธชเธตเธเธฒเธงเน€เธชเธกเธญ (เธฃเธงเธก btn-warning เธ—เธตเนเธเธเธ•เธดเน€เธเนเธเธ•เธฑเธงเธญเธฑเธเธฉเธฃเน€เธเนเธก) */
.table-action-btn,
.table-action-btn:hover,
.table-action-btn:focus,
.table-action-btn:active {
    color: #fff;
}

.sidebar-area .logo .logo-text {
    left: 56px !important;
    top: 50% !important;
    transform: translateY(-50%);
}

/* ===== invalid-state เธเธญเธ ValidateRequired (js/main.js) โ€” เธเธญเธเนเธ”เธเธเธฃเธญเธเธ—เธธเธเธเธเธดเธ” widget ===== */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545 !important;
}

/* select2 (control เธเธฃเธดเธเน€เธเนเธ sibling เธเธญเธ <select>) */
select.is-invalid+.select2-container .select2-selection {
    border-color: #dc3545 !important;
}

/* TomSelect */
select.is-invalid+.ts-wrapper .ts-control {
    border-color: #dc3545 !important;
}

/* TinyMCE */
.tox-tinymce.is-invalid-widget {
    border-color: #dc3545 !important;
}

/* เธเธฅเธธเนเธก radio */
.is-invalid-group {
    outline: 1px solid #dc3545;
    outline-offset: 4px;
    border-radius: 6px;
}

/* เธเนเธญเธเธงเธฒเธกเนเธ•เนเธเนเธญเธ */
.vr-feedback {
    display: block;
}

/* เธเธฑเธ bootstrap เธเนเธญเธ icon invalid เธเธ select เธ—เธตเนเธกเธต widget เธ—เธฑเธ */
select.is-invalid {
    background-image: none !important;
}