/* =============================================================
   BPH Bus/Van Booking - Mobile-First CSS
   ============================================================= */

/* Google Fonts - ภาษาไทย */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: 'Prompt', sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  padding-bottom: 70px;
  max-width: 520px;
  margin: 0 auto;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header h1 { font-size: 1.15rem; font-weight: 600; }
.header .sub { font-size: .75rem; opacity: .85; margin-top: 2px; }

/* ===== Pages ===== */
.page { display: none; padding: 12px; }
.page.active { display: block; }

/* ===== Form Controls ===== */
.form-row {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.form-row label {
  font-size: .8rem;
  font-weight: 500;
  color: #555;
  display: block;
  margin-bottom: 4px;
}
.form-row select,
.form-row input[type="date"],
.form-row input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: .9rem;
  outline: none;
}
.form-row select:focus,
.form-row input:focus {
  border-color: #1565c0;
}

/* ===== ตารางใบแจ้งสายรถ (หัวใจหลัก!) ===== */
.booking-grid {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  margin-bottom: 12px;
}
.booking-grid th,
.booking-grid td {
  border: 1.5px solid #cfd8dc;
  text-align: center;
  padding: 4px 2px;
  font-size: .75rem;
}
.booking-grid th {
  background: #1565c0;
  color: #fff;
  font-weight: 500;
  padding: 7px 2px;
}

/* ชื่อสายรถ (ซ้ายสุด) */
.booking-grid td.rl {
  background: #e3f2fd;
  font-weight: 600;
  color: #1565c0;
  font-size: .78rem;
  text-align: left;
  padding-left: 6px;
  white-space: nowrap;
}

/* ช่องรวมแต่ละแถว */
.booking-grid td.tc {
  background: #e8f5e9;
  font-weight: 700;
  color: #2e7d32;
  font-size: .88rem;
}

/* แถวรวมด้านล่าง */
.booking-grid tr.tr td {
  background: #fff3e0;
  font-weight: 700;
  color: #e65100;
  font-size: .82rem;
}
.booking-grid tr.tr td:first-child {
  background: #ff9800;
  color: #fff;
}

/* ===== ช่อง Input ตัวเลข ===== */
.ci {
  width: 44px;
  height: 34px;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  text-align: center;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: #1565c0;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.ci::-webkit-inner-spin-button,
.ci::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
.ci:focus {
  border-color: #1565c0;
  background: #e3f2fd;
}
.ci::placeholder { color: #ccc; }

/* ===== Submit Area ===== */
.submit-area {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.submit-area .lr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.submit-area .lr label {
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
}
.submit-area .lr input { flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: .15s;
  width: 100%;
}
.btn:active { transform: scale(.95); }
.btn-success { background: #2e7d32; color: #fff; }
.btn:disabled { background: #ccc; color: #999; }

/* ===== Summary Cards ===== */
.sc {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-left: 4px solid #1565c0;
}
.sc .st { font-size: .9rem; font-weight: 600; color: #1565c0; }
.sc .sd { font-size: .78rem; color: #666; margin-top: 4px; }
.sc .sn { font-size: 1.2rem; font-weight: 700; color: #2e7d32; text-align: right; }

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: #fff;
  display: flex;
  justify-content: space-around;
  padding: 6px 0 10px;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: .65rem;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  border: none;
  background: none;
  font-family: 'Prompt', sans-serif;
}
.nav-item.active { color: #1565c0; }
.nav-item .ni { font-size: 1.2rem; }

/* ===== Toast แจ้งเตือน ===== */
.tb {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 90%;
  max-width: 400px;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  font-size: .82rem;
  margin-bottom: 6px;
  animation: fi .3s;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.success { background: #2e7d32; }
.toast.error   { background: #c62828; }
.toast.info    { background: #1565c0; }
@keyframes fi {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Loading ===== */
.ld {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.85);
  z-index: 9998;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
}
.ld.show { display: flex; }
.sp {
  width: 36px; height: 36px;
  border: 4px solid #e0e0e0;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lm { font-size: .82rem; color: #666; }

/* ===== Empty State ===== */
.empty { text-align: center; padding: 40px 20px; color: #aaa; }
.empty .ei { font-size: 2.5rem; margin-bottom: 8px; }

/* ===== Section Title ===== */
.stitle {
  font-size: .92rem;
  font-weight: 600;
  color: #1565c0;
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Grand Total Box ===== */
.gt {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin: 12px 0;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.gt .gn {
  font-size: 2rem;
  font-weight: 700;
  display: block;
  margin-top: 4px;
}

/* ===== Print ===== */
@media print {
  .bottom-nav, .header, .btn { display: none !important; }
  .page { display: block !important; padding: 0; }
}

/* ===== Shift Selector ===== */
.btn-shift {
  flex: 1;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: .88rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: .15s;
  text-align: center;
}
.btn-shift.active {
  border-color: #1565c0;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 600;
}
.btn-shift:active {
  transform: scale(.97);
}