/* style.css */
:root {
  --bg: #0f172a;
  --panel: #111827;
  --border: #1f2937;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --green: #22c55e;
  --green-ink: #052e16;
  --red: #ef4444;
  --red-ink: #450a0a;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
a {
  color: #93c5fd;
  text-decoration: none;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
}
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}
.center {
  max-width: 420px;
  margin: 8vh auto;
}
h1,
h2,
h3 {
  margin: 0 0 12px;
}
label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
}
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #334155;
  background: #0b1220;
  color: var(--text);
  border-radius: 12px;
}
.btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-weight: 700;
}
.btn-outline {
  background: #0b1220;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.error {
  background: #7f1d1d;
  color: #fecaca;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.muted {
  color: var(--muted);
}
.progress {
  margin: 16px 0;
  height: 10px;
  background: #0b1220;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar {
  height: 10px;
  background: var(--primary);
}
.pill {
  display: inline-block;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.9rem;
}
.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.yes {
  background: var(--green);
  color: var(--green-ink);
}
.no {
  background: var(--red);
  color: var(--red-ink);
}
.navrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ans {
  margin-top: 6px;
}
.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  background: #0b1220;
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  padding: 1px 6px;
  border-radius: 6px;
}
footer {
  color: var(--muted);
  text-align: center;
  padding: 16px 0;
}
.logo {
  display: block; /* ทำให้ margin auto ทำงานได้ */
  margin: 0 auto 20px; /* กลางแนวนอน + เว้นขอบล่าง */
  max-width: 300px; /* จำกัดความกว้าง (ปรับได้) */
  height: auto;
}
.container.center {
  display: flex;
  flex-direction: column;
  align-items: center; /* จัดกลางแนวนอน */
  justify-content: center; /* จัดกลางแนวตั้ง */
}

/* ===== Modal (Assess Done) ===== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2,6,23,.65);
  backdrop-filter: blur(8px);
  z-index: 99999;
}

.modal-card{
  width: min(520px, 100%);
  border-radius: 18px;
  background: rgba(17,24,39,.96);
  border: 1px solid rgba(31,41,55,.9);
  color: var(--text);
  box-shadow: 0 18px 70px rgba(0,0,0,.55);
  overflow: hidden;
  animation: modalIn .18s ease-out forwards;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn{
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 16px;
  background: rgba(15,23,42,.65);
  border-bottom: 1px solid rgba(148,163,184,.14);
}

.modal-title{
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.modal-x{
  appearance:none;
  border:1px solid rgba(148,163,184,.18);
  background: rgba(11,18,32,.6);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 20px;
  cursor:pointer;
  opacity: .9;
}
.modal-x:hover{ opacity: 1; }

.modal-body{
  padding: 14px 16px 6px;
  color: var(--text);
  overflow: hidden;
}

.modal-meta{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.modal-actions{
  display:flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 16px 16px;
}

/* ===== Popup summary table + scroll ===== */
.summary-list{
  margin-top: 10px;
  max-height: min(46vh, 320px); /* <<< ทำให้เลื่อนได้ */
  overflow: auto;
  padding-right: 6px;
  border: 1px solid rgba(148,163,184,.14);
  border-radius: 12px;
  background: rgba(11,18,32,.35);
}

/* แถวแบบ 2 คอลัมน์ */
.sum-row{
  display: grid;
  grid-template-columns: 1fr auto; /* ซ้ายยืด, ขวาตามเนื้อ */
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid rgba(148,163,184,.12);
}
.sum-row:first-child{ border-top: 0; }

.sum-title{ font-weight: 800; }
.sum-sub{ margin-top: 2px; font-size: .9rem; }

.sum-ans{
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: .9rem;
  white-space: nowrap;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(15,23,42,.65);
  color: var(--text);
}

/* tag สีตามคำตอบ */
.tag-yes{ border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.16); }
.tag-no { border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.14); }
.tag-pend{ border-color: rgba(148,163,184,.25); background: rgba(148,163,184,.10); }

/* ===== Summary table in modal ===== */
.summary-table {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.summary-head {
  display: grid;
  grid-template-columns: 50px 1fr 140px;
  background: #0b1220;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.summary-body {
  max-height: 215px;        
  overflow-y: auto;
  /* overflow-y: scroll; */
}

.summary-row {
  display: grid;
  grid-template-columns: 50px 1fr 140px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-name {
  font-weight: 600;
}

.summary-ans {
   text-align: left;
  justify-self: start;
  padding-left: 8px;
}

.summary-no{
  font-weight: 800;
}

/* ===== Custom Scrollbar ===== */

/* Firefox */
.summary-body,
.summary-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.45) rgba(11,18,32,.35);
}

/* Chrome / Edge / Safari */
.summary-body::-webkit-scrollbar,
.summary-list::-webkit-scrollbar {
  width: 10px;     /* ทำให้บาง */
  height: 10px;
}

.summary-body::-webkit-scrollbar-track,
.summary-list::-webkit-scrollbar-track {
  background: rgba(11,18,32,.35);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 999px;
}

.summary-body::-webkit-scrollbar-thumb,
.summary-list::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.35);
  border-radius: 999px;
  border: 2px solid rgba(11,18,32,.35); /* ทำให้ดูเป็นแท่งนุ่ม ๆ */
}

.summary-body::-webkit-scrollbar-thumb:hover,
.summary-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148,163,184,.55);
}

/* ===== Mobile Responsive Patch ===== */
.header > div{
  min-width: 0;              /* กันข้อความยาวดันล้น */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header nav{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn{
  min-height: 44px;          /* นิ้วกดง่าย */
  line-height: 1.1;
}

.container{
  width: min(100% - 24px, 960px);  /* กันชิดขอบจอ */
  padding: 18px 0;                 /* ใช้ padding แนวตั้งแทน */
}

.card{
  padding: 18px;
}

@media (max-width: 640px){
  .header{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 14px;
  }

  .header > div{
    white-space: normal;      /* มือถือให้ขึ้นบรรทัดได้ */
  }

  .header nav{
    justify-content: flex-start;
  }

  .header nav .btn{
    flex: 1 1 160px;          /* ปุ่มเรียง 2 คอลัมน์/หรือ 1 คอลัมน์ตามพื้นที่ */
    text-align: center;
  }

  .container{
    width: min(100% - 20px, 960px);
    padding: 14px 0;
  }

  .card{
    border-radius: 14px;
    padding: 14px;
  }

  /* modal ให้เต็มจอมากขึ้นบนมือถือ */
  .modal-card{
    width: 100%;
    max-height: 86vh;
  }

  /* summary ตารางใน modal: ลดความกว้างคอลัมน์ขวา */
  .summary-head,
  .summary-row{
    grid-template-columns: 1fr 110px;
  }
}

