/* /public_html/assets/css/driver.css — Liên Kết 24h
   FULL CODE (không lược)
   --------------------------------------------------------------------------
   Phục vụ cổng tài xế (dashboard.php, vehicles.php, orders.php):
   • Mobile-first, tap-friendly
   • Bản đồ Leaflet không lệch popup (khử transform ancestor)
   • Bảng/offers, Job box, Form phương tiện, KYC, Admin
   -------------------------------------------------------------------------- */

/* =================== Variables =================== */
:root{
  --bg:#fafafa;
  --card:#ffffff;
  --bd:#ececf1;
  --bd-strong:#dfe1e8;
  --ink:#111111;
  --muted:#666666;

  --brand:#c62828;
  --brand-ink:#ffffff;

  --ok:#10b981;
  --info:#0ea5e9;
  --warn:#f59e0b;
  --danger:#e02424;

  --radius:14px;
  --radius-sm:10px;
  --shadow:0 8px 30px rgba(0,0,0,.06);
  --shadow-sm:0 2px 10px rgba(0,0,0,.06);

  --tap:42px;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --safe-left:env(safe-area-inset-left,0px);
  --safe-right:env(safe-area-inset-right,0px);
}

/* =================== Reset/Base =================== */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body.driver-theme{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* =================== Layout =================== */
.container{
  max-width:1120px;
  margin:0 auto;
  padding:16px;
  padding-left:calc(16px + var(--safe-left));
  padding-right:calc(16px + var(--safe-right));
}
.page-title{
  margin:0 0 6px;
  font-size:1.35rem;
  line-height:1.25;
}
.page-subtitle{
  margin:0 0 14px;
  color:var(--muted);
  font-size:.95rem;
}

/* Sections / Cards */
.card{
  background:var(--card);
  border:1px solid var(--bd);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:12px;
}
.card + .card{ margin-top:12px; }

.section-title{
  display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap;
  margin:0 0 8px; font-size:1.05rem;
}

/* Grid helpers */
.grid{ display:grid; gap:12px; grid-template-columns:1fr; }
@media (min-width:920px){ .grid-2{ display:grid; gap:12px; grid-template-columns:1.2fr .8fr; } }

/* =================== Buttons =================== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-height:var(--tap);
  padding:10px 14px;
  border-radius:var(--radius-sm);
  border:1px solid var(--bd);
  background:#fff; color:var(--ink);
  cursor:pointer; user-select:none; text-decoration:none;
  transition:background .15s ease, border-color .15s ease, transform .04s ease;
}
.btn:hover{ background:#f7f7f9; }
.btn:active{ transform:translateY(1px); }
.btn-primary{ border-color:var(--brand); background:var(--brand); color:var(--brand-ink); }
.btn-primary:hover{ filter:brightness(.98); }
.btn-outline{ border-color:var(--brand); color:var(--brand); background:#fff; }
.btn-outline:hover{ background:#fff5f5; }
.btn-ghost{ border-color:transparent; background:transparent; }
.btn-danger{ border-color:var(--danger); background:var(--danger); color:#fff; }

/* Small variant */
.btn-sm{ padding:6px 10px; min-height:34px; border-radius:9px; font-size:.92rem; }

/* =================== Forms =================== */
label{ display:block; font-size:.92rem; color:#444; margin:0 0 6px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"],
input[type="file"], select, textarea{
  width:100%; font:inherit; padding:11px 12px;
  border:1px solid var(--bd); border-radius:var(--radius-sm); background:#fff;
  transition:border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:color-mix(in srgb, var(--brand) 60%, var(--bd));
  box-shadow:0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}
textarea{ min-height:86px; resize:vertical; }

/* Form rows */
.row{ display:grid; gap:10px; grid-template-columns:1fr; }
@media (min-width:560px){ .row-2{ grid-template-columns:1fr 1fr; } }
@media (min-width:920px){ .row-3{ grid-template-columns:1fr 1fr 1fr; } }

.input-group{ display:flex; align-items:stretch; gap:8px; }
.input-group > .grow{ flex:1; }
.help{ color:var(--muted); font-size:.88rem; }

/* =================== Map (Leaflet) =================== */
/* Bảo đảm không bị lệch popup do ancestor có transform */
#mapCard{ padding:10px; }
#mapBox{
  width:100%;
  height:360px;
  border:1px solid var(--bd);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
  overflow:hidden;

  translate:none;
  contain:layout paint size style;
  will-change:auto;
  backface-visibility:hidden;
}
@media (min-width:560px){ #mapBox{ height:440px; } }
@media (min-width:920px){ #mapBox{ height:520px; } }

.leaflet-container{ font:inherit; z-index:0; }
.leaflet-control-zoom a{ width:34px; height:34px; line-height:34px; color:#111; }
.leaflet-popup-content-wrapper{ border-radius:10px; }
.leaflet-container a{ color:var(--brand); }
.lk-dot{ filter:drop-shadow(0 1px 6px rgba(0,0,0,.35)); }

/* =================== State badge =================== */
#stateBadge{
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--bd);
  background:#fff;
  font-size:.9rem;
}
.badge-dot{ width:10px; height:10px; border-radius:50%; display:inline-block; }
.badge-offline{ background:#9ca3af; }
.badge-online{ background:var(--ok); }
.badge-busy{ background:var(--warn); }
.badge-ontrip{ background:#3b82f6; }

/* =================== Offers table =================== */
.table{
  width:100%;
  border-collapse:separate; border-spacing:0;
  border:1px solid var(--bd); border-radius:12px; overflow:hidden;
  background:#fff; box-shadow:var(--shadow-sm);
}
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid var(--bd);
  text-align:left; font-size:.95rem;
}
.table th{ background:#f8f9fb; color:#333; font-weight:600; }
.table tr:last-child td{ border-bottom:none; }
.table td.nowrap{ white-space:nowrap; }

.table-scroll{ overflow:auto; border-radius:12px; border:1px solid var(--bd); background:#fff; }
.table-empty{
  display:none; padding:10px 12px; color:var(--muted);
  background:#fff; border:1px dashed var(--bd); border-radius:var(--radius);
}

/* =================== Job box =================== */
#jobBox{
  display:none;
  border:1px solid var(--bd);
  border-radius:var(--radius);
  background:#fff;
  padding:10px 12px;
  box-shadow:var(--shadow-sm);
}
#jobId{ font-weight:700; color:var(--brand); }
#jobStatus{ font-weight:600; }
#jobRoute{ color:#333; word-break:break-word; }
.job-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* =================== Vehicles =================== */
#vehicleForm.card{ padding:12px; }
#photoPreview{
  width:100%; min-height:140px; border:1px dashed var(--bd);
  border-radius:12px; background:#f6f7fb center/cover no-repeat;
}
#vehicleList[data-loading="1"] .veh-skeleton{ animation:vehSk 1.2s linear infinite; }
#vehiclesEmpty{ display:none; padding:10px 12px; color:var(--muted); background:#fff; border:1px dashed var(--bd); border-radius:var(--radius); }

.veh-card{
  border:1px solid var(--bd);
  border-radius:12px; background:#fff; padding:12px;
  box-shadow:var(--shadow-sm);
}
.veh-card + .veh-card{ margin-top:10px; }

/* =================== Earnings summary =================== */
.sum-grid{
  display:grid; gap:10px; grid-template-columns:1fr 1fr 1fr;
}
.sum-box{
  background:#fff; border:1px solid var(--bd); border-radius:12px;
  padding:10px 12px; text-align:center; box-shadow:var(--shadow-sm);
}
.sum-title{ color:var(--muted); font-size:.9rem; }
.sum-value{ font-size:1.15rem; font-weight:700; }

/* =================== Quick report / SOS =================== */
.quick-row{ display:flex; gap:8px; align-items:stretch; }
.quick-row .grow{ flex:1; }

/* =================== Admin panels =================== */
.admin-grid{ display:grid; gap:12px; grid-template-columns:1fr; }
@media (min-width:920px){ .admin-grid{ grid-template-columns:1fr 1fr; } }
.admin-card{ border:1px solid var(--bd); border-radius:12px; background:#fff; padding:12px; box-shadow:var(--shadow-sm); }

/* =================== Utilities =================== */
.flex{ display:flex; align-items:center; gap:8px; }
.center{ text-align:center; }
.right{ text-align:right; }
.muted{ color:var(--muted); }
.space{ height:10px; }
.hr{ height:1px; background:var(--bd); margin:8px 0; }
.badge{
  display:inline-block; padding:2px 8px; border-radius:999px; font-size:.82rem;
  border:1px solid var(--bd); background:#fff; color:#333;
}
.badge.brand{
  border-color:color-mix(in srgb, var(--brand) 45%, #fff);
  background:color-mix(in srgb, var(--brand) 6%, #fff);
  color:var(--brand);
}

/* Skeleton */
.skeleton{
  background:linear-gradient(90deg,#eee,#f7f7f7,#eee);
  background-size:200% 100%;
  animation:sk 1.2s linear infinite;
  border-radius:10px;
}
@keyframes sk{ 0%{background-position:200% 0} 100%{background-position:-200% 0} }
@keyframes vehSk{ 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* Toast (fallback nếu chưa có) */
#toast{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(16px + var(--safe-bottom));
  z-index:2147482000; display:none;
}
#toastMsg{
  background:#111; color:#fff; padding:10px 14px; border-radius:10px;
  box-shadow:0 8px 30px rgba(0,0,0,.25);
}

/* Header actions (trên cùng của page) */
.header-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* Footer safe space để tránh bị che bởi bottom nav (nếu có) */
.footer-space{ height:calc(12px + var(--safe-bottom)); }

/* =================== Responsive tweaks =================== */
@media (max-width:480px){
  .btn{ width:100%; }
  .input-group{ flex-direction:column; }
  .sum-grid{ grid-template-columns:1fr; }
}

/* =================== Print =================== */
@media print{
  .btn, .header-actions, .footer-space{ display:none !important; }
  .card, .table, .sum-box{ box-shadow:none !important; }
  #mapBox{ height:280px !important; border-color:#ddd; }
}
/* ==========================================================================
   /assets/css/driver.css — Driver UI
   Note: Các class .sc-* bên dưới dùng cho popup Self-check xe (mới)
   ========================================================================== */

/* Bạn có thể giữ nguyên các phần CSS sẵn có của bạn ở trên.
   Khối dưới đây chỉ bổ sung modal Self-check, không override code cũ. */

/* ==== SELF-CHECK MODAL (fit viewport + scrollable body) =================== */

/* Backdrop (có thể JS dùng id/class khác, đã thêm selector dự phòng) */
.sc-backdrop, #scBackdrop, #drvSelfcheckBackdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0,0,0,.40);
  display: none;
  z-index: 2147483400;
}
.sc-backdrop.sc-show, #scBackdrop.sc-show, #drvSelfcheckBackdrop.sc-show {
  display: block;
}

/* Panel khung modal */
.sc-panel, .sc-dlg-panel, #drvSelfcheckPanel, [role="dialog"].sc-panel, .vsc-modal .panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: min(96vw, 860px);
  max-height: min(92vh, 760px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #ececf1;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  overflow: hidden; /* quan trọng để phần body cuộn không tràn */
  z-index: 2147483500;
}

/* Header & Footer cố định, Body cuộn độc lập */
.sc-head, .sc-dlg-head, #drvSelfcheckHead {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(#fff,#fdfdfd);
}
.sc-title {
  margin: 0; font-size: 16px; font-weight: 700;
}
.sc-close {
  border: 0; background: #f3f4f6; width: 32px; height: 32px; border-radius: 10px;
  cursor: pointer;
}
.sc-close:hover { background: #eee; }

.sc-body, .sc-dlg-body, #drvSelfcheckBody, .sc-content {
  padding: 12px 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* mượt trên iOS */
  flex: 1 1 auto; min-height: 0; background: #fff;
}

.sc-foot, .sc-dlg-foot, #drvSelfcheckFoot {
  padding: 12px 16px;
  border-top: 1px solid #f0f0f3;
  background: #fff;
  display: flex; justify-content: flex-end; gap: 8px;
  flex: 0 0 auto;
}

/* Inputs hàng đầu (chọn xe, ghi chú...) */
.sc-field { margin-bottom: 10px; }
.sc-field label { display:block; font-size: .92rem; color:#555; margin:0 0 6px; }
.sc-input, .sc-select, .sc-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #e6e6ea; border-radius: 10px; font: inherit;
}
.sc-textarea { resize: vertical; }

/* Checklist dài, dạng thẻ – responsive gọn */
.sc-checklist, .sc-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.sc-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 10px; padding: 10px 12px; border: 1px solid #eee; border-radius: 12px; background:#fff;
}
.sc-item .sc-text { min-width: 0; }
.sc-item .sc-title { font-size: 15px; margin:0; }
.sc-item .sc-sub { font-size: 12px; color:#888; margin-top:2px; }
.sc-item .sc-choices { display:flex; gap:16px; align-items:center; }

/* Nút */
.sc-btn { display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 14px; border-radius:10px; border:1px solid #ddd; background:#fff; cursor:pointer; }
.sc-btn:hover { background:#f7f7f7; }
.sc-btn-primary { border-color:#c62828; background:#c62828; color:#fff; }
.sc-btn-primary:hover { filter:brightness(.96); }

/* Mobile full-screen */
@media (max-width: 720px) {
  .sc-panel, .sc-dlg-panel, #drvSelfcheckPanel, .vsc-modal .panel {
    width: 100vw; height: 100vh; max-height: 100vh;
    top: 0; left: 0; transform: none; border-radius: 0;
  }
  .sc-head, .sc-dlg-head, #drvSelfcheckHead { padding-top: calc(12px + env(safe-area-inset-top,0)); }
  .sc-foot, .sc-dlg-foot, #drvSelfcheckFoot { padding-bottom: calc(12px + env(safe-area-inset-bottom,0)); }
}

/* Khóa cuộn nền khi mở modal (JS thêm class này vào <body>) */
body.sc-open { overflow: hidden !important; }
