/* ========== Font: Phetsarath OT ==========
   ວາງໄຟລ໌ຟອນ Phetsarath-OT.ttf ໄວ້ທີ່ public/fonts/Phetsarath-OT.ttf
   (ດາວໂຫຼດໄດ້ຈາກ Google Fonts: https://fonts.google.com/specimen/Phetsarath)
   ຖ້າບໍ່ມີໄຟລ໌ຟອນ ລະບົບຈະໃຊ້ Noto Sans Lao ຈາກ Google Fonts CDN ແທນອັດຕະໂນມັດ (ຕ້ອງມີອິນເຕີເນັດ) */
@font-face {
  font-family: 'Phetsarath OT';
  src: url('/fonts/Phetsarath-OT.ttf') format('truetype');
  font-weight: normal;
  font-display: swap;
}

:root {
  --lo-font: 'Phetsarath OT', 'Noto Sans Lao', 'Saysettha OT', sans-serif;
  --maroon: #155e9c;
  --maroon-dark: #0d4173;
  --gold: #2ea0da;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1e2733;
  --muted: #6b7787;
  --border: #dce5f0;
  --success: #2e7d32;
  --warning: #b8860b;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  font-family: var(--lo-font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.7;
}

a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Navbar ---------- */
.navbar {
  background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
  color: #fff;
  padding: 14px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.navbar .brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: bold; color: #fff; }
.navbar .brand small { display: block; font-weight: normal; font-size: 14px; opacity: .85; }
.navbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.navbar nav a { color: #fdf6e3; font-size: 17px; }
.navbar nav a.active { border-bottom: 2px solid var(--gold); padding-bottom: 3px; }
.navbar .user-chip { background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 20px; font-size: 15px; }
.navbar form { display: inline; }
.navbar button.linklike {
  background: none; border: none; color: #fdf6e3; font-family: var(--lo-font); font-size: 15px; cursor: pointer; padding: 0;
}

.user-menu { position: relative; }
.user-chip-btn {
  background: rgba(255,255,255,.12); padding: 6px 14px; border-radius: 20px; font-size: 15px;
  border: none; color: #fdf6e3; font-family: var(--lo-font); cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.user-chip-btn:hover { background: rgba(255,255,255,.2); }
.user-chip-btn .caret { font-size: 12px; transition: transform .15s ease; }
.user-menu.open .caret { transform: rotate(180deg); }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); overflow: hidden; z-index: 100;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown .dropdown-item {
  display: block; width: 100%; text-align: left; padding: 12px 16px; font-size: 15px;
  color: #000000; background: #ffffff; border: none; cursor: pointer; font-family: var(--lo-font); box-sizing: border-box;
}
.user-dropdown a:visited { color: #000000; }
.user-dropdown a:hover, .user-dropdown .dropdown-item:hover { background: #eef3f9; color: var(--maroon); text-decoration: none; }
.user-dropdown form { display: block; margin: 0; }

/* ---------- Layout helpers ---------- */
.page { padding: 28px 0 60px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer;
  font-family: var(--lo-font); font-size: 15px; text-align: center; text-decoration: none;
}
.btn-primary { background: var(--maroon); color: #fff; }
.btn-primary:hover { background: var(--maroon-dark); text-decoration: none; }
.btn-gold { background: var(--gold); color: #2b2200; }
.btn-outline { background: transparent; border: 1px solid var(--maroon); color: var(--maroon); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; margin: 12px 0 5px; font-weight: bold; font-size: 14.5px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--lo-font); font-size: 15px; background: #fff; color: var(--text);
}
textarea { min-height: 80px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 200px; }
.checkbox-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-weight: normal; margin: 4px 0; }
.checkbox-list input { width: auto; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error-box { background: #fdecea; border: 1px solid var(--danger); color: var(--danger); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.success-box { background: #e8f5e9; border: 1px solid var(--success); color: var(--success); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #f1ece0; font-weight: bold; }
tr:hover td { background: #fbf9f3; }
.table-wrap { overflow-x: auto; }
.table-wrap th, .table-wrap td { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: bold; }
.badge-active { background: #e8f5e9; color: var(--success); }
.badge-expired { background: #fdecea; color: var(--danger); }
.badge-revoked { background: #eeeeee; color: #666; }
.badge-verified { background: #e8f5e9; color: var(--success); border: 1px solid var(--success); }

/* ---------- Stat cards ---------- */
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; }
.stat-card .num { font-size: 30px; font-weight: bold; color: var(--maroon); }
.stat-card .label { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- Home hero / search ---------- */
.hero { background: linear-gradient(135deg, var(--maroon), var(--maroon-dark)); color: #fff; padding: 60px 0 80px; text-align: center; }
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero p { opacity: .9; margin-bottom: 26px; }
.search-box { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.search-box input { flex: 1; padding: 14px 16px; border-radius: 8px; border: none; font-size: 16px; }
.search-box button { padding: 0 24px; border-radius: 8px; }

/* ---------- Verify page ---------- */
.verify-card { max-width: 640px; margin: 40px auto; text-align: center; }
.verify-card .stamp { font-size: 60px; }
.verify-card .stamp-logo { width: 90px; height: 90px; object-fit: contain; display: block; margin: 0 auto 8px; }

/* ---------- Print styles ---------- */
.invoice-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 20mm 18mm;
  border: 1px solid var(--border);
  color: #000;
  font-size: 13px;
}
.invoice-sheet h2 { text-align: center; color: #000; font-size: 18px; margin-bottom: 4px; }
.invoice-sheet .inv-subtitle { text-align: center; color: #000; font-size: 12px; margin-top: 0; }
.invoice-sheet table { font-size: 13px; }
.invoice-sheet table th, .invoice-sheet table td { border: 1px solid var(--border); padding: 8px 10px; }
.invoice-sheet .inv-grand-total { font-size: 15px; }
.invoice-sheet .inv-sign-block { font-size: 13px; }

.inv-payment-block { margin-top: 26px; padding: 16px 18px; border: 1px dashed var(--border); border-radius: 10px; background: #fafbfd; }
.inv-payment-title { font-weight: bold; font-size: 14px; margin-bottom: 10px; color: var(--maroon); }
.inv-payment-body { display: flex; align-items: flex-start; gap: 20px; }
.inv-payment-qr { width: 110px; height: 110px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; flex: none; }
.inv-payment-text { font-size: 13px; line-height: 1.7; white-space: pre-wrap; flex: 1; }

/* ---------- Official permit letterhead (matches government form layout) ---------- */
.official-permit {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  border: 3px double var(--maroon);
  padding: 10mm 18mm 18mm;
  font-family: var(--lo-font);
  color: #111;
  position: relative;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.op-header { text-align: center; margin-bottom: 10px; margin-top: 3mm; }
.op-emblem { width: 2.5cm; height: 2.51cm; object-fit: contain; margin: 0 auto 8px; display: block; }
.op-emblem-placeholder {
  width: 2.5cm; height: 2.51cm; border-radius: 50%; border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center; font-size: 32px; margin: 0 auto 8px;
}
.op-country { font-weight: bold; font-size: 17px; line-height: 1.4; }
.op-motto { font-size: 16px; font-weight: bold; margin-top: 4px; line-height: 1.4; }

.op-office-block { display: flex; justify-content: space-between; margin-top: 20px; font-size: 14px; font-weight: normal; line-height: 1.4; }
.op-office-right { text-align: right; }

.op-title { text-align: center; font-size: 19px; font-weight: bold; color: #000; margin-top: 22px; line-height: 1.3; }
.op-subtitle { text-align: center; font-size: 17px; font-weight: bold; margin-top: 4px; margin-bottom: 16px; line-height: 1.3; }

.op-legal { font-size: 15px; color: #333; line-height: 1.5; margin-bottom: 16px; }

/* Bullet rows: "-" ຫ່າງຈາກຕົວໜັງສື 2mm, ແລະ ຕົວໜັງສືທີ່ຕົກແຖວໃໝ່ຈະຊິດກັນກັບແຖວທຳອິດພໍດີ (flex ຮັບປະກັນ) */
.op-bullet-row { display: flex; align-items: flex-start; margin-bottom: 5px; }
.op-bullet { flex: none; }
.op-bullet-text { flex: 1; margin-left: 2mm; }

.op-fields { font-size: 15px; line-height: 1.5; margin-left: 2mm; }

.op-issued-to { margin-bottom: 14px; text-align: center; }
.op-issued-to-office { font-size: 17px; font-weight: bold; line-height: 1.3; }
.op-issued-to-line { font-size: 16px; font-weight: bold; margin-top: 5px; line-height: 1.3; }
.op-fill { padding: 0 4px; }

.op-field { margin-bottom: 8px; }
.op-label { font-weight: normal; }
.op-label-bold { font-weight: bold; }
.op-value { font-weight: normal; }
.op-dots { padding-bottom: 1px; }
.op-biz-list { margin: 4px 0 8px 28px; padding: 0; font-weight: normal; line-height: 1.4; }
.op-biz-list li { margin-bottom: 4px; }

.op-signature { text-align: left; margin-left: 12cm; margin-top: 36px; font-size: 16px; font-weight: bold; }
.op-sig-space { height: 130px; }

.op-qr-block { position: absolute; left: 50px; bottom: 50px; text-align: center; }
.op-qr-block img { width: 110px; height: 110px; }

/* ---------- Page 2 of the permit: instructions / notes, optional back-side template image ---------- */
.official-permit-page2 { margin-top: 20px; padding: 22mm 20mm; }
.op-page2-title { text-align: center; font-size: 19px; font-weight: bold; margin-bottom: 18px; }
.op-page2-content { font-size: 15px; line-height: 1.8; white-space: pre-wrap; }

.page-break { page-break-before: always; break-before: page; }

@page {
  size: A4;
  margin: 0;
}

@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .no-print { display: none !important; }
  body { background: #fff; margin: 0; }
  .page { padding: 0; }
  .container { padding: 0; max-width: none; margin: 0; }
  .official-permit { box-shadow: none; border: 3px double #000; margin: 0; }
  .official-permit-page2 { margin-top: 0; }
  .invoice-sheet { box-shadow: none; border: 1px solid #999; margin: 0; }
}

footer.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0; }

.tag-pill { display: inline-block; background: #f1ece0; border-radius: 20px; padding: 3px 10px; font-size: 12.5px; margin: 2px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.mt-0 { margin-top: 0; }
.text-muted { color: var(--muted); }
