/* ================================================= */
/* Deboura ERP Mobile - Shipments Stylesheet         */
/* Matches docs/shipping.html 100%                   */
/* ================================================= */

:root {
  /* ألوان الحالات */
  --st-preparing: #d97706;    /* 1. قيد التجهيز */
  --st-preparing-bg: #fffbeb;
  --st-preparing-bdr: #fde68a;

  --st-ready: #6366f1;        /* 2. جاهز للاستلام */
  --st-ready-bg: #eef2ff;
  --st-ready-bdr: #c7d2fe;

  --st-outfordel: #0284c7;    /* 3. في الطريق / خرج للتوصيل */
  --st-outfordel-bg: #f0f9ff;
  --st-outfordel-bdr: #bae6fd;

  --st-delivered: #0d9488;    /* 4. تم التوصيل */
  --st-delivered-bg: #f0fdfa;
  --st-delivered-bdr: #99f6e4;

  --st-settled: #059669;      /* 5. تمت التسوية */
  --st-settled-bg: #ecfdf5;
  --st-settled-bdr: #a7f3d0;

  --st-failed: #dc2626;       /* 6. فشل التوصيل */
  --st-failed-bg: #fef2f2;
  --st-failed-bdr: #fecdd3;

  --st-returned: #7c3aed;     /* 7. مرتجع */
  --st-returned-bg: #f5f3ff;
  --st-returned-bdr: #ddd6fe;

  --st-cancelled: #64748b;    /* 8. ملغاة */
  --st-cancelled-bg: #f1f5f9;
  --st-cancelled-bdr: #cbd5e1;
}

/* ================================================= */
/* 1. رأس الصفحة والبحث وشبكة أزرار الحالات (صفين)    */
/* ================================================= */
.shipping-app-header {
  background: #ffffff;
  padding: 10px 14px 10px 14px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  position: sticky;
  top: 80px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ea580c;
  font-size: 16px;
  font-weight: 900;
}

.stats-counter-tag {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted, #64748b);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  flex: 1;
  position: relative;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background-color: #f8fafc;
  outline: none;
}

.search-box input:focus {
  border-color: #ea580c;
  background-color: #ffffff;
}

.search-box .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
}

.btn-filter-icon {
  width: 38px;
  height: 38px;
  background: #f8fafc;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  cursor: pointer;
  flex-shrink: 0;
}

/* مصفوفة الحالات الثمانية (صفين × 4 أزرار) */
.filter-matrix-card {
  background: #edf2f7;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.filter-matrix-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
}

.matrix-btn {
  height: 34px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0 2px;
  white-space: nowrap;
  transition: all 0.18s ease;
  user-select: none;
  box-sizing: border-box;
}

/* الزر النشط بنمط الكارت الأبيض البارز والمرفوع */
.matrix-btn.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.09), 0 1px 2px rgba(0, 0, 0, 0.04);
  transform: translateY(-0.5px);
}

/* ================================================= */
/* 2. كروت الشحنات (2-Line Tiles وبدون Shadow)       */
/* ================================================= */
.shipments-list-body {
  padding: 10px 12px 100px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-shipment-tile {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-right: 5px solid var(--tile-status-color);
  box-shadow: none !important;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

.compact-shipment-tile:active {
  background-color: #f1f5f9;
  transform: scale(0.99);
}

.st-preparing-tile { --tile-status-color: var(--st-preparing); }
.st-ready-tile     { --tile-status-color: var(--st-ready); }
.st-outfordel-tile { --tile-status-color: var(--st-outfordel); }
.st-delivered-tile { --tile-status-color: var(--st-delivered); }
.st-settled-tile   { --tile-status-color: var(--st-settled); }
.st-failed-tile    { --tile-status-color: var(--st-failed); }
.st-returned-tile  { --tile-status-color: var(--st-returned); }
.st-cancelled-tile { --tile-status-color: var(--st-cancelled); }

.tile-line-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.client-area-group {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.client-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.area-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.shipment-status-pill {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.shipment-status-pill.preparing { background: var(--st-preparing-bg); color: var(--st-preparing); border: 1px solid var(--st-preparing-bdr); }
.shipment-status-pill.ready     { background: var(--st-ready-bg); color: var(--st-ready); border: 1px solid var(--st-ready-bdr); }
.shipment-status-pill.outfordel { background: var(--st-outfordel-bg); color: var(--st-outfordel); border: 1px solid var(--st-outfordel-bdr); }
.shipment-status-pill.delivered { background: var(--st-delivered-bg); color: var(--st-delivered); border: 1px solid var(--st-delivered-bdr); }
.shipment-status-pill.settled   { background: var(--st-settled-bg); color: var(--st-settled); border: 1px solid var(--st-settled-bdr); }
.shipment-status-pill.failed    { background: var(--st-failed-bg); color: var(--st-failed); border: 1px solid var(--st-failed-bdr); }
.shipment-status-pill.returned  { background: var(--st-returned-bg); color: var(--st-returned); border: 1px solid var(--st-returned-bdr); }
.shipment-status-pill.cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled); border: 1px solid var(--st-cancelled-bdr); }

.tile-line-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.meta-track-info {
  display: flex;
  align-items: center;
  gap: 5px;
}

.track-num {
  font-family: monospace;
  font-size: 12px;
  font-weight: 800;
  color: #1e293b;
}

.cod-amount-tag {
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main, #0f172a);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cod-amount-tag small {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  font-weight: 600;
}

/* ================================================= */
/* 3. نافذة سجل حركات الشحنة المنبثقة (Timeline Modal)*/
/* ================================================= */
.shipping-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-end;
  backdrop-filter: blur(2px);
}

.shipping-modal-backdrop.open {
  display: flex;
}

.movement-sheet {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: sheetSlideUp 0.25s ease-out;
  overflow: hidden;
  position: relative;
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sheet-title-group h2 {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-main, #0f172a);
}

.sheet-title-group span {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  font-weight: 600;
}

.btn-close-sheet {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  font-size: 16px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 95px;
}

.shipment-summary-box {
  background: #f8fafc;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11.5px;
}

.sum-item span {
  color: var(--text-muted, #64748b);
  display: block;
  font-size: 10.5px;
}

.sum-item strong {
  color: var(--text-main, #0f172a);
  font-size: 12px;
}

/* المخطط الزمني التدفقي */
.timeline-container {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-right: 20px;
}

.timeline-container::before {
  content: "";
  position: absolute;
  right: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #e2e8f0;
}

.timeline-step {
  position: relative;
  padding-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  right: -20px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid var(--node-color);
  z-index: 2;
}

.step-time-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.step-badge-flow {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.state-node-tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  background: var(--tag-bg);
  color: var(--tag-color);
  border: 1px solid var(--tag-bdr);
}

.step-desc {
  font-size: 12px;
  color: #334155;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
  line-height: 1.4;
  border-right: 3px solid var(--node-color);
}

/* ================================================= */
/* 4. شريط الأزرار الثلاثة الثابت أسفل سجل الحركة     */
/* ================================================= */
.sheet-sticky-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border-color, #e2e8f0);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.95fr;
  gap: 6px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  z-index: 50;
}

.btn-sheet-action {
  height: 42px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
  white-space: nowrap;
}

.btn-sheet-action:active {
  transform: scale(0.96);
}

.btn-sheet-action.print {
  background: #0284c7;
  color: #ffffff;
}

.btn-sheet-action.change {
  background: #384f61;
  color: #ffffff;
}

.btn-sheet-action.hold {
  background: #dc2626;
  color: #ffffff;
}

/* ================================================= */
/* 5. نافذة بوليصة الشحن                             */
/* ================================================= */
.waybill-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 14px;
}

.waybill-modal-backdrop.open { display: flex; }

.waybill-card-box {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border-radius: 8px;
  padding: 18px 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 90vh;
  overflow-y: auto;
}

.waybill-header-title {
  font-size: 18px;
  font-weight: 900;
  border-bottom: 2px solid #000;
  padding-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.barcodes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: center;
  margin: 4px 0;
}

.barcode-item span {
  font-size: 11px;
  color: #475569;
}

.barcode-lines {
  height: 44px;
  background: repeating-linear-gradient(90deg, #000 0px, #000 2px, transparent 2px, transparent 4px, #000 4px, #000 7px, transparent 7px, transparent 9px);
  margin: 4px 0;
}

.barcode-code {
  font-family: monospace;
  font-weight: 800;
  font-size: 13px;
}

.waybill-carrier-banner {
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.waybill-recipient-box {
  border: 2px solid #000;
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.waybill-recipient-box h3 {
  font-size: 15px;
  font-weight: 900;
}

.waybill-cod-black-box {
  background: #000000;
  color: #ffffff;
  padding: 10px;
  text-align: center;
  border-radius: 4px;
}

.waybill-cod-black-box span {
  font-size: 12px;
  display: block;
}

.waybill-cod-black-box strong {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
}

.waybill-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-print-direct {
  flex: 1;
  height: 40px;
  background: #ea580c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.btn-close-waybill {
  height: 40px;
  padding: 0 16px;
  background: #f1f5f9;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

/* ================================================= */
/* 6. نافذة تغيير الحالة                             */
/* ================================================= */
.status-change-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.status-change-backdrop.open { display: flex; }

.status-picker-sheet {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 80vh;
  overflow-y: auto;
  animation: sheetSlideUp 0.2s ease-out;
}

.status-opt-btn {
  width: 100%;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  transition: all 0.15s;
}

.status-opt-btn:active {
  background: #e2e8f0;
}
