/* PledgeCross — Global Stylesheet */

/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand:        #0b9fd8;
  --brand-dark:   #0880b0;
  --danger:       #e85530;
  --success:      #1D9E75;
  --warn:         #e89820;
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --border:       #e2e4e8;
  --text:         #1a1d23;
  --muted:        #6b7280;
  --sidebar-w:    300px;
  --sidebar-wide: 340px;
  --nav-h:        52px;
  --radius:       8px;
  --radius-lg:    12px;
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Topnav ─────────────────────────────────────────────────────────────── */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
}
.nav-logo { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.nav-logo span { color: var(--brand); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--muted); }

/* ── GPS indicator (driver) ─────────────────────────────────────────────── */
.gps-indicator { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.gps-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.gps-active .gps-dot { background: var(--success); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Auth ───────────────────────────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.logo-mark { font-size: 24px; font-weight: 800; color: var(--text); }
.logo-mark span { color: var(--brand); }
.logo-text { font-size: 20px; font-weight: 700; }
.auth-tagline { font-size: 13px; color: var(--muted); margin-bottom: 1.5rem; }
.tab-row { display: flex; gap: 4px; margin-bottom: 1.25rem; background: var(--bg); border-radius: var(--radius); padding: 3px; }
.tab { flex: 1; padding: 6px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 0.75rem; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--surface);
  color: var(--text); transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
}
.field textarea { resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%; padding: 9px 16px; background: var(--brand); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-success {
  width: 100%; padding: 9px 16px; background: var(--success); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.btn-outline {
  padding: 6px 14px; background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.btn-outline:hover { background: var(--bg); }
.btn-outline.sm { padding: 4px 10px; font-size: 12px; }
.btn-xs {
  padding: 2px 8px; font-size: 11px; border: 1px solid var(--border);
  background: var(--bg); border-radius: 4px; cursor: pointer;
}
.btn-xs.active, .btn-xs:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.page-wrap {
  display: flex; height: calc(100vh - var(--nav-h)); margin-top: var(--nav-h); overflow: hidden;
}
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 1rem;
}
.sidebar.wide { width: var(--sidebar-wide); }
.sidebar-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 0.5rem; }
.main-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
#map { flex: 1; z-index: 1; }

/* ── Dispatcher layout ──────────────────────────────────────────────────── */
.dispatcher-wrap .main-panel.split { flex-direction: column; }
.dispatcher-wrap #map { flex: 1; min-height: 300px; }
.delivery-console { height: 260px; overflow-y: auto; background: var(--surface); border-top: 1px solid var(--border); }
.console-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 1rem; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 500; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.console-actions { display: flex; gap: 8px; }

/* ── Driver layout ──────────────────────────────────────────────────────── */
.driver-wrap .main-panel { position: relative; }
.active-job {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 1rem; max-height: 55vh; overflow-y: auto;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.job-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.job-title { font-size: 16px; font-weight: 600; }
.job-addr, .job-items { font-size: 13px; margin-top: 2px; }
.job-btns { display: flex; gap: 8px; margin-bottom: 0.75rem; }
.job-btns .btn-primary, .job-btns .btn-success { width: auto; flex: 1; }

/* ── Item cards ─────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 6px; }
.item-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; cursor: pointer;
  transition: border-color 0.15s;
}
.item-card:hover { border-color: var(--brand); }
.item-card.active { border-color: var(--brand); background: #edf7fd; }
.item-card-title { font-size: 13px; font-weight: 500; }
.item-card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-card-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.status-btns { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

/* ── Detail panel (donor) ───────────────────────────────────────────────── */
.detail-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: 360px; z-index: 10;
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 1rem;
  box-shadow: -4px 0 16px rgba(0,0,0,.06);
}
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.detail-header h3 { font-size: 16px; font-weight: 600; }

/* ── Stats ──────────────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 8px; margin-bottom: 1rem; }
.stat { flex: 1; background: var(--bg); border-radius: var(--radius); padding: 10px; text-align: center; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--brand); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Pledge form ────────────────────────────────────────────────────────── */
.pledge-form { background: var(--bg); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.pledge-form h4 { margin-bottom: 4px; }
.amount-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.currency { font-size: 18px; color: var(--muted); }
.amount-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 16px; }
.amount-row .btn-primary { width: auto; padding: 9px 20px; }

/* ── Impact report ──────────────────────────────────────────────────────── */
.impact-report { background: #edfdf5; border: 1px solid #9FE1CB; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.impact-report h4 { color: var(--success); margin-bottom: 4px; }
.unlock-alert { font-size: 13px; color: var(--success); font-weight: 500; }

/* ── Delivery feed ──────────────────────────────────────────────────────── */
.delivery-feed { display: flex; flex-direction: column; }
.delivery-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 1rem; border-bottom: 1px solid var(--border);
}
.delivery-row:last-child { border-bottom: none; }
.delivery-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.delivery-info { flex: 1; min-width: 0; }
.delivery-recipient { font-size: 13px; font-weight: 500; }
.delivery-addr { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delivery-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.proof-link { font-size: 11px; color: var(--brand); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
.badge-pending    { background: #faeeda; color: #854F0B; }
.badge-active     { background: #e6f1fb; color: #0C447C; }
.badge-relief     { background: #eaf3de; color: #27500A; }
.badge-closed     { background: #f1efe8; color: #5F5E5A; }
.badge-queued     { background: #f1efe8; color: #5F5E5A; }
.badge-assigned   { background: #eeedfe; color: #3C3489; }
.badge-in_transit { background: #faeeda; color: #633806; }
.badge-delivered  { background: #eaf3de; color: #27500A; }
.badge-failed     { background: #fcebeb; color: #791F1F; }
.badge-confirmed  { background: #eaf3de; color: #27500A; }
.badge-paid       { background: #e6f1fb; color: #0C447C; }
.badge-cancelled  { background: #f1efe8; color: #5F5E5A; }
.badge-donor      { background: #e6f1fb; color: #0C447C; }
.badge-driver     { background: #eeedfe; color: #3C3489; }
.badge-dispatcher { background: #faeeda; color: #633806; }

.status-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; }
.status-badge.badge-active     { background: #e6f1fb; color: #0C447C; }
.status-badge.badge-relief     { background: #eaf3de; color: #27500A; }
.status-badge.badge-pending    { background: #faeeda; color: #854F0B; }
.status-badge.badge-closed     { background: #f1efe8; color: #5F5E5A; }
.status-badge.badge-in_transit { background: #faeeda; color: #633806; }
.status-badge.badge-delivered  { background: #eaf3de; color: #27500A; }

/* ── Panel sections (dispatcher sidebar) ────────────────────────────────── */
.panel-section { margin-bottom: 1rem; }
.section-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); padding: 6px 0; cursor: pointer; user-select: none;
}
details.panel-section > summary { list-style: none; }
details.panel-section > summary::before { content: '▸ '; }
details.panel-section[open] > summary::before { content: '▾ '; }
.inner-form { margin-top: 8px; }
.driver-opt { display: block; width: 100%; margin-bottom: 6px; text-align: left; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 1.5rem; width: 100%; max-width: 400px; max-height: 80vh; overflow-y: auto;
}
.modal-box h3 { margin-bottom: 6px; }
.modal-btns { margin-top: 1rem; display: flex; justify-content: flex-end; gap: 8px; }
.driver-options { display: flex; flex-direction: column; gap: 6px; margin-top: 1rem; }

/* ── Confirm form (driver) ──────────────────────────────────────────────── */
.confirm-form { background: var(--bg); border-radius: var(--radius); padding: 1rem; margin-top: 0.75rem; }
.confirm-form h4 { margin-bottom: 0.75rem; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; z-index: 1000; animation: fadeup 0.2s ease;
}
@keyframes fadeup { from { opacity:0; transform: translateX(-50%) translateY(10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ── Messages ───────────────────────────────────────────────────────────── */
.msg { font-size: 13px; color: var(--danger); margin-top: 6px; }
.msg.success { color: var(--success); }
.error-msg { font-size: 13px; color: var(--danger); margin: 6px 0; }
.unlock-msg { margin-top: 8px; }

/* ── Driver icon on map ─────────────────────────────────────────────────── */
.driver-icon { font-size: 22px; line-height: 1; }

/* ── Delivery status colors ─────────────────────────────────────────────── */
.status-queued     { color: var(--muted); }
.status-assigned   { color: #534AB7; }
.status-in_transit { color: var(--warn); }
.status-delivered  { color: var(--success); }
.status-failed     { color: var(--danger); }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
