/* ============================================================
   ตารางสอบ — สไตล์หลัก
   โทนสีน้ำเงินเข้ม เรียบง่าย ไม่ใช้ icon / font ภายนอก
   ============================================================ */

:root {
  /* สี — กลุ่มน้ำเงินเข้มเป็นหลัก + กลาง ๆ เท่านั้น ไม่ใช้สีสันอื่นแทรก */
  --navy-900: #0b1f3a;
  --navy-800: #12294f;
  --navy-700: #1f3d68;
  --navy-100: #e9edf4;
  --navy-050: #f4f6fa;

  --bg: #f2f4f7;
  --surface: #ffffff;
  --border: #dde3ec;
  --text: #1a2431;
  --text-muted: #5b6b7c;

  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(11, 31, 58, 0.06);
  --shadow-md: 0 4px 14px rgba(11, 31, 58, 0.10);

  --font-body: "Sarabun", "Leelawadee UI", "Tahoma", -apple-system,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy-900);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.site-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.65);
  font-weight: 400;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  max-width: 420px;
}

.search-field label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

.search-field input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
}

.search-field input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-field input:focus {
  outline: 2px solid #ffffff;
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- Main / layout ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ---------- Exam Banner ---------- */

.exam-banner {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy-800);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 16px;
}

.exam-banner-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--navy-900);
  letter-spacing: 0.2px;
}

.exam-banner-subtitle {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-900);
  letter-spacing: 0.2px;
}

.exam-banner-date {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--navy-700);
}

.status-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
  min-height: 32px;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-clear-search {
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--navy-800);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.btn-clear-search:hover {
  background: var(--navy-050);
  border-color: var(--navy-700);
}

.status-line {
  margin: 0 0 0 auto;
  font-size: 13.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  min-height: 22px; /* ป้องกัน layout shift เมื่อข้อความสถานะเปลี่ยน */
}

.status-line strong {
  color: var(--navy-800);
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Day group ---------- */

.day-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}

.day-heading {
  margin: 0;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-900);
  background: var(--navy-050);
  border-left: 4px solid var(--navy-800);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.day-heading .day-title-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
}

.day-heading .day-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-left: 8px;
}

.day-heading .day-deadline {
  font-size: 13px;
  font-weight: 500;
  color: var(--navy-800);
  background: var(--navy-100);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 10px;
  white-space: nowrap;
}

/* ---------- Table ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13.5px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--navy-100);
  color: var(--navy-900);
  text-align: left;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: var(--navy-050);
}

tbody tr:hover {
  background: var(--navy-100);
}

tbody tr[hidden] {
  display: none;
}

/* ---------- Session divider (ช่วงบ่าย) ---------- */

.session-divider,
.session-divider:hover {
  background: var(--navy-050) !important;
}

.session-divider td {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--navy-900);
  background: #ADD8E6;
  border-top: 2px solid var(--navy-800);
  border-bottom: 1px solid var(--border);
}

.col-no,
.col-amount,
.col-room {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.col-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.time-duplicate,
.subject-duplicate {
  display: none;
}

.col-staff {
  white-space: nowrap;
}

/* ---------- Quick Navigation Buttons ---------- */

.quick-nav-section {
  width: 100%;
  margin-top: 28px;
}

.quick-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 16px;
  background: var(--navy-800);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid var(--navy-700);
}

.nav-button:hover {
  background: var(--navy-900);
}

/* ---------- External Links Section ---------- */

.external-links-section {
  width: 100%;
  margin-top: 20px;
  padding: 18px 20px;
  background: #e8f2fa;
  border: 1px solid #c7dbe9;
  border-radius: var(--radius);
}

.external-links-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-900);
  border-bottom: 1px solid #c7dbe9;
  padding-bottom: 8px;
}

.external-links-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.external-link-item {
  display: block;
  background: #ffffff;
  color: var(--navy-900);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.external-link-item:hover {
  background: var(--navy-050);
  border-color: var(--navy-700);
}

/* ---------- Footer ---------- */

.site-footer {
  width: 100%;
  margin: 0 0 0 0;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 16px;
  color: #ffffff;
  text-align: center;
  background: var(--navy-900);
}

/* ---------- Responsive: phone ---------- */

@media (max-width: 640px) {
  .header-inner {
    gap: 12px;
    padding: 14px 16px;
  }

  .search-field {
    max-width: none;
  }

  .page {
    padding: 16px 12px 40px;
  }

  table {
    min-width: 640px;
    font-size: 13px;
  }

  .day-heading {
    font-size: 14px;
    padding: 10px 12px;
  }

  .exam-banner {
    padding: 14px 16px;
    margin-bottom: 12px;
  }

  .exam-banner-title {
    font-size: 16px;
  }

  .exam-banner-date {
    font-size: 13.5px;
  }

  .status-container {
    min-height: 28px;
    gap: 8px;
  }

  .btn-clear-search {
    font-size: 12.5px;
    padding: 3px 10px;
  }

  .status-line {
    font-size: 12.5px;
  }

  .quick-nav-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .external-links-section {
    padding: 14px 16px;
  }
}

/* ---------- Scroll navigation buttons ---------- */

.scroll-nav {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scroll-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-800);
  color: #ffffff;
  border: 1px solid var(--navy-700);
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.scroll-btn:hover {
  background: var(--navy-900);
}

/* ---------- Focus visibility (accessibility) ---------- */

:focus-visible {
  outline: 2px solid var(--navy-700);
  outline-offset: 2px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
