/* =========================================================
   ZIJAI DELIVERY PORTAL
   Mobile-first screen for delivery riders.
   ========================================================= */

:root {
  --d-hot: #8b0000;
  --d-dark: #12161c;
  --d-panel: #1c222b;
  --d-line: #2b3340;
  --d-muted: #8b98a8;
  --d-ok: #198754;
  --d-warn: #f0a500;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  /* Respect notched / safe areas on modern phones */
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);

  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;

  background: #0d1117;

  color: #e7edf5;

  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;

  -webkit-font-smoothing: antialiased;

  /* Prevent iOS rubber-band overscroll while keeping normal scroll */
  overscroll-behavior-y: contain;

  /* Tap-highlight: no flash on iOS / Android touch */
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;

  min-height: 100vh;

  max-width: 480px;

  margin: 0 auto;

  background: #0d1117;
}


/* ---------- Header ---------- */

.d-header {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 14px 16px;

  background: var(--d-dark);

  border-bottom: 1px solid var(--d-line);
}

.d-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.d-logo {
  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 11px;

  background: var(--d-hot);

  font-size: 20px;
}

.d-brand-text {
  line-height: 1.15;
}

.d-brand-name {
  font-weight: 800;
  font-size: 15px;

  letter-spacing: 0.6px;
}

.d-brand-role {
  font-size: 11px;

  color: var(--d-muted);
}

.d-online {
  margin-left: auto;

  display: flex;
  align-items: center;
  gap: 6px;

  font-size: 11px;
  font-weight: 700;

  color: #4ade80;
}

.d-online .dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: #4ade80;

  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);

  animation: d-pulse 1.8s infinite;
}

@keyframes d-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.35);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(74, 222, 128, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
  }
}


/* ---------- Alert banner ---------- */

.d-alert-banner {
  display: none;

  align-items: center;
  gap: 12px;

  padding: 13px 16px;

  background: linear-gradient(
    90deg,
    #b3001b 0%,
    #7a0012 100%
  );

  color: #fff;

  animation: d-shake 0.5s ease;
}

.d-alert-banner.show {
  display: flex;
}

@keyframes d-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.d-alert-icon {
  font-size: 24px;

  animation: d-ring 0.7s ease-in-out infinite;
}

@keyframes d-ring {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-14deg);
  }
  75% {
    transform: rotate(14deg);
  }
}

.d-alert-text {
  flex: 1;
  min-width: 0;
}

.d-alert-title {
  font-weight: 800;
  font-size: 14px;
}

.d-alert-sub {
  font-size: 12px;

  opacity: 0.9;
}

.d-alert-go {
  flex-shrink: 0;

  padding: 8px 13px;

  border: 0;
  border-radius: 9px;

  background: #fff;
  color: #b3001b;

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}


/* ---------- Stats ---------- */

.d-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);

  gap: 9px;

  padding: 14px 16px;
}

.d-stat {
  padding: 13px 8px;

  text-align: center;

  background: var(--d-panel);

  border: 1px solid var(--d-line);

  border-radius: 13px;
}

.d-stat-num {
  font-size: 24px;
  font-weight: 800;

  line-height: 1;
}

.d-stat-label {
  margin-top: 6px;

  font-size: 10.5px;

  letter-spacing: 0.4px;

  text-transform: uppercase;

  color: var(--d-muted);
}

.d-stat-num.hot {
  color: #ff6b6b;
}

.d-stat-num.ok {
  color: #4ade80;
}

.d-stat-num.warn {
  color: #ffc94d;
}


/* ---------- Tabs ---------- */

.d-tabs {
  display: flex;

  gap: 6px;

  margin: 4px 16px 14px;

  padding: 5px;

  background: var(--d-panel);

  border-radius: 12px;
}

.d-tab {
  flex: 1;

  padding: 10px 6px;

  border: 0;
  border-radius: 9px;

  background: transparent;

  color: var(--d-muted);

  font-size: 13px;
  font-weight: 700;

  cursor: pointer;

  transition:
    background-color 0.18s ease,
    color 0.18s ease;
}

.d-tab.active {
  background: var(--d-hot);

  color: #fff;
}

.d-tab .count {
  display: inline-block;

  margin-left: 5px;

  padding: 1px 6px;

  border-radius: 10px;

  background: rgba(255, 255, 255, 0.16);

  font-size: 10.5px;
}


/* ---------- Cards ---------- */

.d-main {
  flex: 1;

  padding: 0 16px 30px;
}

.d-card {
  margin-bottom: 14px;

  background: var(--d-panel);

  border: 1px solid var(--d-line);

  border-radius: 16px;

  overflow: hidden;
}

.d-card.pulse {
  animation: d-glow 1.4s ease 3;
}

@keyframes d-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.28);
  }
}

.d-card-head {
  display: flex;
  align-items: center;
  gap: 11px;

  padding: 13px 14px;

  background: #232a35;
}

.d-avatar {
  width: 42px;
  height: 42px;

  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: rgba(139, 0, 0, 0.35);

  color: #ff8f8f;

  font-size: 19px;
}

.d-customer {
  min-width: 0;

  flex: 1;
}

.d-customer-name {
  font-weight: 700;

  font-size: 15px;
}

.d-customer-meta {
  font-size: 12px;

  color: var(--d-muted);
}

.d-order-total {
  text-align: right;

  flex-shrink: 0;
}

.d-order-total strong {
  display: block;

  font-size: 16px;
  font-weight: 800;
}

.d-order-total small {
  font-size: 10.5px;

  color: var(--d-muted);
}

.d-card-body {
  padding: 13px 14px;
}

.d-line {
  display: flex;

  align-items: flex-start;
  gap: 10px;

  padding: 6px 0;

  font-size: 13.5px;
}

.d-line + .d-line {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.d-line-icon {
  flex-shrink: 0;

  width: 20px;

  color: var(--d-muted);
}

.d-line-text {
  min-width: 0;

  flex: 1;

  word-wrap: break-word;
}

.d-line-text a {
  color: #7cc4ff;
  text-decoration: none;
  font-weight: 700;
}

.d-items {
  margin: 0;
  padding-left: 19px;

  font-size: 13px;
}

.d-items li {
  margin-bottom: 3px;
}

.d-eta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 4px 10px;

  border-radius: 20px;

  background: rgba(240, 165, 0, 0.16);

  color: #ffc94d;

  font-size: 11.5px;
  font-weight: 700;
}


/* ---------- Map ---------- */

.d-map {
  height: 190px;

  margin: 4px 0 12px;

  border-radius: 12px;

  overflow: hidden;

  border: 1px solid var(--d-line);

  background: #1b2027;
}

.d-map-fallback {
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  gap: 8px;

  color: var(--d-muted);

  font-size: 12.5px;

  text-align: center;

  padding: 12px;
}


/* ---------- Actions ---------- */

.d-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);

  gap: 8px;

  padding: 12px 14px 14px;
}

.d-actions.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.d-btn {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 7px;

  padding: 12px 8px;

  border: 0;
  border-radius: 11px;

  font-size: 13px;
  font-weight: 700;

  cursor: pointer;

  transition: filter 0.15s ease, transform 0.12s ease;
}

.d-btn:active {
  transform: scale(0.97);
}

.d-btn:disabled {
  opacity: 0.55;

  cursor: not-allowed;
}

.d-btn-primary {
  background: var(--d-ok);

  color: #fff;
}

.d-btn-warn {
  background: var(--d-warn);

  color: #1a1200;
}

.d-btn-dark {
  background: #2f3947;

  color: #e7edf5;
}

.d-btn-block {
  grid-column: 1 / -1;
}

.d-btn-ghost {
  background: transparent;

  border: 1px solid var(--d-line);

  color: #e7edf5;
}


/* ---------- Empty / loading ---------- */

.d-empty {
  padding: 60px 24px;

  text-align: center;

  color: var(--d-muted);
}

.d-empty i {
  display: block;

  font-size: 52px;

  margin-bottom: 14px;

  opacity: 0.45;
}

.d-empty h5 {
  font-weight: 700;
  color: #e7edf5;

  margin-bottom: 6px;
}

.d-spinner {
  padding: 60px 0;

  text-align: center;

  color: var(--d-muted);
}


/* ---------- Profile ---------- */

.d-profile {
  padding: 20px 16px;
}

.d-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 12px;

  padding: 14px 0;

  border-bottom: 1px solid var(--d-line);

  font-size: 14px;
}

.d-profile-row:last-child {
  border-bottom: 0;
}

.d-profile-row .d-muted {
  color: var(--d-muted);
}

.d-perm-pill {
  display: inline-flex;
  align-items: center;

  gap: 6px;

  padding: 5px 11px;

  border-radius: 20px;

  font-size: 12px;
  font-weight: 700;

  background: rgba(25, 135, 84, 0.18);

  color: #4ade80;
}

.d-perm-pill.off {
  background: rgba(190, 35, 35, 0.16);

  color: #ff8f8f;
}

.d-perm-toggle {
  padding: 9px 16px;

  border: 0;
  border-radius: 10px;

  background: var(--d-ok);

  color: #fff;

  font-size: 12.5px;
  font-weight: 700;

  cursor: pointer;
}


/* ---------- Settings note ---------- */

.d-note {
  margin: 16px;

  padding: 13px 15px;

  border: 1px dashed var(--d-line);

  border-radius: 12px;

  background: rgba(255, 255, 255, 0.02);

  font-size: 12.5px;

  line-height: 1.6;

  color: var(--d-muted);
}

.d-note strong {
  color: #e7edf5;
}


/* ---------- Toast ---------- */

.d-toast {
  position: fixed;

  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));

  transform: translateX(-50%);

  z-index: 9999;

  padding: 11px 18px;

  border-radius: 11px;

  background: #232a35;

  color: #fff;

  font-size: 13px;
  font-weight: 600;

  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);

  opacity: 0;

  pointer-events: none;

  transition: opacity 0.22s ease, transform 0.22s ease;

  max-width: calc(100vw - 30px);
}

.d-toast.show {
  opacity: 1;

  transform: translateX(-50%) translateY(-6px);
}


/* ---------- Install button ---------- */

.d-install-btn {
  position: fixed;

  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));

  z-index: 8000;

  display: flex;
  align-items: center;
  gap: 6px;

  padding: 9px 13px;

  border: 0;
  border-radius: 22px;

  background: var(--d-hot);

  color: #fff;

  font-size: 12.5px;
  font-weight: 700;

  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);

  cursor: pointer;

  transition: transform 0.15s ease, opacity 0.15s ease;
}

.d-install-btn:active {
  transform: scale(0.96);
}

.d-install-btn.hidden {
  display: none;
}


/* ---------- Responsive ---------- */

/* Touch targets: ensure ≥44 px hit area everywhere */
@media (pointer: coarse) {

  .d-btn,
  .d-alert-go,
  .d-perm-toggle,
  .d-tab {
    min-height: 44px;
  }

  .d-alert-banner {
    padding-top: 16px;
    padding-bottom: 16px;
  }

}

@media (max-width: 480px) {

  .d-header {
    padding: 10px 12px;
  }

  .d-profile {
    padding: 16px 12px;
  }

  .d-stats {
    padding: 12px;
  }

  .d-main {
    padding: 0 12px 30px;
  }

}

@media (max-width: 380px) {

  .d-actions {
    grid-template-columns: 1fr;
  }

  .d-stats {
    gap: 7px;
  }

  .d-stat-num {
    font-size: 20px;
  }

  .d-tab {
    font-size: 12px;
  }

  .d-card-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .d-order-total {
    width: 100%;
    text-align: left;
  }

}

/* Landscape phones: keep the portal usable sideways */
@media (orientation: landscape) and (max-height: 500px) {

  .app {
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
  }

  .d-header,
  .d-profile,
  .d-stats,
  .d-tabs,
  .d-main,
  .d-note {
    flex: 1 1 auto;
  }

}

/* Larger screens (tablets / desktop preview): widen the
   app shell and allow two-column layout. */
@media (min-width: 768px) {

  .app {
    max-width: 720px;
    border-left: 1px solid var(--d-line);
    border-right: 1px solid var(--d-line);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  }

  .d-map {
    height: 240px;
  }

  .d-actions {
    grid-template-columns: repeat(4, 1fr);
  }

}

/* Print: hide the interactive chrome so an order can be
   printed cleanly from a computer. */
@media print {

  body {
    background: #fff;
    color: #000;
  }

  .d-header,
  .d-profile,
  .d-stats,
  .d-tabs,
  .d-actions,
  .d-alert-banner,
  .d-install-btn,
  .d-note,
  .d-toast {
    display: none !important;
  }

  .app {
    max-width: none;
  }

  .d-card {
    border: 1px solid #ccc;
    background: #fff;
  }

  .d-card-body,
  .d-card-head {
    background: #fff;
    color: #000;
  }

}
