/* ============================================================
 * PTT SHIP · Vehicle Scan Log — สไตล์รวม
 *
 * สองโทน
 *   .hud-page    ฉากหลัง HUD สีฟ้าเข้ม — หน้าเข้าสู่ระบบ และหน้าแสดงผลรถ
 *   .light-page  พื้นขาว อ่านง่าย     — ตารางบันทึก และหน้าพิมพ์ QR
 *
 * ทุกอย่างเป็นคลาส ไม่มี inline style เพราะ CSP ตั้งเป็น style-src 'self'
 * ============================================================ */
@import url('/css/fonts.css');

:root {
  --font: 'Kanit', 'Segoe UI', 'Tahoma', system-ui, sans-serif;

  /* โทนสว่าง */
  --bg: #eef3f7;
  --card: #ffffff;
  --ink: #16232e;
  --muted: #74848f;
  --line: #dfe7ee;
  --brand: #00396b;
  --cyan: #22ace0;
  --cyan-d: #0d8dbe;
  --ok: #16915a;
  --warn: #c07d15;
  --err: #d0402c;

  /* โทน HUD — ใช้เฉพาะหน้าเข้าสู่ระบบ */
  --hud-ink: #e9fbff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan-d); }

/* ============================================================
 * โลโก้
 * ============================================================ */
.brand-logo { display: block; line-height: 0; }
.logo-img { width: 100%; height: auto; display: block; }

/* ============================================================
 * ฉากหลัง HUD
 * ============================================================ */
.hud-page { position: relative; min-height: 100vh; color: var(--hud-ink); overflow: hidden; }
#hud-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.hud-svg { width: 100%; height: 100%; display: block; }

.hud-spin-slow, .hud-spin-rev { transform-box: fill-box; transform-origin: center; }
.hud-spin-slow { animation: hud-spin 120s linear infinite; }
.hud-spin-rev  { animation: hud-spin 80s linear infinite reverse; }
@keyframes hud-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .hud-spin-slow, .hud-spin-rev { animation: none; }
}

.hud-page > *:not(#hud-bg) { position: relative; z-index: 1; }

/* กรอบมุมรอบเนื้อหา — เส้นสี่มุมแบบจอเป้าหมาย */
.hud-frame { position: relative; padding: 30px; }
.hud-frame::before, .hud-frame::after,
.hud-frame > .corner-b::before, .hud-frame > .corner-b::after {
  content: ''; position: absolute; width: 62px; height: 62px;
  border: 5px solid #fff; border-radius: 3px;
}
.hud-frame::before { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.hud-frame::after  { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.hud-frame > .corner-b::before { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.hud-frame > .corner-b::after  { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* ============================================================
 * แถบบน
 * ============================================================ */
/* แถบบนเป็นพื้นสว่าง เพื่อให้โลโก้ ปตท. (สีกรมท่า) วางลงไปตรง ๆ ได้
   ไม่ต้องมีแผ่นสีขาวรองซึ่งดูเหมือนสติกเกอร์แปะทับ */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; color: var(--ink);
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(20, 50, 80, .06);
}
.topbar .brand-logo { width: 92px; flex: none; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 500; color: var(--brand); letter-spacing: .01em; }
.topbar .divider { width: 1px; height: 26px; background: var(--line); }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  padding: 6px 13px; border-radius: 7px;
}
.topbar nav a:hover { color: var(--ink); background: #eef4f8; }
.topbar nav a.on { color: #fff; background: var(--cyan); font-weight: 500; }

.wrap { max-width: 1460px; margin: 0 auto; padding: 18px 20px 60px; }

/* ============================================================
 * การ์ด
 * ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(20, 50, 80, .05);
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 500; color: var(--brand); }
.card-head .spacer { flex: 1; }

/* ============================================================
 * ช่องกรอกแบบ outlined (ป้ายลอยอยู่บนเส้นขอบ)
 * ============================================================ */
.mfield { position: relative; }
.mfield > label {
  position: absolute; top: -8px; left: 11px; z-index: 1;
  padding: 0 6px; background: var(--card);
  font-size: 12px; color: var(--muted); pointer-events: none;
}
.mfield input, .mfield select, .mfield textarea {
  width: 100%; padding: 13px 13px; font-family: var(--font); font-size: 14.5px;
  color: var(--ink); background: transparent;
  border: 1px solid #c9d6e0; border-radius: 6px;
  appearance: none;
}
.mfield select {
  background-image:
    linear-gradient(45deg, transparent 50%, #8fa1ae 50%),
    linear-gradient(135deg, #8fa1ae 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px; cursor: pointer;
}
.mfield input:hover, .mfield select:hover { border-color: #9db4c4; }
.mfield input:focus, .mfield select:focus, .mfield textarea:focus {
  outline: none; border: 2px solid var(--cyan); padding: 12px;
}
.mfield input:focus + label, .mfield:focus-within > label { color: var(--cyan-d); }
.mfield textarea { resize: vertical; line-height: 1.7; }

/* บนการ์ดกระจก ป้ายวางไว้เหนือช่องไปเลย จะได้ไม่ต้องมีแถบพื้นมาบังเส้นขอบ */
.glass .mfield { padding-top: 20px; }
.glass .mfield > label { top: 0; left: 2px; padding: 0; background: none; font-size: 13.5px; color: #486777; }
.glass .mfield input {
  background: rgba(255, 255, 255, .96); border-color: #bcd6e3; border-radius: 7px;
  box-shadow: inset 0 1px 2px rgba(20, 60, 90, .06);
}

/* ============================================================
 * ปุ่ม
 * ============================================================ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap; cursor: pointer;
  font-family: var(--font); font-size: 14.5px; font-weight: 500;
  padding: 9px 20px; border-radius: 8px;
  border: 1px solid var(--cyan); background: var(--cyan); color: #fff;
  transition: background .15s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--cyan-d); border-color: var(--cyan-d); }
button.ghost { background: #fff; color: var(--cyan-d); }
button.ghost:hover { background: #e8f6fd; }
button.plain { background: #fff; color: var(--muted); border-color: var(--line); }
button.plain:hover { background: #f2f6f9; color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: #fff; }

/* ============================================================
 * หน้าเข้าสู่ระบบ
 * ============================================================ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-frame { width: min(430px, 92vw); }
.glass {
  background: linear-gradient(160deg, rgba(238, 250, 255, .93), rgba(214, 240, 250, .86));
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 10px;
  padding: 32px 30px 30px;
  box-shadow: 0 20px 60px rgba(0, 25, 45, .35), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.glass .brand-logo { width: 172px; margin: 2px auto 14px; }
.login-title {
  text-align: center; font-size: 19px; font-weight: 600; color: var(--brand);
  letter-spacing: .01em;
}
.login-kicker {
  text-align: center; font-size: 11px; font-weight: 500; letter-spacing: .28em;
  color: #7e97a6; margin: 3px 0 26px;
}
.glass .mfield { margin-bottom: 20px; }
.glass button[type="submit"] {
  width: 100%; margin-top: 6px; padding: 12px;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(20, 120, 180, .25);
}
.login-foot { margin-top: 20px; text-align: center; font-size: 12px; color: #5a7a8b; }

.msg { margin-top: 14px; padding: 10px 13px; border-radius: 8px; font-size: 13px; display: none; }
.msg.show { display: block; }
.msg.err  { background: #fdeae6; color: var(--err); }
.msg.ok   { background: #e4f5ec; color: var(--ok); }
.msg.warn { background: #fdf4e3; color: #8a5d05; }

/* ============================================================
 * ตาราง
 * ============================================================ */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px 16px; }
.filters .actions { display: flex; gap: 8px; align-items: center; }

.tablewrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: 12px; background: #fff;
  box-shadow: 0 1px 3px rgba(20, 50, 80, .05);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--cyan); color: #fff;
  text-align: center; font-weight: 500; font-size: 14px;
  padding: 13px 14px; white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 11px; }
thead th:last-child  { border-top-right-radius: 11px; }
tbody td {
  padding: 11px 14px; border-bottom: 1px solid #eef2f6;
  white-space: nowrap; text-align: center;
}
tbody tr:hover { background: #f4fafd; }
tbody tr:last-child td { border-bottom: 0; }
td.plate-cell { font-weight: 600; font-size: 15px; letter-spacing: .02em; }
td.mono, .mono { font-family: ui-monospace, 'Consolas', monospace; font-size: 12.5px; color: var(--muted); }
.empty { padding: 46px; text-align: center; color: var(--muted); }
.empty.hide { display: none; }

.tag { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.tag.veh  { background: #e3f3fc; color: #0d7fae; }
.tag.per  { background: #eeeafa; color: #59409c; }
.tag.in   { background: #e2f5ec; color: var(--ok); }
.tag.out  { background: #fdefdd; color: #a5670a; }

.pager { display: flex; align-items: center; gap: 10px; padding: 14px 4px; font-size: 13.5px; color: var(--muted); }
.pager .spacer { flex: 1; }
.pager strong { color: var(--ink); font-weight: 600; }

/* ============================================================
 * หน้าพิมพ์ QR
 * ============================================================ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.qcard {
  background: #fff; border: 1px solid #c6d4de; border-radius: 10px;
  padding: 16px 14px 13px; text-align: center; break-inside: avoid;
}
.qcard svg { display: block; margin: 0 auto 10px; width: 168px; height: 168px; }
.qcard .p { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.qcard .v { font-size: 13px; color: var(--muted); }
.qcard .c { font-size: 10px; color: #a8b4be; margin-top: 7px; letter-spacing: 1px; font-family: ui-monospace, monospace; }
.qcard.bad { border-color: #e8b6ac; background: #fdf6f4; }
.qcard.bad .p { color: var(--err); font-size: 15px; }

@media print {
  .noprint { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; }
  .cards { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .card { border: none; padding: 0; box-shadow: none; }
}

@media (max-width: 900px) {
  .topbar h1, .topbar .divider { display: none; }
}
