/* =====================================================================
   สมุดสมรรถนะ — ธีมแบรนด์ (น้ำเงินหมึกกลางคืน + ทองหญ้าฝรั่น)
   โหลดหลัง Bootstrap ทุกหน้า: แทนสีเขียวของ Bootstrap (success) ด้วยสีแบรนด์
   แก้สีทั้งระบบได้ที่ตัวแปรด้านล่างที่เดียว
   ===================================================================== */
:root {
  --smt-900: #144c54;
  --smt-800: #185d67;
  --smt-700: #1f7582;
  --smt-600: #117888;
  --smt-500: #117888;
  --smt-300: #a9e9de;
  --smt-100: #edf8f3;
  --smt-50:  #f6fcf9;
  --smt-gold: #ffd23f;
  --smt-gold-soft: #fff4dc;
  --smt-coral: #ff6b57;
  --smt-ok: #117888;            /* สถานะสำเร็จ/มาเรียน (ฟ้าสด แทนเขียว) */
  --smt-ok-soft: #e7f6ef;
  --smt-ink: #155059;
  --smt-paper: #f4fbf8;
  --smt-grad: linear-gradient(135deg, #1f7582 0%, #117888 55%, #89e2d2 100%);
  --smt-grad-night: linear-gradient(165deg, #144c54 0%, #185d67 55%, #1f7582 100%);
  --smt-shadow: 0 14px 34px -14px rgba(31, 117, 130, .45);

  /* ให้ Bootstrap ใช้สีแบรนด์เป็นสี "success" และ "primary" */
  --bs-success: #117888; --bs-success-rgb: 17, 120, 136;
  --bs-primary: #117888; --bs-primary-rgb: 17, 120, 136;
  --bs-success-text-emphasis: #185d67; --bs-success-bg-subtle: #edf8f3; --bs-success-border-subtle: #a9e9de;
  --bs-link-color: #117888; --bs-link-color-rgb: 17, 120, 136; --bs-link-hover-color: #185d67;
  --bs-body-bg: #f4fbf8;
}

body { background-color: var(--smt-paper); margin: 0; }
/* 100vw รวมความกว้างแถบเลื่อน → ล้นด้านข้าง 8–17px บางเครื่อง: ใช้ 100% ของหน้าแทน */
.app-layout { width: 100% !important; max-width: 100%; }
::selection { background: var(--smt-gold); color: var(--smt-900); }

/* พื้นหลังส่วนเนื้อหา: แสงไล่เฉดบาง ๆ ให้มีมิติ */
.main-area, .main-content {
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(17, 120, 136, .10), transparent 60%),
    radial-gradient(700px 380px at -10% 110%, rgba(245, 165, 36, .10), transparent 60%),
    var(--smt-paper);
}

/* ---------- ปุ่ม ---------- */
.btn-success, .btn-primary {
  --bs-btn-bg: #117888; --bs-btn-border-color: #117888; --bs-btn-hover-bg: #1f7582; --bs-btn-hover-border-color: #1f7582;
  --bs-btn-active-bg: #185d67; --bs-btn-active-border-color: #185d67; --bs-btn-disabled-bg: #89e2d2; --bs-btn-disabled-border-color: #89e2d2;
  background-image: var(--smt-grad); border: 0; color: #fff;
  box-shadow: 0 8px 18px -10px rgba(17, 120, 136, .8);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-success:hover, .btn-primary:hover { transform: translateY(-2px); box-shadow: var(--smt-shadow); filter: saturate(1.15); color: #fff; }
.btn-success:active, .btn-primary:active { transform: translateY(0); }
.btn-outline-success, .btn-outline-primary {
  --bs-btn-color: #117888; --bs-btn-border-color: #117888; --bs-btn-hover-bg: #117888; --bs-btn-hover-border-color: #117888;
  --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1f7582; --bs-btn-active-border-color: #1f7582;
}
.btn-warning { --bs-btn-bg: #ffd23f; --bs-btn-border-color: #ffd23f; --bs-btn-hover-bg: #f2c12e; --bs-btn-hover-border-color: #f2c12e; --bs-btn-color: #144c54; --bs-btn-hover-color: #144c54; }
.btn:focus-visible { box-shadow: 0 0 0 .25rem rgba(245, 165, 36, .55) !important; }

/* ---------- ยูทิลิตีสีของ Bootstrap ---------- */
.text-success { color: #117888 !important; }
.bg-success { background-color: #117888 !important; }
.border-success { border-color: #117888 !important; }
.text-bg-success { background-color: #117888 !important; color: #fff !important; }
.bg-success-subtle { background-color: #edf8f3 !important; }
.text-success-emphasis { color: #185d67 !important; }
.alert-success { --bs-alert-color: #185d67; --bs-alert-bg: #edf8f3; --bs-alert-border-color: #ccecdd; }
.table-success { --bs-table-bg: #edf8f3; --bs-table-color: #185d67; }
.badge.bg-success { background-image: var(--smt-grad); }
.text-warning { color: #e0ad1f !important; }
.bg-warning { background-color: #ffd23f !important; }
.progress-bar.bg-success { background-image: var(--smt-grad); }

/* ---------- ฟอร์ม ---------- */
.form-control:focus, .form-select:focus {
  border-color: #89e2d2; box-shadow: 0 0 0 .22rem rgba(17, 120, 136, .20);
}
.form-check-input:checked { background-color: #117888; border-color: #117888; }
.form-range::-webkit-slider-thumb { background: #117888; }

/* ---------- การ์ด ---------- */
.card, .stat-card { border-color: rgba(31, 117, 130, .10); }
.stat-card { transition: transform .2s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--smt-shadow) !important; }

/* ---------- แถบเมนูด้านข้าง ---------- */
.sidebar { background: var(--smt-grad-night) !important; }
.sidebar .sidebar-brand { border-bottom-color: rgba(255, 255, 255, .08) !important; }
.sidebar .side-link { border-radius: 10px; margin: 2px 10px; transition: background .15s ease, transform .15s ease; }
.sidebar .side-link:hover { background: rgba(255, 255, 255, .08) !important; transform: translateX(3px); }
.sidebar .side-link.active {
  background: linear-gradient(90deg, rgba(245, 165, 36, .22), rgba(245, 165, 36, .04)) !important;
  box-shadow: inset 3px 0 0 #ffd23f; color: #fff !important;
}
.sidebar .side-link.active i { color: #ffd23f !important; }

/* ---------- ตารางคะแนน ---------- */
.table thead th { letter-spacing: .01em; }
.input-cell:focus { outline: none; border-color: #117888 !important; box-shadow: 0 0 0 3px rgba(17, 120, 136, .18); }

/* ---------- สกรอลล์บาร์ ---------- */
* { scrollbar-color: #a9e9de transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3eee2; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #a9e9de; background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  .btn-success, .btn-primary, .stat-card, .sidebar .side-link { transition: none; }
  .btn-success:hover, .btn-primary:hover, .stat-card:hover, .sidebar .side-link:hover { transform: none; }
}

@media print {
  .main-area, .main-content { background: #fff !important; }
  /* กด Ctrl+P ในหน้าที่ไม่มีโหมดพิมพ์ของตัวเอง: พิมพ์ได้ครบทุกแถว ไม่ถูกตัดที่ความสูงจอ */
  html, body { height: auto !important; overflow: visible !important; }
  .app-layout { display: block !important; height: auto !important; overflow: visible !important; }
  .main-area, .main-content, #scrollArea { height: auto !important; max-height: none !important; overflow: visible !important; }
  #navbar-container, .sidebar, .sidebar-overlay, #sidebarOverlay, .mobile-nav-toggle, #btnBackToTop { display: none !important; }
  .table-responsive { overflow: visible !important; max-height: none !important; }
}

/* ---- จอสัมผัส (มือถือ/แท็บเล็ต): ช่องติ๊กและสวิตช์ใหญ่ขึ้น กดง่าย ---- */
@media (pointer: coarse) {
  .form-check-input { width: 1.5em; height: 1.5em; margin-top: .05em; }
  .form-switch .form-check-input { width: 2.7em; height: 1.5em; }
  .form-check { min-height: 1.9em; display: flex; align-items: center; gap: .45em; }
  .form-check .form-check-label { padding-top: .1em; }
  input[type=checkbox]:not(.form-check-input) { width: 24px; height: 24px; }
}

/* ---- หัวหน้าบันทึกคะแนน/กิจกรรมบนจอแคบ: ชื่อวิชายาวขึ้นบรรทัดใหม่ · ช่องเลือกไม่ล้นจอ ---- */
@media (max-width: 576px) {
  .header-controls h4 { white-space: normal; font-size: 1.15rem; line-height: 1.4; overflow-wrap: anywhere; }
  .header-controls > div, .header-controls .rounded-pill { max-width: 100%; min-width: 0; }
  .header-controls select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
}

/* =====================================================================
   ธีม "สมุดปากกาเน้นข้อความ" — ชุดขายรุ่นพื้นฐาน (หลักสูตร 2568 · ป.1–ป.2)
   แนวคิด: สมุดจดของครู — หมึกเขียวหัวเป็ด กระดาษลายจุด และ "แถบปากกาเน้นข้อความสีเหลือง" เป็นจุดเด่นจุดเดียว
   (เมนูที่เลือกอยู่ · หัวข้อหน้า · ปุ่มหลักบนหน้าเข้าสู่ระบบ) · ตัวอักษรหัวเรื่อง Mitr (กลม เป็นมิตร) · เนื้อหา Sarabun
   ใช้ง่ายทุกอุปกรณ์: ปุ่ม/ช่องกรอกสูงอย่างน้อย 44px · ช่องกรอกตัวอักษร 16px (มือถือไม่ซูมเอง) · โฟกัสเห็นชัด
   ใส่ต่อท้าย theme.css ตอน build (build_sale.py basic)
   ===================================================================== */
:root {
  --n-ink: #0d3b42; --n-ink2: #12505a; --n-teal: #0f7480; --n-teal-d: #0b5e68; --n-teal-50: #e8f5f2; --n-teal-100: #cfeae4;
  --n-marker: #ffd23f; --n-marker-soft: #fff1b8; --n-coral: #f25c54; --n-mint: #2fae8f;
  --n-paper: #f7f9f6; --n-line: #dfe8e4; --n-muted: #55666a;
  --n-display: 'Mitr', 'Sarabun', sans-serif;
  --n-dots: radial-gradient(rgba(13, 59, 66, .07) 1px, transparent 1.2px);
}
html body { background-color: var(--n-paper); background-image: var(--n-dots); background-size: 18px 18px; color: #17282b; }
html body .main-area, html body .main-content { background: transparent !important; }
html body h1, html body h2, html body h3, html body h4, html body h5, html body .greeting-text, html body .brand-title, html body .sidebar-brand h5 { font-family: var(--n-display) !important; letter-spacing: 0; }

/* ---------- หัวข้อหน้า: แถบปากกาเน้นข้อความ ---------- */
html body .main-area > div > h4:first-child, html body .main-area h4.fw-bold, html body .page-title {
  color: var(--n-ink) !important; display: inline; padding: 0 .15em;
  background: linear-gradient(transparent 58%, var(--n-marker) 58%, var(--n-marker) 92%, transparent 92%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
html body .main-area h4.fw-bold i { color: var(--n-teal) !important; }
html body .main-area [class*="card"] h4.fw-bold, html body .main-area .modal h4.fw-bold { background: none !important; display: block; padding: 0; }

/* ---------- เมนูด้านข้าง: หมึกเขียวหัวเป็ด + ลายจุด ---------- */
html body .sidebar { background: var(--n-ink) !important; background-image: radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1.2px) !important; background-size: 16px 16px !important;
  border-right: 0 !important; box-shadow: 6px 0 28px -16px rgba(13, 59, 66, .7) !important; }
html body .sidebar .sidebar-brand { background: transparent !important; border-bottom: 1px solid rgba(255, 255, 255, .1) !important; }
html body .sidebar-brand h5 { color: #fff !important; text-shadow: none !important; font-weight: 600; }
html body .sidebar-brand h5 i { color: var(--n-marker) !important; }
html body .sidebar-brand small { color: rgba(255, 255, 255, .78) !important; }
html body .side-title { color: rgba(255, 255, 255, .62) !important; opacity: 1 !important; border-bottom: 0 !important; font-family: var(--n-display); font-weight: 500; }
html body .side-title span { color: inherit !important; }
html body .sidebar .side-link { color: rgba(255, 255, 255, .9) !important; margin: 2px 10px; padding-left: 14px; border-radius: 12px; border-left: 0 !important; min-height: 44px; }
html body .sidebar .side-link i, html body .sidebar .side-link i[class*="text-"] { color: #8fd8c8 !important; }
html body .sidebar .side-link:hover { background: rgba(255, 255, 255, .08) !important; color: #fff !important; transform: none; }
html body .sidebar .side-link.active { background: var(--n-marker) !important; color: var(--n-ink) !important; font-weight: 700;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .55); transform: rotate(-.6deg); }
html body .sidebar .side-link.active i { color: var(--n-ink) !important; filter: none !important; }
html body .sidebar.collapsed .side-link { margin: 2px 8px; padding-left: 0; transform: none; }
html body .footer-panel { background: rgba(0, 0, 0, .14) !important; border-top: 1px solid rgba(255, 255, 255, .08) !important; }
html body .sidebar .btn-outline-light { color: #fff !important; border-color: rgba(255, 255, 255, .5) !important; }
html body .sidebar .btn-outline-light:hover { background: var(--n-coral) !important; border-color: var(--n-coral) !important; }
html body .pp5-avatar { border-color: var(--n-marker) !important; background-color: var(--n-marker-soft) !important; color: var(--n-ink) !important; }
html body .mobile-nav-toggle { background: var(--n-ink) !important; border: 3px solid var(--n-marker) !important; box-shadow: 0 8px 22px -6px rgba(13, 59, 66, .6) !important; width: 56px; height: 56px; }
html body .sidebar-mobile-overlay { background-color: rgba(13, 59, 66, .45) !important; }

/* เมนูของรุ่นเต็ม (ล็อก) */
html body .sidebar .side-link.nav-locked { opacity: .78; }
html body .sidebar .side-link.nav-locked .lock-pill { margin-left: auto; margin-right: 8px; font-size: 11px; font-weight: 700; color: var(--n-ink); background: var(--n-marker-soft);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap; font-family: var(--n-display); }
html body .sidebar.collapsed .lock-pill { display: none; }

/* ---------- เนื้อหา: การ์ดกระดาษ ปุ่มหมึก ---------- */
html body .custom-card, html body .card-custom, html body .card-x { border-top: 0 !important; border: 1px solid var(--n-line) !important; border-radius: 18px !important;
  box-shadow: 0 1px 0 rgba(13, 59, 66, .04), 0 10px 24px -18px rgba(13, 59, 66, .35) !important; }
html body .btn { min-height: 44px; border-radius: 12px; font-weight: 600; }
html body .btn-sm { min-height: 36px; }
html body .btn-success, html body .btn-primary { background: var(--n-teal) !important; border-color: var(--n-teal) !important; color: #fff !important; }
html body .btn-success:hover, html body .btn-primary:hover { background: var(--n-teal-d) !important; border-color: var(--n-teal-d) !important; }
html body .btn-outline-success, html body .btn-outline-primary { --bs-btn-color: var(--n-teal-d); --bs-btn-border-color: var(--n-teal); --bs-btn-hover-bg: var(--n-teal); --bs-btn-hover-border-color: var(--n-teal); --bs-btn-hover-color: #fff; }
html body .text-success { color: #0a6b56 !important; }
html body .form-control, html body .form-select { border-color: #cfdcd8; border-radius: 12px; min-height: 44px; font-size: 16px; }
html body .form-control-sm, html body .form-select-sm { min-height: 36px; font-size: 15px; }
html body .form-control:focus, html body .form-select:focus { border-color: var(--n-teal); box-shadow: 0 0 0 .22rem rgba(255, 210, 63, .55); }
html body .form-check-input { width: 1.25em; height: 1.25em; }
html body .form-check-input:checked { background-color: var(--n-teal); border-color: var(--n-teal); }
html body .table thead th, html body .table-light th { background: var(--n-teal-50) !important; color: var(--n-ink) !important; }
html body ::selection { background: var(--n-marker); color: var(--n-ink); }
html body :focus-visible { outline: 3px solid var(--n-marker) !important; outline-offset: 2px; }
html body .badge.bg-primary, html body .badge.text-bg-primary { background: var(--n-teal) !important; }

/* แบนเนอร์ต้อนรับหน้าแรก */
html body .dash-header { background: var(--n-ink) !important; background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1.2px) !important; background-size: 16px 16px !important;
  box-shadow: 0 16px 34px -18px rgba(13, 59, 66, .9) !important; border-radius: 22px !important; }
html body .dash-header .greeting-text { color: #fff !important; }
html body .dash-header .greeting-text::after { content: ""; display: block; width: 88px; height: 8px; margin-top: 8px; border-radius: 4px; background: var(--n-marker); transform: rotate(-1.5deg); }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
html body:has(.split-layout) { background: var(--n-paper) !important; background-image: var(--n-dots) !important; background-size: 18px 18px !important; }
html body .bg-orb { display: none !important; }
html body .split-layout { background: #fff !important; border: 1px solid var(--n-line) !important; border-radius: 26px !important; box-shadow: 0 30px 70px -28px rgba(13, 59, 66, .45) !important; }
html body .left-panel { background: var(--n-ink) !important; background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1.2px) !important; background-size: 16px 16px !important; border-right: 0 !important; }
html body .left-panel .brand-title { background: none !important; -webkit-text-fill-color: #fff !important; color: #fff !important; animation: none !important; font-weight: 600; }
html body .left-panel .brand-subtitle { color: rgba(255, 255, 255, .9) !important; }
html body .left-panel .brand-divider { background: var(--n-marker) !important; height: 8px !important; border-radius: 4px; transform: rotate(-1.5deg); }
html body .left-panel .system-version { color: rgba(255, 255, 255, .7) !important; }
html body .school-logo-container { background: #fff !important; box-shadow: 0 0 0 7px var(--n-marker), 0 18px 34px rgba(0, 0, 0, .3) !important; }
html body .school-logo-container:has(img[hidden]) { background: var(--n-marker) !important; }
html body .school-logo-container:has(img[hidden])::after { color: var(--n-ink) !important; }
html body .btn-login { background: var(--n-marker) !important; color: var(--n-ink) !important; border: 0 !important; font-family: var(--n-display); font-weight: 600 !important; min-height: 52px;
  box-shadow: 0 10px 22px -10px rgba(224, 168, 0, .9) !important; }
html body .btn-login:hover { background: #ffc61a !important; color: var(--n-ink) !important; }
html body .doc-tabs .nav-link.active, html body .nav-pills .nav-link.active { background: var(--n-ink) !important; color: #fff !important; box-shadow: inset 0 -4px 0 var(--n-marker); }

/* ---------- มือถือ / แท็บเล็ต ---------- */
@media (max-width: 768px) {
  html body .main-area { padding: 14px 12px 88px !important; }
  html body .custom-card { padding: 16px !important; border-radius: 16px !important; }
  html body .dash-header { border-radius: 18px !important; }
  html body .table { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { html body * { animation-duration: .001s !important; transition-duration: .001s !important; } html body .sidebar .side-link.active { transform: none; } }
@media print { html body { background: #fff !important; background-image: none !important; } html body .main-area h4.fw-bold { background: none !important; } }
