/* =============================================
   Bedjo Cleaner – tracking.css
   Matches existing app UI (light blue header,
   white cards, green status badge)
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue-bg: #dceeff;
  --blue-mid: #a8d4f5;
  --blue-accent: #2a7dd6;
  --green-badge-bg: #d4f5e2;
  --green-badge-text: #1a8c4e;
  --yellow-badge-bg: #fff3cd;
  --yellow-badge-text: #856404;
  --red-badge-bg: #fde8e8;
  --red-badge-text: #b91c1c;
  --gray-bg: #f4f6f9;
  --gray-border: #e5e9ef;
  --text-primary: #1a1f2e;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --white: #ffffff;
  --wa-green: #25d366;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.07);
  --radius-card: 16px;
  --radius-badge: 20px;
}

body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--gray-bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ─────────────────────────────────── */
.app-header {
  background-color: var(--blue-bg);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.header-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  display: block;
}

.header-brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--blue-accent);
  letter-spacing: -0.3px;
  text-align: center;
}

/* ── MAIN LAYOUT ─────────────────────────────── */
.main-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 20px;
}

.tracking-search-card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 16px;
}

.tracking-search-card label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tracking-search-row {
  display: flex;
  gap: 8px;
}

.tracking-search-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--gray-border);
  border-radius: 10px;
  padding: 0 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
}

.tracking-search-row button {
  height: 40px;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  background: var(--blue-accent);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* ── STATE CARDS (loading / error) ───────────── */
.state-card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.state-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.state-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.error-icon {
  background-color: var(--red-badge-bg);
  color: var(--red-badge-text);
}

/* ── SPINNER ─────────────────────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--blue-mid);
  border-top-color: var(--blue-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── HIDDEN ──────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── ORDER HEADER ────────────────────────────── */
.order-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--blue-mid);
  color: var(--blue-accent);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.order-meta {
  flex: 1;
  min-width: 0;
}

.customer-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-id {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status-helper {
  font-size: 13px;
  font-weight: 500;
  color: var(--blue-accent);
  margin-top: 10px;
}

/* ── STATUS BADGE ────────────────────────────── */
.status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--radius-badge);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-completed {
  background-color: var(--green-badge-bg);
  color: var(--green-badge-text);
  border: 1px solid #a7f3c7;
}

.badge-process {
  background-color: var(--yellow-badge-bg);
  color: var(--yellow-badge-text);
  border: 1px solid #fcd34d;
}

.badge-pending {
  background-color: #e0eaff;
  color: #3b5bdb;
  border: 1px solid #bfcfff;
}

.badge-cancelled {
  background-color: var(--red-badge-bg);
  color: var(--red-badge-text);
  border: 1px solid #fca5a5;
}

/* ── DIVIDER ─────────────────────────────────── */
.divider {
  height: 1px;
  background-color: var(--gray-border);
  margin: 16px 0;
}

/* ── INFO ROWS ───────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.info-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* ── SECTION TITLE ───────────────────────────── */
.section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.order-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.order-item-detail {
  padding: 12px;
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  background-color: #fafbfc;
}

.order-item-number {
  margin-bottom: 4px;
  color: var(--blue-accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.order-item-title {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.order-item-fields {
  display: grid;
  gap: 5px;
  margin: 0;
}

.order-item-fields > div {
  display: grid;
  grid-template-columns: minmax(78px, 0.75fr) minmax(0, 1.25fr);
  gap: 10px;
}

.order-item-fields dt,
.order-item-fields dd {
  margin: 0;
  font-size: 12px;
}

.order-item-fields dt {
  color: var(--text-secondary);
}

.order-item-fields dd {
  color: var(--text-primary);
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.order-item-fields .order-item-note {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-border);
}

/* ── ITEM CANCELLED (tetap tampil, hanya ditandai) ───────────── */
.order-item-detail--cancelled {
  opacity: 0.62;
  background-color: #fef2f2;
  border-color: #fca5a5;
}

.order-item-cancelled-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-badge);
  background-color: var(--red-badge-bg);
  color: var(--red-badge-text);
  border: 1px solid #fca5a5;
  vertical-align: middle;
  /* Catatan: opacity kartu induk (.order-item-detail--cancelled) tetap
     memengaruhi elemen ini secara visual (batasan CSS stacking-context);
     badge tetap cukup kontras karena background merah solid + border. */
}

.order-item-fields dd.order-item-value--cancelled {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.order-item-fields .order-item-cancel-info {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-border);
}

.order-item-fields .order-item-cancel-info dd {
  color: #b91c1c;
}

.order-item-empty {
  padding: 14px;
  border: 1px dashed var(--gray-border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}

.payment-summary {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-border);
}

.payment-summary-title {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
}

/* ── PHOTO BLOCK ─────────────────────────────── */
.photo-block {
  margin-top: 12px;
}

.photo-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.photo-wrapper {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--gray-border);
  background-color: var(--gray-bg);
}

.item-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-light);
}

/* ── NOTE BLOCK ──────────────────────────────── */
.note-block {
  margin-top: 14px;
}

.note-text {
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 20px;
}

/* ── TIMELINE ────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 14px;
  position: relative;
}

.timeline-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--gray-border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.timeline-dot.done {
  background-color: var(--blue-accent);
  border-color: var(--blue-accent);
  color: white;
}

/* Step "selesai DAN sedang berlangsung saat ini" (mis. Selesai saat
   status=completed, Barang Sudah Diambil saat status=picked_up) -- tetap
   checkmark biru terisi penuh seperti step lampau, TAPI ditambah ring/glow
   yang sama dengan .timeline-dot.active supaya tidak menyatu tak terbedakan
   dengan step yang sudah benar-benar lewat. */
.timeline-dot.done.current {
  box-shadow: 0 0 0 4px rgba(42, 125, 214, 0.15);
}

.timeline-check {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.timeline-dot.active {
  background-color: var(--white);
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 4px rgba(42, 125, 214, 0.15);
}

.timeline-line {
  width: 2px;
  flex: 1;
  background-color: var(--gray-border);
  min-height: 28px;
  transition: background-color 0.3s ease;
}

.timeline-line.done {
  background-color: var(--blue-accent);
}

.timeline-right {
  padding-bottom: 24px;
  padding-top: 1px;
}

.timeline-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.timeline-label.active,
.timeline-label.done {
  color: var(--text-primary);
}

.timeline-helper {
  font-size: 12px;
  font-weight: 500;
  color: var(--blue-accent);
  margin-top: 2px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ── HELP CARD ───────────────────────────────── */
.help-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.help-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.help-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.wa-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--wa-green);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.wa-btn:hover {
  background-color: #1ebc59;
}

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

/* Production tracking scale restore */
.app-header {
  padding: 20px 24px;
}

.header-inner {
  max-width: 640px;
  gap: 12px;
}

.header-logo {
  width: 96px;
  height: 96px;
}

.header-brand {
  font-size: clamp(24px, 3vw, 30px);
}

.main-content {
  max-width: 620px;
  padding: 26px 20px 48px;
  gap: 18px;
}

.card,
.tracking-search-card {
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(16,24,40,0.08);
}

.card {
  padding: 24px;
}

.tracking-search-card {
  padding: 20px;
}

.tracking-search-card label {
  font-size: 15px;
  margin-bottom: 10px;
}

.tracking-search-row {
  gap: 10px;
}

.tracking-search-row input,
.tracking-search-row button {
  height: 50px;
  border-radius: 12px;
  font-size: 15px;
}

.tracking-search-row input {
  padding: 0 14px;
}

.tracking-search-row button {
  padding: 0 22px;
}

.order-header {
  gap: 16px;
}

.avatar {
  width: 54px;
  height: 54px;
  font-size: 21px;
}

.customer-name {
  font-size: 18px;
}

.order-id {
  font-size: 14px;
}

.status-badge {
  font-size: 12px;
  padding: 6px 14px;
}

.divider {
  margin: 20px 0;
}

.info-row {
  margin-bottom: 11px;
}

.info-label,
.info-value,
.note-text,
.timeline-label {
  font-size: 15px;
}

.section-title {
  font-size: 18px;
}

.order-items-list {
  gap: 12px;
  margin-top: 16px;
}

.order-item-detail {
  padding: 16px;
}

.order-item-number {
  font-size: 13px;
}

.order-item-title {
  margin-bottom: 12px;
  font-size: 17px;
}

.order-item-fields {
  gap: 8px;
}

.order-item-fields > div {
  grid-template-columns: minmax(110px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
}

.order-item-fields dt,
.order-item-fields dd {
  font-size: 14px;
}

.payment-summary {
  margin-top: 18px;
  padding-top: 16px;
}

.payment-summary-title {
  margin-bottom: 12px;
  font-size: 17px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}

.media-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--gray-border);
  border-radius: 12px;
  background: var(--gray-bg);
  display: block;
}

.media-grid .no-photo {
  min-height: 96px;
  padding: 16px;
  border: 1px dashed var(--gray-border);
  border-radius: 12px;
  background: var(--gray-bg);
}

.help-title {
  font-size: 16px;
}

.help-sub {
  font-size: 14px;
}

.wa-btn {
  font-size: 15px;
}

@media (max-width: 640px) {
  .app-header {
    padding: 16px 18px;
  }

  .header-logo {
    width: 68px;
    height: 68px;
  }

  .header-brand {
    font-size: 20px;
  }

  .main-content {
    max-width: none;
    padding: 18px 14px 40px;
    gap: 14px;
  }

  .card {
    padding: 20px;
  }

  .tracking-search-card {
    padding: 18px;
  }

  .tracking-search-row input,
  .tracking-search-row button {
    height: 46px;
    font-size: 14px;
  }

  .avatar {
    width: 48px;
    height: 48px;
  }

  .customer-name {
    font-size: 17px;
  }

  .info-label,
  .info-value,
  .note-text,
  .timeline-label {
    font-size: 14px;
  }

  .section-title,
  .payment-summary-title {
    font-size: 16px;
  }

  .order-item-title {
    font-size: 15px;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
}

@media (max-width: 380px) {
  .tracking-search-row {
    flex-direction: column;
  }

  .tracking-search-row button {
    width: 100%;
  }

  .order-header {
    align-items: flex-start;
  }

  .status-badge {
    max-width: 120px;
    white-space: normal;
    text-align: center;
  }
}
