/* ============================================================
   SWIFTSHIP — Tracking Page Styles
   ============================================================ */

.track-hero {
  background: var(--navy);
  padding: 140px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.track-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(27,79,216,0.3) 0%, transparent 70%);
}

.track-hero h1 { color: white; font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 12px; }
.track-hero p { color: rgba(255,255,255,0.6); font-size: 1rem; margin-bottom: 40px; }

.track-search-bar {
  display: flex;
  max-width: 600px;
  margin: 0 auto;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.track-search-bar input {
  flex: 1;
  padding: 16px 24px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}
.track-search-bar input::placeholder { color: rgba(255,255,255,0.4); }
.track-search-bar input:focus { border-color: var(--amber); background: rgba(255,255,255,0.12); }

/* ─── Track Result ───────────────────────────────────────── */
#track-result {
  padding: 60px 0 100px;
  display: none;
}

#track-result.visible { display: block; }

.track-result-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 28px;
  margin-bottom: 28px;
}

/* Status Overview Card */
.track-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 32px;
}

[data-theme="dark"] .track-card {
  background: var(--navy-mid);
  border-color: rgba(255,255,255,0.08);
}

.track-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}
[data-theme="dark"] .track-card-header { border-bottom-color: rgba(255,255,255,0.08); }

.track-id-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-400);
  margin-bottom: 6px;
}

.track-id-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
}
[data-theme="dark"] .track-id-value { color: white; }

/* Progress Steps */
.track-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.track-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  padding-bottom: 28px;
}

.track-step:last-child { padding-bottom: 0; }
.track-step:last-child .step-line { display: none; }

.step-icon-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.step-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
  border: 2px solid;
  transition: all 0.4s ease;
}

/* The connector line between steps */
.step-line {
  width: 2px;
  flex: 1;
  min-height: 28px;
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;         /* clip the animated fill */
  background: var(--gray-200);
}

/* Animated fill inside the step-line — used for in-transit progress */
.step-line-fill {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-light) 100%);
  border-radius: 2px;
  transition: height 1.4s cubic-bezier(0.34, 1.1, 0.64, 1);
}

/* Reversed fill for failed/returned — fills from bottom */
.step-line-fill.reversed {
  top: auto;
  bottom: 0;
  background: linear-gradient(0deg, var(--danger) 0%, rgba(239,68,68,0.5) 100%);
}

/* ── Step state styles ── */

.step-done .step-icon {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.step-done .step-line { background: var(--success); }
.step-done .step-line .step-line-fill { height: 100%; background: var(--success); }

/* Active — package is HERE right now */
.step-active .step-icon {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--navy);
  box-shadow: 0 0 0 6px rgba(245,158,11,0.15);
  animation: pulse 2s ease infinite;
}
/* Line below active step: half-filled to midpoint, animated */
.step-active .step-line { background: var(--gray-200); }

/* In-transit — package has LEFT this checkpoint but NOT arrived at next */
.step-in-transit .step-icon {
  background: rgba(245,158,11,0.12);
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 0 4px rgba(245,158,11,0.08);
}
/* Line below: animated fill going partway toward next checkpoint */
.step-in-transit .step-line { background: var(--gray-200); }

.step-pending .step-icon {
  background: transparent;
  border-color: var(--gray-200);
  color: var(--gray-400);
}
.step-pending .step-line { background: var(--gray-200); }

/* Failed / returned variant */
.step-failed .step-icon {
  background: rgba(239,68,68,0.1);
  border-color: var(--danger);
  color: var(--danger);
}
.step-failed .step-line { background: var(--gray-200); }

/* ── Step content text ── */
.step-content { flex: 1; padding-top: 8px; }

.step-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--navy);
  margin-bottom: 4px;
}
[data-theme="dark"] .step-title { color: white; }
.step-pending .step-title { color: var(--gray-400); }
.step-failed  .step-title { color: var(--danger); }

.step-desc { font-size: 0.82rem; color: var(--gray-400); }
.step-time { font-size: 0.78rem; color: var(--gray-400); margin-top: 4px; }

/* Sub-label for "Was at / heading to" copy */
.step-sublabel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  margin-top: 6px;
}
.step-sublabel.transit-tag {
  background: rgba(245,158,11,0.12);
  color: var(--amber-dark);
}
.step-sublabel.here-tag {
  background: rgba(245,158,11,0.18);
  color: var(--amber-dark);
}
.step-sublabel.done-tag {
  background: rgba(16,185,129,0.1);
  color: var(--success);
}
.step-sublabel.failed-tag {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

/* ── Progress summary bar (top of timeline card) ── */
.journey-progress-wrap {
  margin-bottom: 28px;
}

.journey-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.journey-progress-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
}

.journey-progress-pct {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--navy);
}
[data-theme="dark"] .journey-progress-pct { color: white; }
.journey-progress-pct.failed-pct { color: var(--danger); }

.journey-progress-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .journey-progress-track { background: rgba(255,255,255,0.08); }

.journey-progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--amber) 100%);
  transition: width 1.6s cubic-bezier(0.34, 1.1, 0.64, 1);
  position: relative;
}

/* Pulse glow on the leading edge */
.journey-progress-fill::after {
  content: '';
  position: absolute;
  right: -1px; top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(245,158,11,0.25);
  animation: pulse 1.8s ease infinite;
}

.journey-progress-fill.failed-fill {
  background: linear-gradient(90deg, var(--danger) 0%, rgba(239,68,68,0.5) 100%);
  transition: width 1.6s cubic-bezier(0.34, 1.1, 0.64, 1) reverse;
}
.journey-progress-fill.failed-fill::after {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239,68,68,0.25);
  animation: none;
}

.journey-status-text {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
}

.journey-status-text i { color: var(--amber); }
.journey-status-text.failed-text { color: var(--danger); }
.journey-status-text.failed-text i { color: var(--danger); }

/* Shipment Info Card */
.shipment-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.info-item {}
.info-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: 6px;
}
.info-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--navy);
}
[data-theme="dark"] .info-value { color: white; }

/* Transit History */
.transit-history {
  margin-top: 28px;
}

.transit-history h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: 20px;
}

.transit-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}
[data-theme="dark"] .transit-item { border-bottom-color: rgba(255,255,255,0.06); }
.transit-item:last-child { border-bottom: none; }

.transit-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  margin-top: 5px;
  flex-shrink: 0;
}
.transit-item.latest .transit-dot { background: var(--amber); }

.transit-loc {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  margin-bottom: 4px;
}
[data-theme="dark"] .transit-loc { color: white; }
.transit-status { font-size: 0.8rem; color: var(--gray-400); }
.transit-time { font-size: 0.78rem; color: var(--gray-400); margin-top: 4px; }

/* Map Visualization */
.track-map {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 28px;
}
[data-theme="dark"] .track-map {
  background: var(--navy-mid);
  border-color: rgba(255,255,255,0.08);
}

.track-map h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 24px;
}
[data-theme="dark"] .track-map h4 { color: white; }

.route-visual {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 16px 0;
}

.route-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 90px;
  text-align: center;
}

.route-dot {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--gray-100);
  border: 2px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--gray-400);
  position: relative;
  z-index: 1;
}
.route-dot.done { background: rgba(16,185,129,0.1); border-color: var(--success); color: var(--success); }
.route-dot.active { background: rgba(245,158,11,0.15); border-color: var(--amber); color: var(--amber); }

.route-label { font-size: 0.72rem; font-weight: 600; color: var(--gray-600); line-height: 1.3; }

.route-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  min-width: 30px;
  position: relative;
}
.route-connector.done { background: var(--success); }
.route-connector::after {
  content: '';
  position: absolute;
  right: -5px; top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border: 5px solid transparent;
  border-left-color: var(--gray-200);
}
.route-connector.done::after { border-left-color: var(--success); }

/* Actions Bar */
.track-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Empty State */
.track-empty {
  text-align: center;
  padding: 80px 20px;
}
.track-empty i { font-size: 4rem; color: var(--gray-200); margin-bottom: 20px; }
.track-empty h3 { font-size: 1.4rem; color: var(--navy); margin-bottom: 12px; }
.track-empty p { color: var(--gray-600); font-size: 0.9rem; }

/* QR Overlay */
.qr-modal .modal { max-width: 320px; text-align: center; }
.qr-code-canvas { margin: 20px auto; border-radius: var(--radius-md); }

@media (max-width: 768px) {
  .track-result-grid { grid-template-columns: 1fr; }
  .shipment-info-grid { grid-template-columns: 1fr; }
  .track-hero { padding: 120px 0 60px; }
  .track-search-bar { flex-direction: column; }
  .track-search-bar input { border-radius: var(--radius-md); }
}
