@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --brand: #FE5426;
  --brand-dark: #d8431a;
  --navy: #1a2333;
  --ink: #232733;
  --muted: #767c8c;
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e7e9f0;
  --success: #1c9a5b;
  --warn: #d68a00;
  --danger: #d9412f;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 16px 0;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.topbar nav a { color: rgba(255,255,255,0.75); margin-left: 20px; font-size: 14px; font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; padding: 11px 20px;
  font-family: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

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

.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.password-toggle-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer; color: var(--muted); border-radius: 6px;
}
.password-toggle-btn:hover { color: var(--ink); background: #f2f3f7; }
.password-toggle-btn svg { width: 18px; height: 18px; display: block; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfd; }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.badge-pending, .badge-picked_up { background: #eef0f6; color: var(--muted); }
.badge-pending::before, .badge-picked_up::before { background: var(--muted); }
.badge-in_transit { background: #fff2ea; color: var(--brand-dark); }
.badge-in_transit::before { background: var(--brand); }
.badge-out_for_delivery { background: #fff7e0; color: var(--warn); }
.badge-out_for_delivery::before { background: var(--warn); }
.badge-delivered { background: #e7f8ee; color: var(--success); }
.badge-delivered::before { background: var(--success); }
.badge-failed, .badge-rto, .badge-cancelled { background: #fdecea; color: var(--danger); }
.badge-failed::before, .badge-rto::before, .badge-cancelled::before { background: var(--danger); }

/* ---------- Courier badges (logo or generated initials) ---------- */
.courier-badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 26px; max-width: 120px; border-radius: 6px;
  overflow: hidden; vertical-align: middle; flex-shrink: 0;
  background: #fff; border: 1px solid var(--border); padding: 3px 7px;
}
.courier-badge img { max-height: 100%; max-width: 100%; object-fit: contain; display: block; }
.courier-badge-initials {
  display: none; width: 22px; height: 22px; border-radius: 50%;
  align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
/* Applied by the img's onerror handler when no real logo file is found */
.courier-badge.no-logo {
  background: var(--badge-color); border-color: transparent; padding: 0;
  width: 26px;
}
.courier-badge.no-logo .courier-badge-initials { display: flex; }
.courier-line { display: flex; align-items: center; gap: 8px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { width: 360px; background: #fff; border-radius: var(--radius); padding: 32px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }

/* ---------- Public tracking page ---------- */
.track-hero {
  background: linear-gradient(135deg, var(--navy) 0%, #24304a 100%);
  color: #fff; padding: 56px 0 90px;
}
.track-hero h1 { font-size: 28px; margin: 0 0 8px; }
.track-hero p { color: rgba(255,255,255,0.7); margin: 0; }

.search-card { margin-top: -56px; }
.search-row { display: flex; gap: 12px; flex-wrap: wrap; }
.search-row .field { flex: 1; min-width: 200px; margin-bottom: 0; }

.timeline { position: relative; margin-top: 8px; padding-left: 4px; }
.timeline-item { display: flex; gap: 16px; padding-bottom: 26px; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: 9px; top: 22px; bottom: -4px; width: 2px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; z-index: 1; }
.timeline-item.done .timeline-dot { background: var(--success); }
.timeline-item.current .timeline-dot { background: var(--brand); box-shadow: 0 0 0 4px #fff2ea; }
.timeline-dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.timeline-body strong { display: block; font-size: 14px; }
.timeline-body span.loc { color: var(--muted); font-size: 13px; }
.timeline-body span.time { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.error-box { background: #fdecea; color: var(--danger); border-radius: 10px; padding: 14px 16px; font-size: 14px; }

/* ---------- Tracking result: two-card responsive layout ---------- */
/* Mobile (default): stacked, details card on top, timeline below.
   Desktop (min-width 860px): side by side, timeline on the left,
   details card on the right — achieved by reversing flex direction
   while keeping DOM order [details, timeline] for the mobile stack. */
.track-layout { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 860px) {
  .track-layout { flex-direction: row-reverse; align-items: flex-start; }
  .track-detail-card { flex: 0 0 320px; position: sticky; top: 20px; }
  .track-timeline-card { flex: 1; min-width: 0; }
}

.track-detail-card, .track-timeline-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.track-detail-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.track-detail-header .icon { color: var(--muted); display: flex; flex-shrink: 0; }
.track-detail-header h3 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }

.track-detail-body { padding: 28px 20px; text-align: center; }
.track-logo-large { display: flex; align-items: center; justify-content: center; height: 60px; margin: 0 auto 16px; }
.track-logo-large img { height: 60px; width: auto; max-width: 220px; object-fit: contain; }
.track-logo-large-fallback {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
}
.track-courier-name { font-size: 18px; font-weight: 600; margin-bottom: 18px; }
.track-meta-row { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.track-meta-row strong { color: var(--ink); font-weight: 600; }

.track-timeline-card { padding: 24px 20px; }
.track-tl-item { display: flex; gap: 16px; padding-bottom: 30px; position: relative; }
.track-tl-item:last-child { padding-bottom: 0; }
.track-tl-item::before {
  content: ''; position: absolute; left: 19px; top: 42px; bottom: -6px; width: 0;
  border-left: 2px dashed var(--border);
}
.track-tl-item:last-child::before { display: none; }
.track-tl-icon {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; z-index: 1;
}
.track-tl-icon svg { width: 18px; height: 18px; }
.track-tl-body { padding-top: 6px; }
.track-tl-body strong { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.track-tl-body .loc { display: block; font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.track-tl-body .time { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

footer.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }
