/* =====================================================================
   สมุดสมรรถนะ — ธีมแบรนด์ (น้ำเงินหมึกกลางคืน + ทองหญ้าฝรั่น)
   โหลดหลัง Bootstrap ทุกหน้า: แทนสีเขียวของ Bootstrap (success) ด้วยสีแบรนด์
   แก้สีทั้งระบบได้ที่ตัวแปรด้านล่างที่เดียว
   ===================================================================== */
:root {
  --smt-900: #21304d;
  --smt-800: #253758;
  --smt-700: #2b4066;
  --smt-600: #293e65;
  --smt-500: #243e6d;
  --smt-300: #abc0e7;
  --smt-100: #ecf0f9;
  --smt-50:  #f6f8fc;
  --smt-gold: #e5b334;
  --smt-gold-soft: #fcf4df;
  --smt-coral: #ff6b57;
  --smt-ok: #253d6b;            /* สถานะสำเร็จ/มาเรียน (ฟ้าสด แทนเขียว) */
  --smt-ok-soft: #e7ecf6;
  --smt-ink: #213250;
  --smt-paper: #f6f7f9;
  --smt-grad: linear-gradient(135deg, #2b4066 0%, #243e6d 55%, #8da9de 100%);
  --smt-grad-night: linear-gradient(165deg, #21304d 0%, #253758 55%, #2b4066 100%);
  --smt-shadow: 0 14px 34px -14px rgba(43, 64, 102, .45);

  /* ให้ Bootstrap ใช้สีแบรนด์เป็นสี "success" และ "primary" */
  --bs-success: #293e65; --bs-success-rgb: 29, 104, 216;
  --bs-primary: #243e6d; --bs-primary-rgb: 11, 102, 239;
  --bs-success-text-emphasis: #253758; --bs-success-bg-subtle: #ecf0f9; --bs-success-border-subtle: #abc0e7;
  --bs-link-color: #293e65; --bs-link-color-rgb: 29, 104, 216; --bs-link-hover-color: #253758;
  --bs-body-bg: #f6f7f9;
}

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(36, 62, 109, .10), transparent 60%),
    radial-gradient(700px 380px at -10% 110%, rgba(229, 179, 52, .10), transparent 60%),
    var(--smt-paper);
}

/* ---------- ปุ่ม ---------- */
.btn-success, .btn-primary {
  --bs-btn-bg: #293e65; --bs-btn-border-color: #293e65; --bs-btn-hover-bg: #2b4066; --bs-btn-hover-border-color: #2b4066;
  --bs-btn-active-bg: #253758; --bs-btn-active-border-color: #253758; --bs-btn-disabled-bg: #8da9de; --bs-btn-disabled-border-color: #8da9de;
  background-image: var(--smt-grad); border: 0; color: #fff;
  box-shadow: 0 8px 18px -10px rgba(41, 62, 101, .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: #293e65; --bs-btn-border-color: #293e65; --bs-btn-hover-bg: #293e65; --bs-btn-hover-border-color: #293e65;
  --bs-btn-hover-color: #fff; --bs-btn-active-bg: #2b4066; --bs-btn-active-border-color: #2b4066;
}
.btn-warning { --bs-btn-bg: #e5b334; --bs-btn-border-color: #e5b334; --bs-btn-hover-bg: #d8a31f; --bs-btn-hover-border-color: #d8a31f; --bs-btn-color: #21304d; --bs-btn-hover-color: #21304d; }
.btn:focus-visible { box-shadow: 0 0 0 .25rem rgba(229, 179, 52, .55) !important; }

/* ---------- ยูทิลิตีสีของ Bootstrap ---------- */
.text-success { color: #293e65 !important; }
.bg-success { background-color: #293e65 !important; }
.border-success { border-color: #243e6d !important; }
.text-bg-success { background-color: #293e65 !important; color: #fff !important; }
.bg-success-subtle { background-color: #ecf0f9 !important; }
.text-success-emphasis { color: #253758 !important; }
.alert-success { --bs-alert-color: #253758; --bs-alert-bg: #ecf0f9; --bs-alert-border-color: #c9d6ef; }
.table-success { --bs-table-bg: #ecf0f9; --bs-table-color: #253758; }
.badge.bg-success { background-image: var(--smt-grad); }
.text-warning { color: #ca981b !important; }
.bg-warning { background-color: #e5b334 !important; }
.progress-bar.bg-success { background-image: var(--smt-grad); }

/* ---------- ฟอร์ม ---------- */
.form-control:focus, .form-select:focus {
  border-color: #8da9de; box-shadow: 0 0 0 .22rem rgba(36, 62, 109, .20);
}
.form-check-input:checked { background-color: #293e65; border-color: #293e65; }
.form-range::-webkit-slider-thumb { background: #293e65; }

/* ---------- การ์ด ---------- */
.card, .stat-card { border-color: rgba(43, 64, 102, .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(229, 179, 52, .22), rgba(229, 179, 52, .04)) !important;
  box-shadow: inset 3px 0 0 #e5b334; color: #fff !important;
}
.sidebar .side-link.active i { color: #e5b334 !important; }

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

/* ---------- สกรอลล์บาร์ ---------- */
* { scrollbar-color: #abc0e7 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d0dcf2; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #abc0e7; 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; }
}

/* =====================================================================
   v1.8.2 ธีม "กรมท่า-ทอง" — ปพ.5 ดิจิทัล 2551 รุ่นเซิร์ฟเวอร์ (pp5_2551) โรงเรียนเมืองนครราชสีมา เท่านั้น
   แยกจากชุดขาย (เมนูขาว + แถบสีเทียน) และรุ่น Google ของโรงเรียน (เขียว) ให้จำได้ทันทีว่าเป็นรุ่นเซิร์ฟเวอร์
   จุดเด่นเดียว = เมนูซ้ายกรมท่าเข้ม + เส้นทองบาง · ส่วนอื่นเรียบ ขาว อ่านง่าย (คอนทราสต์ตัวอักษร ≥ 4.5:1)
   ===================================================================== */
:root {
  --k-ink: #171b23; --k-sky: #2b3f66; --k-sky-d: #1b2a45; --k-sky-50: #f1f3f8; --k-sky-100: #e1e6f0;
  --k-sun: #e5b334; --k-gold-d: #8a6512; --k-navy: #1e2d48; --k-navy-2: #26375a;
  --k-paper: #f6f7fa;
  --k-gold-line: linear-gradient(90deg, #e5b334, #f3d27a 50%, #e5b334);
}
html body { background-color: var(--k-paper); color: var(--k-ink); }
html body .main-area, html body .main-content { background: var(--k-paper) !important; }

/* ---------- เมนูด้านข้าง: กรมท่าเข้ม · ตัวอักษรขาว · ไอคอนทอง ---------- */
html body .sidebar { background: linear-gradient(180deg, var(--k-navy-2) 0%, var(--k-navy) 100%) !important; color: #fff !important; border-right: 0 !important;
  box-shadow: 4px 0 24px -12px rgba(15, 22, 36, .55) !important; }
html body .sidebar .sidebar-brand { background: rgba(0, 0, 0, .18) !important; border-bottom: 0 !important; position: relative; padding: 18px 16px 18px !important; }
html body .sidebar .sidebar-brand::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--k-gold-line); }
html body .sidebar-brand h5 { color: #fff !important; text-shadow: none !important; font-size: 18px; white-space: nowrap; }
html body .sidebar-brand h5 i { color: var(--k-sun) !important; }
html body .sidebar-brand small { color: rgba(255, 255, 255, .85) !important; }
html body .btn-toggle-sidebar { color: #fff !important; }
html body .side-title { color: #e9c766 !important; opacity: 1 !important; border-bottom: 1px solid rgba(255, 255, 255, .08) !important; letter-spacing: .3px; }
html body .side-title span { color: inherit !important; }
html body .sidebar .side-link { color: rgba(255, 255, 255, .92) !important; margin: 2px 10px; padding-left: 14px; border-radius: 10px; border-left: 0 !important; }
html body .sidebar .side-link i, html body .sidebar .side-link i[class*="text-"] { color: #e9c766 !important; }
html body .sidebar .side-link:hover { background: rgba(255, 255, 255, .08) !important; color: #fff !important; border-left: 0 !important; transform: none; }
html body .sidebar .side-link.active { background: var(--k-sun) !important; color: var(--k-navy) !important; font-weight: 700; box-shadow: 0 8px 18px -10px rgba(229, 179, 52, .9); }
html body .sidebar .side-link.active i { color: var(--k-navy) !important; filter: none !important; }
html body .sidebar.collapsed .side-link { margin: 2px 8px; padding-left: 0; }
html body .sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); }
html body .footer-panel { background: rgba(0, 0, 0, .2) !important; border-top: 1px solid rgba(255, 255, 255, .1) !important; }
html body .footer-panel .text-light, html body .footer-panel .btn-link, html body .footer-panel #teacherNameDisplay { color: #fff !important; }
html body .footer-panel .text-white-50 { color: rgba(255, 255, 255, .72) !important; }
html body .sidebar .btn-outline-light { color: #ffd0d0 !important; border-color: rgba(255, 160, 160, .7) !important; background: transparent; }
html body .sidebar .btn-outline-light:hover { background: #d9534f !important; border-color: #d9534f !important; color: #fff !important; }
html body .footer-panel [role=group] .btn-outline-light { color: #fff !important; border-color: rgba(255, 255, 255, .45) !important; }
html body .pp5-avatar { border-color: var(--k-sun) !important; background-color: rgba(229, 179, 52, .15) !important; color: var(--k-sun) !important; }
html body .mobile-nav-toggle { background: var(--k-navy) !important; border: 3px solid var(--k-sun) !important; box-shadow: 0 8px 22px -6px rgba(15, 22, 36, .6) !important; }
html body .sidebar-mobile-overlay { background-color: rgba(15, 22, 36, .45) !important; }
html body .sidebar .side-link:focus-visible, html body .btn:focus-visible { outline: 3px solid var(--k-sun) !important; outline-offset: 2px; }

/* ---------- เนื้อหา: การ์ดขาวขอบบนกรมท่า · ปุ่มกรมท่า ---------- */
html body .custom-card, html body .card-custom, html body .card-x { border-top: 4px solid var(--k-sky) !important; border-radius: 14px; }
html body .btn-success, html body .btn-primary { background: var(--k-sky) !important; border-color: var(--k-sky) !important; color: #fff !important; }
html body .btn-success:hover, html body .btn-primary:hover { background: var(--k-sky-d) !important; border-color: var(--k-sky-d) !important; }
html body .btn-outline-success, html body .btn-outline-primary { --bs-btn-color: var(--k-sky-d); --bs-btn-border-color: var(--k-sky); --bs-btn-hover-bg: var(--k-sky); --bs-btn-hover-border-color: var(--k-sky); --bs-btn-hover-color: #fff; }
html body .text-success { color: #0a7d5a !important; }
html body .form-control, html body .form-select { border-color: #d8dde8; }
html body .form-control:focus, html body .form-select:focus { border-color: var(--k-sky); box-shadow: 0 0 0 .2rem rgba(43, 63, 102, .18); }
html body ::selection { background: #f6e3a8; color: var(--k-ink); }

/* แบนเนอร์ต้อนรับหน้าแรก: กรมท่า + เส้นทอง */
html body .dash-header { background: linear-gradient(120deg, #1e2d48 0%, #2b3f66 60%, #3a5281 100%) !important; box-shadow: 0 14px 30px -16px rgba(15, 22, 36, .8) !important; padding-bottom: 36px; }
html body .dash-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--k-gold-line); }
html body .dash-header .greeting-text { color: #f3d27a !important; }

/* ---------- หน้าเข้าสู่ระบบ: แผงกรมท่า + เส้นทอง · ปุ่มทอง ---------- */
html body .left-panel { background: linear-gradient(160deg, #26375a 0%, #1e2d48 100%) !important; position: relative; overflow: hidden; border-right: 0 !important; }
html body .left-panel::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--k-gold-line); }
html body .left-panel .brand-title { background: none !important; -webkit-text-fill-color: #fff !important; color: #fff !important; animation: none !important; }
html body .left-panel .brand-subtitle { color: #fff !important; }
html body .left-panel .brand-divider { background: var(--k-sun) !important; }
html body .left-panel .system-version { color: rgba(255, 255, 255, .8) !important; bottom: 32px; }
html body .school-logo-container { background: #fff !important; box-shadow: 0 14px 30px rgba(15, 22, 36, .3), 0 0 0 6px rgba(229, 179, 52, .9) !important; }
html body .school-logo-container:has(img[hidden]) { background: var(--k-sun) !important; }
html body .school-logo-container:has(img[hidden])::after { color: var(--k-ink) !important; }
html body .btn-login { background: var(--k-sun) !important; color: var(--k-navy) !important; border: 0 !important; box-shadow: 0 10px 24px -10px rgba(138, 101, 18, .9) !important; }
html body .btn-login:hover { background: #d9a420 !important; color: var(--k-navy) !important; }
html body .bg-orb { display: none !important; }
html body .split-layout { background: #fff !important; border: 0 !important; box-shadow: 0 30px 70px -20px rgba(15, 22, 36, .35) !important; }
html body:has(.split-layout) { background: #e9edf4 !important; }
@media (prefers-reduced-motion: reduce) { html body * { animation-duration: .001s !important; transition-duration: .001s !important; } }
html body .doc-tabs .nav-link.active, html body .nav-pills .nav-link.active { background: var(--k-sky) !important; color: #fff !important; box-shadow: inset 0 -4px 0 var(--k-sun); }
