/* =====================================================================
 * MTTS@MOE - Theme (ต่อยอดจาก AdminLTE 4 / Bootstrap 5.3)
 * สี --mtts-primary / --mtts-secondary ถูกกำหนดจาก tbl_system_config ใน <head>
 * ===================================================================== */

/* ---------- Noto Sans Thai (self-hosted) ---------- */
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 300; src: url('../fonts/noto-sans-thai/noto-sans-thai-thai-300-normal.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 400; src: url('../fonts/noto-sans-thai/noto-sans-thai-thai-400-normal.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 500; src: url('../fonts/noto-sans-thai/noto-sans-thai-thai-500-normal.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 600; src: url('../fonts/noto-sans-thai/noto-sans-thai-thai-600-normal.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 700; src: url('../fonts/noto-sans-thai/noto-sans-thai-thai-700-normal.woff2') format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 300; src: url('../fonts/noto-sans-thai/noto-sans-thai-latin-300-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 400; src: url('../fonts/noto-sans-thai/noto-sans-thai-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 500; src: url('../fonts/noto-sans-thai/noto-sans-thai-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 600; src: url('../fonts/noto-sans-thai/noto-sans-thai-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Sans Thai'; font-style: normal; font-display: swap; font-weight: 700; src: url('../fonts/noto-sans-thai/noto-sans-thai-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --mtts-primary: #1f3c88;
  --mtts-secondary: #e8a33d;
  --bs-font-sans-serif: 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-font-size: .95rem;
}

body { font-family: var(--bs-body-font-family); }
.swal2-popup { font-family: var(--bs-body-font-family); }

/* ---------- Brand colors ---------- */
.btn-mtts { --bs-btn-color: #fff; --bs-btn-bg: var(--mtts-primary); --bs-btn-border-color: var(--mtts-primary); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: color-mix(in srgb, var(--mtts-primary) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--mtts-primary) 85%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--mtts-primary) 75%, #000); --bs-btn-active-color: #fff; }
.text-mtts { color: var(--mtts-primary) !important; }
.bg-mtts { background-color: var(--mtts-primary) !important; color: #fff; }
.border-mtts { border-color: var(--mtts-secondary) !important; }

.app-sidebar[data-bs-theme="dark"] { background: linear-gradient(180deg, var(--mtts-primary) 0%, color-mix(in srgb, var(--mtts-primary) 55%, #000) 100%) !important; }
.app-sidebar .sidebar-brand { border-bottom: 2px solid var(--mtts-secondary); }
.app-sidebar .brand-link .brand-image { background: #fff; border-radius: 50%; padding: 2px; opacity: 1 !important; }
.app-sidebar .brand-text { font-weight: 600 !important; letter-spacing: .3px; }
.sidebar-menu .nav-link.active { background-color: var(--mtts-secondary) !important; color: #1b1b1b !important; font-weight: 500; }
.sidebar-menu .nav-header { color: color-mix(in srgb, var(--mtts-secondary) 70%, #fff) !important; font-size: .78rem; letter-spacing: .5px; }
.sidebar-menu .nav-link p { white-space: normal; }
.sidebar-user { padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-user img { width: 40px; height: 40px; object-fit: cover; }
.sidebar-user .small { color: rgba(255,255,255,.7); }

.app-header { border-bottom: 3px solid var(--mtts-secondary); }
.app-footer { font-size: .85rem; }
.app-content-header h1 { font-weight: 600; color: var(--mtts-primary); }
[data-bs-theme="dark"] .app-content-header h1 { color: #dbe4ff; }

/* ---------- Cards / KPI ---------- */
.card { border-radius: .75rem; }
.card-header { background: transparent; }
.kpi-card { border: 0; border-left: 5px solid var(--kpi, var(--mtts-primary)); transition: transform .15s ease; }
.kpi-card:hover { transform: translateY(-2px); }
.kpi-card .kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kpi-card .kpi-icon { font-size: 2.2rem; opacity: .25; }
.kpi-card .kpi-label { font-size: .85rem; color: var(--bs-secondary-color); }
a.kpi-link { text-decoration: none; color: inherit; }

.task-title { white-space: pre-line; }
.table-task td { vertical-align: middle; }
.table-task .task-title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chart-box { position: relative; height: 280px; }

/* ---------- Timeline ---------- */
.mtts-timeline { position: relative; padding-left: 1.75rem; }
.mtts-timeline::before { content: ''; position: absolute; left: .55rem; top: .25rem; bottom: .25rem; width: 2px; background: var(--bs-border-color); }
.mtts-timeline .tl-item { position: relative; margin-bottom: 1rem; }
.mtts-timeline .tl-dot { position: absolute; left: -1.62rem; top: .2rem; width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 3px solid var(--bs-body-bg); }
.mtts-timeline .tl-time { font-size: .8rem; color: var(--bs-secondary-color); }

/* ---------- Login / Public ---------- */
.mtts-public { min-height: 100vh; background: radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--mtts-secondary) 30%, transparent) 0, transparent 40%), linear-gradient(135deg, var(--mtts-primary) 0%, color-mix(in srgb, var(--mtts-primary) 50%, #000) 100%); }
.mtts-public .brand-logo { width: 96px; height: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.mtts-public .login-card { border: 0; border-top: 4px solid var(--mtts-secondary); border-radius: 1rem; box-shadow: 0 1rem 3rem rgba(0,0,0,.3); }
.mtts-public .hero-title { color: #fff; font-weight: 700; }
.mtts-public .hero-sub { color: rgba(255,255,255,.85); }
.mtts-public .feature { color: #fff; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: .75rem; padding: 1rem; height: 100%; }
.mtts-public .feature i { color: var(--mtts-secondary); font-size: 1.6rem; }
.mtts-public footer { color: rgba(255,255,255,.7); font-size: .85rem; }

/* ---------- Portal layout (หน้าแรกสาธารณะ: พื้นขาว + แถบหัว + แถบเมนู) ---------- */
.mtts-portal { min-height: 100vh; background: #fbf8f1; } /* พื้นเนื้อหาสีครีมอ่อน (การ์ดยังเป็นสีขาว) */
.portal-skip { position: absolute; z-index: 1080; top: .5rem; left: .5rem; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.portal-top { color: #fff; padding: .9rem 0; background: linear-gradient(90deg, color-mix(in srgb, var(--mtts-primary) 82%, #000) 0%, var(--mtts-primary) 55%, color-mix(in srgb, var(--mtts-primary) 80%, #3b82f6) 100%); }
.portal-brand { color: #fff; min-width: 0; }
.portal-brand:hover { color: #fff; }
.portal-logo { flex-shrink: 0; display: block; line-height: 0; }
.portal-logo img { display: block; height: 48px; width: auto; max-width: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); } /* ตราเป็นภาพแนวตั้ง: กำหนดความสูงตรง ๆ ไม่ให้ล้นแถบหัว */
.portal-brand-text { min-width: 0; display: flex; flex-direction: column; }
.portal-title { font-size: 1.15rem; font-weight: 600; line-height: 1.35; }
.portal-sub { font-size: .82rem; opacity: .85; line-height: 1.4; }
.portal-login { --bs-btn-border-color: rgba(255,255,255,.85); white-space: nowrap; }
.portal-nav { background: #fff; border-bottom: 1px solid var(--bs-border-color); position: sticky; top: 0; z-index: 1020; }
.portal-tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.portal-tabs::-webkit-scrollbar { display: none; }
.portal-tabs .nav-link { color: var(--bs-body-color); padding: 1rem .9rem; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.portal-tabs .nav-link:hover, .portal-tabs .nav-link:focus-visible { color: var(--mtts-primary); }
.portal-tabs .nav-link.active, .portal-tabs .show > .nav-link { color: var(--mtts-primary); border-bottom-color: var(--mtts-primary); }
.portal-tabs .nav-link i { margin-right: .2rem; }
.portal-dropdown { max-height: 65vh; overflow-y: auto; max-width: min(92vw, 34rem); }
.portal-dropdown .dropdown-item { white-space: normal; }
.portal-dropdown .dropdown-item.active { background: var(--mtts-primary); }
.portal-dropdown .dropdown-item.active .text-body-secondary { color: rgba(255,255,255,.8) !important; }
.portal-h1 { font-size: 1.6rem; font-weight: 700; color: var(--bs-emphasis-color); }
.mtts-portal .card { border: 1px solid var(--bs-border-color); box-shadow: 0 1px 2px rgba(16,24,40,.04) !important; }
.mtts-portal .kpi-card { border-left: 5px solid var(--kpi, var(--mtts-primary)); }
.mtts-portal .pd-cat-card { border-top: 4px solid var(--cat, var(--mtts-primary)); }
.mtts-portal .pd-cat-card:hover { box-shadow: 0 .5rem 1.25rem rgba(16,24,40,.12) !important; }
.portal-footer { background: #f3eee2; border-top: 1px solid #e6dfcf; color: var(--bs-secondary-color); }
.portal-footer a { color: inherit; }
@media (max-width: 575.98px) {
  .portal-logo img { height: 40px; }
  .portal-title { font-size: .98rem; }
  .portal-sub { font-size: .75rem; }
  .portal-h1 { font-size: 1.3rem; }
  .portal-tabs .nav-link { padding: .85rem .7rem; }
}
.pd-wrap { width: 100%; }
.pd-hero-num { font-size: 2.25rem; font-weight: 700; line-height: 1; color: var(--mtts-primary); font-variant-numeric: tabular-nums; }
.pd-progress .progress-bar { font-weight: 600; font-size: .75rem; font-variant-numeric: tabular-nums; }
.pd-progress-val { min-width: 3.2rem; text-align: right; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bs-body-color); }
.pd-cat-badge { background: color-mix(in srgb, var(--cat, #6c757d) 14%, transparent); color: color-mix(in srgb, var(--cat, #6c757d) 80%, #000); border: 1px solid color-mix(in srgb, var(--cat, #6c757d) 35%, transparent); font-weight: 500; white-space: normal; text-align: left; }
.pd-cat-card { border: 0; border-top: 4px solid var(--cat, var(--mtts-primary)); transition: transform .15s ease, box-shadow .15s ease; }
.pd-cat-card:hover, .pd-cat-card:focus-visible { transform: translateY(-2px); box-shadow: 0 .5rem 1.25rem rgba(0,0,0,.2) !important; }
.pd-type-item { border-left: 4px solid var(--cat, var(--mtts-primary)) !important; }
.pd-swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; background: var(--cat, var(--mtts-primary)); margin-right: .4rem; vertical-align: baseline; }
.pd-cat-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.avatar-lg { width: 120px; height: 120px; object-fit: cover; border: 4px solid var(--mtts-secondary); }
.avatar-sm { width: 32px; height: 32px; object-fit: cover; }
.notification-unread { background-color: color-mix(in srgb, var(--mtts-secondary) 12%, transparent); }
.required::after { content: ' *'; color: var(--bs-danger); }
.cursor-pointer { cursor: pointer; }

@media print {
  .app-sidebar, .app-header, .app-footer, .no-print, .btn { display: none !important; }
  .app-main { margin: 0 !important; }
  body { font-size: 12pt; }
}
