/* ฟอนต์ TH SarabunPSK (ดู LICENSE-THSarabunPSK.txt ในโฟลเดอร์ fonts) */
@font-face {
    font-family: 'TH SarabunPSK';
    src: url('../fonts/THSarabunPSK-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TH SarabunPSK';
    src: url('../fonts/THSarabunPSK-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #000;
    --blue: #0000ff;
    --pass-text: #0a7d0a;
    --pass-bg: #339900;
    --fail: #d40000;
    --line: #000;
    --soft-line: #999;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: #fff;
    color: var(--ink);
    font-family: 'TH SarabunPSK', 'TH Sarabun New', Tahoma, sans-serif;
    font-size: 24px;
    line-height: 1.2;
}

a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
}

/* ---------- หัวรายงาน ---------- */
.report-header { text-align: center; padding-bottom: 10px; }
.report-header img { display: block; margin: 0 auto 6px; max-width: 100%; height: auto; }
.report-header p { margin: 0; }

/* ---------- ปุ่ม / ลิงก์ ---------- */
.btn {
    font: inherit;
    font-size: 22px;
    min-height: 38px;
    padding: 2px 20px;
    border: 1px solid #666;
    border-radius: 3px;
    background: #efefef;
    color: var(--ink);
    cursor: pointer;
}
.btn:hover { background: #e0e0e0; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- หน้า login ---------- */
.login { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.error { color: var(--fail); text-align: center; margin: 4px 0 12px; }

.login-box {
    max-width: 560px;
    margin: 8px auto 0;
    padding: 18px 12px 0;
    border: 1px solid var(--soft-line);
}
.login-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 12px;
    margin-bottom: 14px;
}
.login-row label { flex: 0 0 170px; text-align: right; }
.login-row input {
    width: 220px;
    max-width: 100%;
    height: 42px;
    padding: 0 8px;
    border: 1px solid #767676;
    font-family: Arial, sans-serif;
    font-size: 26px;
    font-weight: 700;
}
.login-actions {
    margin: 18px -12px 0;
    padding: 10px;
    background: var(--soft-line);
    text-align: center;
}

/* ---------- หน้าผลสอบ ---------- */
.report { max-width: 1240px; margin: 0 auto; padding: 12px 16px 40px; }
.report-page .report-header { border-bottom: 1px solid var(--soft-line); margin-bottom: 12px; }

.student-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px 24px;
    margin: 4px 0 10px;
}

.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { border: 1px solid var(--line); padding: 3px 8px; vertical-align: middle; }
.grid th { font-weight: 700; text-align: center; }

.left { text-align: left; }
.center { text-align: center; }
.strong { font-weight: 700; }
.blue { color: var(--blue); }

.verdict-cell { padding: 0 !important; }
.verdict { display: flex; align-items: stretch; }
.verdict-label {
    flex: 4 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-right: 1px solid var(--line);
    font-weight: 700;
}
.verdict-badge {
    flex: 1 1 0;
    padding: 4px 8px;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.is-pass { background: var(--pass-bg); }
.is-fail { background: var(--fail); }

.fail-area { margin: 14px 0 4px; }
.notice {
    margin: 0 0 10px;
    animation: notice-blink 1s steps(1, end) infinite;
}
@keyframes notice-blink {
    0%   { color: var(--fail); }
    50%  { color: #000; }
}
@media (prefers-reduced-motion: reduce) {
    .notice { animation: none; color: var(--fail); }
}
.confirm-form { margin: 14px 0; text-align: center; }
.btn-confirm { min-width: 250px; height: 46px; font-size: 26px; }
.confirmed { margin: 10px 0; color: var(--fail); font-size: 28px; font-weight: 700; text-align: center; }

.section-title { margin: 22px 0 8px; color: var(--blue); font-size: 24px; font-weight: 700; }

.skills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}
.skills-table th, .skills-table td { font-size: 18px; }
.skills-table th:nth-child(1) { width: 9%; }
.skills-table th:nth-child(2) { width: 26%; }
.skills-table th:nth-child(3) { width: 40%; }
.skills-table th:nth-child(4) { width: 25%; }
.skills-table .topic-no, .skills-table .topic-name { font-size: 24px; }
.pass { color: var(--pass-text); }
.fail { color: var(--fail); }

.signature { margin-top: 18px; text-align: center; }
.signature img { display: block; margin: 0 auto 2px; }
.signature p { margin: 0; }

/* ---------- ปุ่มท้ายหน้า (พิมพ์ / ออกจากระบบ) จัดกึ่งกลางหน้า ---------- */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin: 34px 0 6px;
    padding-top: 22px;
    border-top: 1px solid #d0d0d0;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 190px;
    min-height: 48px;
    padding: 4px 26px;
    border: 2px solid var(--act, #444);
    border-radius: 999px;
    background: #fff;
    color: var(--act, #444);
    font: inherit;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.action-btn:hover,
.action-btn:focus-visible {
    background: var(--act, #444);
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
}
.action-btn:active { transform: translateY(1px); box-shadow: none; }
.action-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.action-icon { flex: none; }
.action-print  { --act: #1f4e8c; }
.action-logout { --act: #b3261e; }
@media (prefers-reduced-motion: reduce) { .action-btn { transition: none; } }
@media (max-width: 560px) {
    .page-actions { flex-direction: column; align-items: stretch; }
    .action-btn { width: 100%; }
}

/* ---------- หน้าแจ้งข้อความ ---------- */
.message { max-width: 760px; margin: 14vh auto 0; padding: 16px; text-align: center; }
.message-text { margin: 0 0 18px; color: var(--fail); font-size: 40px; }
.message-link { color: var(--pass-text); font-size: 32px; }

/* ---------- จอแคบ (มือถือ) ---------- */
@media (max-width: 980px) {
    .skills { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    body { font-size: 22px; }
    .login-row label { flex-basis: 100%; text-align: left; }
    .login-row input { width: 100%; }
    .verdict-badge { font-size: 26px; }
    .message-text { font-size: 30px; }
}

/* ---------- พิมพ์ ---------- */
@page { size: A4; margin: 10mm; }
@media print {
    .no-print { display: none !important; }
    body { font-size: 17px; }
    .report { max-width: none; padding: 0; }
    .table-wrap { overflow: visible; }
    .grid th, .grid td { padding: 1px 5px; }
    .skills { grid-template-columns: 1fr 1fr; gap: 8px; }
    .skills-table th, .skills-table td { font-size: 13px; }
    .skills-table .topic-no, .skills-table .topic-name { font-size: 16px; }
    .verdict-badge { font-size: 22px; }
    .notice { animation: none; color: var(--fail); }
}
