/* ============================================================
   CCN — หน้าลูกค้าติดตามรถ (standalone, public)
   ธีมแดงเข้าชุดกับ ccn-transport-v2
   ============================================================ */

:root {
  --brand:      #b91c1c;
  --brand-dark: #991b1b;
  --brand-soft: #fef2f2;
  --brand-ring: rgba(185, 28, 28, 0.15);

  --ok:    #16a34a;
  --ok-soft:#f0fdf4;
  --idle:  #d97706;
  --idle-soft:#fffbeb;
  --off:   #64748b;
  --off-soft:#f1f5f9;

  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;
  --border:    #e2e8f0;

  --radius:    16px;
  --radius-sm: 11px;
  --pill:      999px;
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 8px 28px rgba(15,23,42,.06);
  --shadow-lg: 0 18px 50px rgba(15,23,42,.16);

  --font: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: .5px;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.25; }
.logo-text strong { font-size: 16px; font-weight: 700; }
.logo-text span { font-size: 12.5px; opacity: .85; }

/* ── Layout ── */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

/* ── Hero / search ── */
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.hero .sub { color: var(--text-2); margin-top: 6px; font-size: 15px; }

.search-wrap {
  position: relative;
  max-width: 520px;
  margin: 22px auto 0;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--pill);
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}

/* ── Autocomplete dropdown ── */
.suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  text-align: left;
  animation: rise .16s ease;
}
.suggest li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .1s;
}
.suggest li:hover,
.suggest li.active { background: var(--brand-ring); }
.suggest .s-plate {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .5px;
  color: var(--text);
}
.suggest .s-plate b { color: var(--brand); }
.suggest .s-meta {
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.suggest .s-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.suggest .s-dot.moving { background: #16a34a; }
.suggest .s-dot.idle   { background: #eab308; }
.suggest .s-dot.off    { background: #94a3b8; }
.suggest .s-dot.nogps  { background: #cbd5e1; }
.suggest .s-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
.search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring), var(--shadow);
}
.search-ico { font-size: 17px; opacity: .6; }
.search input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text);
  min-width: 0;
}
.search input::placeholder { color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.btn-search {
  flex-shrink: 0;
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: var(--pill);
  cursor: pointer;
  transition: transform .12s, filter .12s;
}
.btn-search:hover { filter: brightness(1.06); }
.btn-search:active { transform: scale(.97); }

.hint {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text-3);
  min-height: 18px;
}
.hint.err { color: var(--brand); }

/* ── Result card ── */
.result { animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.plate-badge {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 6px 14px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13.5px;
  padding: 7px 14px;
  border-radius: var(--pill);
  white-space: nowrap;
}
.status-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.status-pill.moving { color: var(--ok);   background: var(--ok-soft); }
.status-pill.idle   { color: var(--idle); background: var(--idle-soft); }
.status-pill.off    { color: var(--off);  background: var(--off-soft); }
.status-pill.moving::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.card-body { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.place { display: flex; gap: 12px; align-items: flex-start; }
.place-ico { font-size: 20px; line-height: 1.4; }
.place-name { font-weight: 700; font-size: 17px; }
.place-meta { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.metric-label { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.metric-value { font-size: 19px; font-weight: 700; }
.metric-value small { font-size: 12px; color: var(--text-3); font-weight: 600; }
.metric-value.mono { font-family: var(--mono); font-size: 14px; font-weight: 600; }

.map {
  height: 300px;
  width: 100%;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 0;
}

.card-foot {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: var(--pill);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-3); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }

/* ── States ── */
.state { text-align: center; padding: 40px 20px; }
.state-ico { font-size: 44px; }
.state h2 { font-size: 19px; margin-top: 10px; }
.state p { color: var(--text-2); margin-top: 6px; font-size: 14.5px; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 18px;
  color: var(--text-3);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

@media (max-width: 440px) {
  .hero h1 { font-size: 22px; }
  .btn-search { padding: 11px 16px; }
  .metrics { grid-template-columns: 1fr; }
  .map { height: 240px; }
}
