/* ============================================================
   ธีม “วันเรียน” (Dawn) สำหรับระบบตารางสอนบนเว็บ ict · โหลดต่อจาก theme.css
   - เมนูขั้นตอน 1–5 บนพื้นกรมท่า · เนื้อหาพื้นขาวอมฟ้า
   - สีไล่ ฟ้า (เช้า) → ม่วง → ชมพู → ส้ม (บ่าย) ใช้เป็นจุดเด่นเท่านั้น: แถบขั้นต่อไป เส้นใต้แถบบน · หัวคาบในตารางใช้โทนเย็น
   - ตัวอักษรบนจอใช้ชุดเดียวกับธีมเว็บ ict · ตารางที่พิมพ์ใช้ TH Sarabun New (ไฟล์ในเครื่อง)
   - ใช้ class เดิมทั้งหมด ไม่แก้ PHP · ถอดไฟล์นี้ออก = กลับเป็นธีมเว็บ ict · กฎหน้าจออยู่ใน @media screen · ท้ายไฟล์ปรับเฉพาะตารางที่พิมพ์ (.ttp)
   ============================================================ */


@media screen {

/* ---------- ค่าสี / ตัวอักษร ---------- */
:root {
    --navy: #13203A; --navy-2: #1E2E52; --navy-3: #2A3B62;
    --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #EEF1F7;
    --ink: #13203A; --ink-2: #33415E; --ink-3: #5A6684;
    --line: #DCE1EC; --line-2: #E8ECF3; --field: #CDD4E2;
    --accent: #3A3FB3; --accent-dark: #2B2F8F; --accent-soft: #E6E7FA; --accent-ink: #FFFFFF;
    --good: #17734A; --good-soft: #DDF3E7; --warn: #8A5300; --warn-soft: #FCEBCB; --bad: #B42A3C; --bad-soft: #FBE1E5;
    --p1: #2563C9; --p2: #3E5BCF; --p3: #5A53D2; --p4: #7A4CC9; --p5: #A2479F; --p6: #C9467A; --p7: #DE6A4F; --p8: #E58A2E;
    --p-dark-ink: #13203A;
    --dawn: linear-gradient(100deg, var(--p1) 0%, var(--p3) 35%, var(--p6) 72%, var(--p8) 100%);
    /* ตัวอักษรบนจอ: ชุดเดียวกับธีมเว็บ ict (Sarabun เนื้อหา · Leelawadee UI หัวข้อ) */
    --f-body: "Sarabun", "Leelawadee UI", "Tahoma", sans-serif;
    --f-head: "Leelawadee UI", "Sarabun", "Tahoma", sans-serif;
    --shadow: 0 1px 2px rgba(19, 32, 58, .04), 0 6px 18px rgba(19, 32, 58, .05);
    --tap: 44px;
}
body { background: var(--bg); font-family: var(--f-body); color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 600; color: var(--navy); }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 3px solid var(--p3); }

/* สีประจำขั้น: --nc = เข้ม (บนพื้นขาว) · --nc-bar = สว่าง (วงกลมเลข เส้นบนกล่อง บนพื้นกรมท่า) */
.nav-pink, .nav-sec.nav-pink { --nc: #B4306F; --nc-bar: #E7709F; --nc-bg: #FCEFF5; --nc-soft: #F8DCE9; }
.nav-sky, .nav-sec.nav-sky { --nc: #1C6A99; --nc-bar: #4FB3E8; --nc-bg: #EDF6FC; --nc-soft: #D6EAF7; }
.nav-yellow, .nav-sec.nav-yellow { --nc: #855F00; --nc-bar: #E3B341; --nc-bg: #FDF7E3; --nc-soft: #F8EBBF; }
.nav-navy, .nav-sec.nav-navy { --nc: #3A3FB3; --nc-bar: #9B9DF5; --nc-bg: #ECECFB; --nc-soft: #DADBF8; }
.nav-green, .nav-sec.nav-green { --nc: #1E7347; --nc-bar: #4FC28A; --nc-bg: #EDF8F1; --nc-soft: #D3EEDD; }
.nav-slate, .nav-sec.nav-slate { --nc: #435775; --nc-bar: #8C9DBB; --nc-bg: #F0F3F8; --nc-soft: #DFE5EF; }

/* ---------- แถบบน ---------- */
.topbar { background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--dawn); pointer-events: none; }
.brand b { font-family: var(--f-head); font-weight: 600; color: var(--navy); }
.term-switch select {
    min-height: var(--tap); border: 0; background-color: var(--navy); color: #fff; font-weight: 600;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.term-switch select:hover { border-color: transparent; background-color: var(--navy-2); }
.user-menu > summary { border: 1px solid var(--line); background: var(--surface); min-height: var(--tap); }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-2); }
.user-menu .ob { background: var(--dawn); }
.um-t b { color: var(--navy); }
.nav-btn { border-radius: 12px; border-color: var(--line); background: var(--surface); }

/* ---------- เมนูซ้าย: พื้นกรมท่า ---------- */
.sidebar { background: var(--navy); border-right: 0; color: #C9D3E8; scrollbar-color: var(--navy-3) transparent; }
.sidebar .nav-search input {
    background-color: var(--navy-2); color: #fff; border-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2393A1C0' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.sidebar .nav-search input::placeholder { color: #7E8BA8; }
.sidebar .nav-search input:focus { background-color: var(--navy-3); border-color: var(--p3); }
.sidebar a, .sidebar .soon { color: #D7DFEF; border-radius: 10px; }
.sidebar a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar a.on, .nav-c a.on { background: #fff; color: var(--navy); font-weight: 600; box-shadow: none; }
.nav-home a { color: #fff; font-weight: 600; }
.nav-home a.on { color: var(--navy); }
.nav-c .nav-group, details.nav-sec > summary.nav-group { color: #fff; }
details.nav-sec > summary:hover { background: rgba(255, 255, 255, .06); }
details.nav-sec > summary::after { color: #7E8BA8; }
.sidebar .nav-no { background: var(--nc-bar, #8C9DBB); color: var(--navy); }
.sidebar .nav-no .ic { color: var(--navy); }
.nav-c .nav-items { border-left-color: var(--nc-bar); border-left-width: 2px; }
.nav-c a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-empty, .nav-foot { color: #7E8BA8; }

/* ---------- เนื้อหา ---------- */
.crumbs .crumb-g { color: var(--nc); }
.crumbs .nav-no { background: var(--nc); color: #fff; }
.pagehead h1 { font-family: var(--f-head); font-weight: 600; color: var(--navy); font-size: clamp(24px, 2.6vw, 31px); line-height: 1.3; text-wrap: balance; }
.pagehead p { color: var(--ink-3); }
.panel { border-radius: 18px; border-color: var(--line); box-shadow: var(--shadow); }
.panel > h2, .panel > h3 { font-family: var(--f-head); font-weight: 600; color: var(--navy); }
.panel .tscroll { border-radius: 0 0 18px 18px; }
.flash { border: 0; box-shadow: inset 4px 0 0 currentColor; }
.flash.success { color: var(--good); background: var(--good-soft); }
.flash.error { color: var(--bad); background: var(--bad-soft); }
.flash.info { color: var(--warn); background: var(--warn-soft); }

/* ปุ่ม ช่องกรอก แท็บ */
.btn { border-radius: 12px; border-color: var(--line); color: var(--navy); }
.btn:hover { border-color: #B9C2D6; color: var(--navy); }
.btn.pri { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.pri:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
select:focus, input[type=text]:focus, input[type=number]:focus, input[type=search]:focus, input[type=password]:focus, input[type=date]:focus, input[type=time]:focus, textarea:focus { border-color: var(--p3); box-shadow: 0 0 0 3px rgba(90, 83, 210, .18); }
.tabs a { border-radius: 12px; }
.tabs a.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.area-nav a.on { background: var(--navy); color: #fff; }
.room-chips .rchip { text-decoration: none; }
.room-chips .rchip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill.acc { background: var(--accent-soft); color: var(--accent); }
.meter > i { background: #2FA36B; }
table.data th { background: #F6F8FC; color: var(--ink-3); }
/* ปุ่มในแถวตาราง (เช่น “จัดวิชา”): โทนอ่อน ไม่ให้ทั้งคอลัมน์เป็นแถบดำ */
table.data .btn.pri { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
table.data .btn.pri:hover { background: var(--accent); color: #fff; }
table.data tbody tr:hover td { background: #F7F8FD; }

/* ---------- หน้าภาพรวม ---------- */
.dash-next { position: relative; overflow: hidden; background: var(--dawn); padding: 20px 24px; border-radius: 20px; box-shadow: 0 16px 32px -20px rgba(90, 83, 210, .9); }
.dash-next::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10, 18, 40, .32), rgba(10, 18, 40, .06) 55%, rgba(10, 18, 40, 0)); pointer-events: none; }
.dash-next > * { position: relative; }
.dash-next .dn-ic { width: 52px; height: 52px; border-radius: 16px; background: rgba(255, 255, 255, .18); }
.dash-next .dn-t b { font-family: var(--f-head); font-weight: 600; font-size: 23px; }
.dash-next .btn { min-height: var(--tap); padding: 0 20px; border: 0; background: #fff; color: var(--navy); box-shadow: 0 6px 16px rgba(10, 18, 40, .2); }
.dash-next .btn:hover { background: #F4F6FA; color: var(--navy); }
.phase { border-radius: 20px; border-top-width: 4px; border-top-color: var(--nc-bar); box-shadow: var(--shadow); padding: 18px 20px 20px; }
.phase-h h2 { font-family: var(--f-head); font-weight: 600; font-size: 20px; color: var(--nc); }
.phase-h .nav-no { width: 32px; height: 32px; background: var(--nc); color: #fff; }
.phase.done .phase-cnt { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; background: var(--good-soft); color: var(--good); }
.step { background: #F8F9FC; border-color: var(--line-2); border-radius: 14px; }
a.step:hover { background: #fff; border-color: var(--nc-bar); box-shadow: 0 6px 16px rgba(19, 32, 58, .07); }
.step .v { font-family: var(--f-head); font-weight: 700; color: var(--navy); font-size: 27px; }
.step.ok .k i { background: #2FA36B; border-color: #2FA36B; }
.step.next { border-color: var(--p3); box-shadow: 0 0 0 3px rgba(90, 83, 210, .16); background: #fff; }

/* ---------- ตารางสอน: หัวคาบเป็นสีตามเวลา ---------- */
table.tt { border-spacing: 4px; }
table.tt thead th:not(.tt-day) { border-radius: 10px; padding: 6px 3px; color: #fff; font-weight: 700; line-height: 1.25; }
table.tt thead th:not(.tt-day) small { color: inherit; opacity: .92; font-weight: 500; }
/* สีหัวคาบโทนเย็น: เขียวน้ำทะเล (เช้า) → ฟ้า → คราม → ม่วงคราม (บ่าย) · ตัวอักษรขาวทุกคาบ */
:root { --t1: #177C8B; --t2: #1A72A0; --t3: #2366B1; --t4: #2E5BB8; --t5: #3D52B4; --t6: #4B4AAB; --t7: #5843A0; --t8: #643E93; }
table.tt thead th:nth-child(2) { background: var(--t1); }
table.tt thead th:nth-child(3) { background: var(--t2); }
table.tt thead th:nth-child(4) { background: var(--t3); }
table.tt thead th:nth-child(5) { background: var(--t4); }
table.tt thead th:nth-child(6) { background: var(--t5); }
table.tt thead th:nth-child(7) { background: var(--t6); }
table.tt thead th:nth-child(8) { background: var(--t7); }
table.tt thead th:nth-child(n+9) { background: var(--t8); }
table.tt tbody th.tt-day { background: var(--surface-2); border-radius: 10px; font-family: var(--f-head); font-weight: 600; color: var(--navy); }
.tt-cell { border-radius: 10px; }
.tt-e b { color: inherit; }
/* คาบที่ล็อก/ลงไม่ได้: โทนกรมท่าเข้ากับเมนู */
:root { --off-a: #33415E; --off-b: #3E4D6E; --off-lock: #2A3B62; }
.tt-bar { padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 3px solid transparent; border-image: var(--dawn) 1; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
body:has(.login-wrap) { background: var(--navy); }
body:has(.login-wrap) .main { max-width: none; padding: 0; }
body:has(.login-wrap) .site-foot { margin: 0; padding: 14px 16px; }
.login-wrap { background: radial-gradient(900px 500px at 15% 10%, rgba(37, 99, 201, .45), transparent 60%), radial-gradient(800px 500px at 90% 90%, rgba(229, 138, 46, .35), transparent 60%), radial-gradient(700px 400px at 70% 20%, rgba(201, 70, 122, .3), transparent 60%); min-height: calc(100vh - var(--topbar) - 50px); }
.login-card { border: 0; border-radius: 24px; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .55); }
.login-card h1 { font-family: var(--f-head); font-weight: 600; }
.login-card .btn.pri { background: var(--navy); }
body:has(.login-wrap) .site-foot { color: #93A1C0; border-top-color: rgba(255, 255, 255, .12); }

/* ---------- แชท ---------- */
.chat-fab { background: var(--navy); }

/* ============================================================
   จอขนาดต่าง ๆ
   ============================================================ */
@media (max-width: 1180px) {
    :root { --sidebar: 236px; }
    .main { padding: 20px 22px 64px; }
    /* iPad แนวนอน: แถบบนแถวเดียว (ซ่อนข้อความ “ไม่มีผู้ใช้อื่นออนไลน์” และชื่อผู้ใช้ เหลือวงกลม) */
    .online-none { display: none; }
    .user-menu .um-t { display: none; }
    .brand { flex: 1 1 0; min-width: 0; }
    .brand b { font-size: 15.5px; }
}
@media (min-width: 641px) and (max-width: 900px) {
    /* iPad แนวตั้ง: ภาคเรียนอยู่แถวเดียวกับชื่อระบบ */
    .online-bar { display: none; }
    .term-switch { order: 0; flex: 0 0 auto; }
    .term-switch select { width: auto; }
}
@media (max-width: 900px) {
    .nav-btn { min-width: var(--tap); min-height: var(--tap); display: inline-grid; place-items: center; }
    .sidebar { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(22px, env(safe-area-inset-bottom)); box-shadow: 18px 0 40px rgba(0, 0, 0, .35); }
    .nav-toggle:checked ~ .layout .nav-backdrop { background: rgba(19, 32, 58, .45); }
}
@media (max-width: 640px) {
    .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
    .term-switch { order: 5; flex: 1 1 100%; }
    .term-switch select { width: 100%; text-align: center; }
    .pagehead .actions { width: 100%; }
    .pagehead .actions .btn { flex: 1 1 auto; justify-content: center; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar input[type=search], .toolbar select, .toolbar .btn { width: 100%; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: 1 / -1; }
    .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { flex: none; }
    .dash-next { padding: 16px; }
    .dash-next .dn-t b { font-size: 20px; }
    .phase { padding: 14px; }
    .step .v { font-size: 22px; }
    .chat-dock { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
}
/* จอสัมผัส: ขนาดแตะ 44px · ช่องกรอก 16px (iPhone ไม่ซูมเอง) · คอลัมน์วันค้างไว้ */
@media (pointer: coarse) {
    .btn, .tabs a, .area-nav a, .sidebar a, details.nav-sec > summary, .um-pop a, .um-pop .linklike { min-height: var(--tap); }
    .btn.sm { min-height: 38px; }
    select, input[type=text], input[type=number], input[type=search], input[type=password], input[type=date], input[type=time], textarea, .sidebar .nav-search input, .term-switch select { font-size: 16px; min-height: var(--tap); }
    .check input[type=checkbox], .check input[type=radio], table.data input[type=checkbox] { width: 20px; height: 20px; }
    table.data td { padding-top: 11px; padding-bottom: 11px; }
    .tscroll, .panel .tscroll { -webkit-overflow-scrolling: touch; }
    table.tt th.tt-day { position: sticky; left: 0; z-index: 3; box-shadow: 4px 0 6px -4px rgba(19, 32, 58, .25); }
    table.tt thead th.tt-day { background: var(--surface); }
    .tt-cell { height: 76px; }
    /* ปุ่มเลือกห้อง (1/1 1/2 …) ใหญ่พอแตะ */
    .room-chips { gap: 6px; }
    .room-chips .rchip { min-width: 52px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 10px; font-weight: 600; }
}

} /* @media screen */

/* ============================================================
   ตารางที่พิมพ์ / PDF (หน้า พิมพ์รายงาน): ตัวอักษร TH Sarabun New และสระล่างไม่ถูกตัด
   - ใช้ไฟล์ assets/fonts/THSarabunNew.ttf / THSarabunNew-Bold.ttf ที่มากับระบบ (ทุกเครื่องเหมือนกัน รวม iPad) หรือที่ติดตั้งในเครื่อง
   - ถ้าไม่มีทั้งสองแบบ ใช้ Sarabun ที่มากับระบบ (หน้าตาใกล้เคียงกัน)
   - size-adjust: TH Sarabun ตัวเล็กกว่าฟอนต์ทั่วไปราว 1 ใน 3 จึงขยายให้ขนาดเท่ากับเดิม
   ============================================================ */
@font-face { font-family: "KKW TH Sarabun"; src: url("../fonts/THSarabunNew.ttf") format("truetype"), local("TH Sarabun New"), local("THSarabunNew"), local("TH SarabunPSK"), local("THSarabunPSK"); font-weight: 400; size-adjust: 132%; font-display: swap; }
@font-face { font-family: "KKW TH Sarabun"; src: url("../fonts/THSarabunNew-Bold.ttf") format("truetype"), local("TH Sarabun New Bold"), local("THSarabunNew-Bold"), local("TH SarabunPSK Bold"), local("THSarabunPSK-Bold"); font-weight: 700; size-adjust: 132%; font-display: swap; }

.ttp .tt-sheet, .ttp .tt-sheet table.tt { font-family: "KKW TH Sarabun", "Sarabun", "Leelawadee UI", Tahoma, sans-serif; }

@media print {
    /* บรรทัดชื่อวิชา/ครู: ระยะบรรทัดพอให้สระล่าง (ุ ู ฺ) และวรรณยุกต์บนไม่ถูกตัด */
    .ttp .tt-e { line-height: 1.3; }
    .ttp .tt-e b { line-height: 1.25; }
    .ttp .tt-e .tt-n, .ttp .tt-e .tt-t { line-height: 1.38; padding-bottom: .12em; }
    .ttp .tt-e.tt-e-mini { line-height: 1.35; }
    .ttp table.tt .tt-cell.blk span { line-height: 1.35; }
}
