/* ============================================================
   PHAME Rider — shared design system
   Uses PHAME brand palette (purple + orange). Supports light/dark.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  /* Brand */
  --brand:         #5B21B6;   /* PHAME purple */
  --brand-2:       #7C3AED;
  --brand-dark:    #4C1D95;
  --accent:        #F97316;   /* PHAME orange */
  --accent-2:      #FB923C;
  --brand-ink:     #ffffff;

  --success:       #10B981;
  --danger:        #DC2626;
  --warning:       #F59E0B;
  --info:          #3B82F6;

  --radius:        16px;
  --radius-sm:     12px;
  --font:          'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Light theme (default) ===== */
:root, [data-theme="light"] {
  --bg:            #F8FAFC;
  --bg-elev:       #ffffff;
  --bg-card:       #ffffff;
  --border:        #E5E7EB;
  --text:          #111827;
  --text-dim:      #6B7280;
  --text-muted:    #9CA3AF;
  --shadow:        0 10px 30px rgba(91,33,182,.10);
  --input-bg:      #F3F4F6;
}

/* ===== Dark theme ===== */
[data-theme="dark"] {
  --bg:            #0b0f14;
  --bg-elev:       #121821;
  --bg-card:       #182231;
  --border:        #223042;
  --text:          #e7ecf3;
  --text-dim:      #96a3b5;
  --text-muted:    #6b7a90;
  --shadow:        0 10px 30px rgba(0,0,0,.35);
  --input-bg:      #121821;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.app-container { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; position: relative; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 14px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; font-weight: 700; letter-spacing: .2px; flex: 1; color: var(--text); }
.topbar .icon-btn { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 16px; cursor: pointer; transition: all .15s ease; }
.topbar .icon-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.section { padding: 0 16px; }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin: 22px 4px 10px; padding: 0 12px; }

/* ===== Balance card (PHAME purple gradient) ===== */
.balance-card {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-radius: 20px;
  padding: 22px;
  margin: 4px 16px 0;
  box-shadow: 0 14px 32px rgba(91,33,182,.28);
  position: relative; overflow: hidden;
}
.balance-card::before {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(249,115,22,.35), transparent 70%);
}
.balance-card::after {
  content: ""; position: absolute; left: -40px; bottom: -80px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.balance-card .label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; opacity: .85; font-weight: 600; position: relative; z-index: 2; }
.balance-card .amount { font-size: 34px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; position: relative; z-index: 2; }
.balance-card .meta { display: flex; gap: 10px; margin-top: 14px; font-size: 12px; font-weight: 600; position: relative; z-index: 2; }
.balance-card .chip { background: rgba(255,255,255,.18); padding: 6px 10px; border-radius: 999px; backdrop-filter: blur(4px); }
.balance-card .actions { display: flex; gap: 10px; margin-top: 16px; position: relative; z-index: 2; }
.balance-card .actions a {
  flex: 1; text-align: center; padding: 12px; border-radius: 12px; text-decoration: none;
  font-weight: 700; font-size: 14px;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 14px rgba(249,115,22,.35);
}
.balance-card .actions a.ghost { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }

/* Locked state (negative balance) */
.balance-card.locked { background: linear-gradient(135deg, #DC2626, #991B1B); box-shadow: 0 14px 32px rgba(220,38,38,.3); }
.balance-card.locked .actions a { background: #fff; color: #991B1B; }
.balance-card.locked .actions a.ghost { background: rgba(255,255,255,.18); color: #fff; }

/* ===== Availability toggle ===== */
.availability {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; margin: 14px 16px 0;
  box-shadow: var(--shadow);
}
.availability .status { display: flex; align-items: center; gap: 10px; }
.availability .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); }
.availability.online .dot { background: var(--success); box-shadow: 0 0 0 4px rgba(16,185,129,.2); }
.availability.busy   .dot { background: var(--warning); }
.availability h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.availability p { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.switch { position: relative; width: 56px; height: 32px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px;
  transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 26px; height: 26px; background: #fff; border-radius: 50%;
  transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 12px; padding: 14px 18px;
  font-family: var(--font); font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .1s ease, opacity .2s ease, background .2s ease;
  width: 100%;
  box-shadow: 0 6px 16px rgba(91,33,182,.25);
}
.btn:hover { background: var(--brand-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.accent    { background: var(--accent); box-shadow: 0 6px 16px rgba(249,115,22,.3); }
.btn.accent:hover { background: var(--accent-2); }
.btn.danger    { background: var(--danger); box-shadow: none; }
.btn.success   { background: var(--success); box-shadow: none; }
.btn.outline   { background: transparent; color: var(--brand); border: 1px solid var(--brand); box-shadow: none; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 14px 14px;
  font-family: var(--font); font-size: 15px; outline: none;
  transition: border-color .15s ease;
}
.input:focus { border-color: var(--brand); }

/* ===== Trip row ===== */
.trip-row {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.trip-row .head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.trip-row .fare { font-size: 22px; font-weight: 800; color: var(--brand); }
.trip-row .distance { font-size: 12px; color: var(--text-dim); text-align: right; }
.trip-row .path { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text); }
.trip-row .path .pt { display: flex; align-items: flex-start; gap: 10px; }
.trip-row .path .pt i { width: 18px; text-align: center; margin-top: 2px; }
.trip-row .path .pt.pickup i { color: var(--success); }
.trip-row .path .pt.drop   i { color: var(--danger); }
.trip-row .name { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--text-dim); }
.trip-row .accept-btn { margin-top: 12px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--bg-elev); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-muted); font-size: 11px; font-weight: 500;
  padding: 6px 0;
}
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--brand); }

/* ===== Empty / loading ===== */
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty i { font-size: 48px; margin-bottom: 12px; color: var(--text-muted); display: block; }
.empty h4 { color: var(--text); margin-bottom: 6px; font-weight: 600; }

.skeleton { background: linear-gradient(90deg, var(--bg-elev) 25%, var(--border) 50%, var(--bg-elev) 75%); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px);
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: all .3s ease; z-index: 100;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { border-color: var(--success); }
.toast-error   { border-color: var(--danger); }
.toast-info    { border-color: var(--info); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card); width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 22px; border: 1px solid var(--border);
  animation: slideUp .25s ease; color: var(--text);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 12px; }
.modal .close { float: right; background: transparent; border: 0; color: var(--text-dim); font-size: 20px; cursor: pointer; }

/* ===== Quick amounts ===== */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-row button {
  flex: 1; min-width: 70px; background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); padding: 10px; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.chip-row button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== Row list ===== */
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.list-item .ico { width: 42px; height: 42px; border-radius: 12px; background: color-mix(in oklab, var(--brand) 12%, transparent); display: grid; place-items: center; color: var(--brand); }
.list-item .body { flex: 1; }
.list-item .title { font-weight: 600; font-size: 14px; color: var(--text); }
.list-item .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.list-item .amt { font-weight: 700; color: var(--text); }
.list-item .amt.pos { color: var(--success); }
.list-item .amt.neg { color: var(--danger); }

/* ===== Active trip banner (dashboard) ===== */
.active-trip-wrap { margin: 14px 16px 0; }
.active-trip-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--accent), #EA580C);
  color: #fff; border-radius: 16px; padding: 14px 16px; text-decoration: none;
  box-shadow: 0 10px 24px rgba(249,115,22,.35);
  transition: transform .12s ease;
}
.active-trip-banner:active { transform: scale(.98); }
.atb-pulse { width: 12px; height: 12px; border-radius: 50%; background: #fff; flex-shrink: 0; animation: atbPulse 1.4s infinite; }
@keyframes atbPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.6); }
  70%  { box-shadow: 0 0 0 10px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.atb-body { flex: 1; min-width: 0; }
.atb-title { font-weight: 700; font-size: 14px; }
.atb-sub { font-size: 12px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.atb-cta { font-weight: 700; font-size: 13px; background: rgba(255,255,255,.22); padding: 8px 12px; border-radius: 999px; flex-shrink: 0; }

/* ===== Chat UI ===== */
body.chat-page { height: 100%; overflow: hidden; overscroll-behavior: none; }
.chat-shell {
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; right: 0;
  width: 100%; max-width: 480px; margin: 0 auto;
  height: 100vh; height: -webkit-fill-available; height: 100dvh;
  background: var(--bg);
}
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 10;
}
.chat-header .back { background: transparent; border: 0; color: var(--text); font-size: 18px; cursor: pointer; padding: 6px; }
.chat-header .avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.chat-header .who { flex: 1; }
.chat-header .who .name { font-weight: 600; font-size: 15px; color: var(--text); }
.chat-header .who .sub  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.chat-header .call-btn {
  background: var(--success); color: #fff; border: 0; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; font-size: 16px;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}

.chat-scroll {
  flex: 1; overflow-y: auto; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-day {
  align-self: center; font-size: 11px; color: var(--text-muted);
  background: var(--bg-elev); padding: 4px 10px; border-radius: 999px;
  margin: 8px 0; border: 1px solid var(--border);
}
.msg { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.4; word-wrap: break-word; position: relative; }
.msg .time { display: block; font-size: 10px; opacity: .7; margin-top: 4px; text-align: right; }
.msg.in  { align-self: flex-start; background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end;   background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 4px 10px rgba(91,33,182,.25); }
.msg.out .time { color: rgba(255,255,255,.85); }

.chat-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-elev); border-top: 1px solid var(--border);
}
.chat-composer textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 44px;
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 22px; padding: 12px 16px; font-family: var(--font); font-size: 14px;
  outline: none;
}
.chat-composer textarea:focus { border-color: var(--brand); }
.chat-composer .send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 16px;
  box-shadow: 0 4px 12px rgba(91,33,182,.35);
  display: grid; place-items: center; flex-shrink: 0;
}
.chat-composer .send-btn:disabled { opacity: .5; cursor: not-allowed; }

.chat-empty { text-align: center; color: var(--text-dim); padding: 40px 20px; margin: auto; }
.chat-empty i { font-size: 40px; margin-bottom: 10px; color: var(--brand); opacity: .5; display: block; }

/* Status pills (support / reports) */
.pill { display:inline-block; padding:4px 10px; border-radius:999px; font-size:11px; font-weight:700;
  text-transform:capitalize; letter-spacing:.2px; }
.pill.ok   { background: color-mix(in oklab, var(--success) 16%, transparent); color: var(--success); }
.pill.warn { background: color-mix(in oklab, var(--accent) 16%, transparent);  color: var(--accent); }
.pill.err  { background: color-mix(in oklab, var(--danger) 16%, transparent);  color: var(--danger); }
.pill.mut  { background: var(--bg-elev); color: var(--text-dim); }

/* ---- Dispatch offer countdown (rider dashboard) ---- */
.offer-timer { margin-top: 10px; }
.offer-timer-bar {
  height: 6px; border-radius: 99px; background: var(--line, #e5e7eb); overflow: hidden;
}
.offer-timer-bar span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--brand, #5B21B6), var(--accent, #F97316));
  transition: width 1s linear;
}
.offer-timer small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.offer-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-top: 12px; }
.offer-actions .accept-btn { margin-top: 0; }
.decline-btn { background: transparent; border: 1px solid var(--line, #e5e7eb); color: var(--muted); }
