/* MSFleet UI — Bolt/Lalamove style */
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --panel: #ffffff;
  --panel-dark: #1e293b;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-invert: #f8fafc;
  --primary: #22c55e;      /* bolt/lalamove green */
  --primary-dark: #16a34a;
  --accent: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: 'Sarabun','Inter',system-ui,sans-serif; color: var(--text); }
body { background: #f1f5f9; }

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--bg); color: var(--text-invert);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.topbar .brand .logo { font-size: 26px; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; }
.topbar nav a {
  color: #cbd5e1; padding: 8px 14px; border-radius: 8px; font-size: 14px;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- Booking page ---------- */
.split {
  display: grid; grid-template-columns: 420px 1fr; flex: 1; min-height: 0;
}
@media (max-width: 880px) { .split { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } }

.panel {
  background: var(--panel); overflow-y: auto; padding: 18px; border-right: 1px solid var(--border);
}
#map { width: 100%; height: 100%; background: #aadaff; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff;
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* segmented control for service type */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 12px; }
.segmented button {
  border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--text-muted);
}
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; min-width: 96px; text-align: left; transition: .15s;
}
.chip .ic { font-size: 22px; }
.chip .nm { font-size: 13px; font-weight: 600; }
.chip .pr { font-size: 11px; color: var(--text-muted); }
.chip:hover { border-color: var(--primary); }
.chip.active { border-color: var(--primary); background: #f0fdf4; box-shadow: 0 0 0 2px var(--primary) inset; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--text); color: #fff; border: 0; padding: 12px 18px; border-radius: 12px;
  font-weight: 700; font-size: 15px; width: 100%; transition: .15s;
}
.btn:hover { opacity: .92; }
.btn.primary { background: var(--primary); color: #062b14; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Fare estimate card ---------- */
.fare-card {
  background: linear-gradient(135deg, #22c55e22, #3b82f622);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0;
}
.fare-card .total { font-size: 30px; font-weight: 800; color: var(--primary-dark); }
.fare-card .meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.fare-card .row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; }

/* ---------- stops list ---------- */
.stop-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.stop-item { display: flex; gap: 8px; align-items: flex-start; }
.stop-item .dot {
  width: 14px; height: 14px; border-radius: 50%; margin-top: 12px; flex: 0 0 14px;
  background: var(--accent);
}
.stop-item.pickup .dot { background: var(--primary); }
.stop-item.dropoff .dot { background: var(--danger); }

/* ---------- toast / status ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg); color: #fff; padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 9999; font-size: 14px; max-width: 90vw;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--primary-dark); }

/* ---------- Agent chat ---------- */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: #f8fafc; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--primary); color: #062b14; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--text-muted); font-size: 12px; }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); background: #fff; }
.chat-input input { flex: 1; }

/* ---------- Tables (dispatch) ---------- */
.table-wrap { background: #fff; border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); margin: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.pending, .badge.quoted { background: #fef3c7; color: #92400e; }
.badge.accepted, .badge.assigned, .badge.enroute_pickup, .badge.enroute_dropoff, .badge.picked_up { background: #dbeafe; color: #1e40af; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.cancelled, .badge.no_show { background: #fee2e2; color: #991b1b; }

.toolbar { display: flex; gap: 8px; align-items: center; padding: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---------- track page ---------- */
.track-wrap { height: calc(100vh - 60px); }
.track-info { position: absolute; bottom: 20px; left: 20px; right: 20px; max-width: 520px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; z-index: 1000; }
.track-info .driver { display: flex; align-items: center; gap: 12px; }
.track-info .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 22px; }

.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
