/* ============================================================
   SCANOUT PAGE — FULL CSS (mobile-first, production-grade)
   Drop-in replacement. No JS changes needed.
   ============================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Reset / Base ── */
#scanoutPage {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  min-height: 100vh;
  padding: 14px 10px 72px;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
#scanoutPage .so-header {
  max-width: 960px;
  margin: 0 auto 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
#scanoutPage .so-header-left { display: flex; align-items: center; gap: 12px; }
#scanoutPage .so-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#scanoutPage .so-icon svg { width:18px; height:18px; stroke:#fff; fill:none; stroke-width:2.5; }
#scanoutPage .so-title { font-size:16px; font-weight:800; color:#0f172a; letter-spacing:-.3px; }
#scanoutPage .so-sub   { font-size:11px; color:#64748b; font-weight:500; margin-top:1px; }
#scanoutPage .so-badge {
  padding: 4px 11px;
  background: #eff6ff; border: 1px solid #dbeafe;
  border-radius: 8px; font-size:12px; font-weight:700; color:#1e40af;
  white-space: nowrap;
}

/* ══════════════════════════════════════
   TABS
══════════════════════════════════════ */
#scanoutPage .so-tabs {
  max-width: 960px; margin: 0 auto 12px;
  display: flex; gap: 5px;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 11px; padding: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
#scanoutPage .so-tab {
  flex: 1; padding: 8px 0; text-align: center;
  font-size: 12.5px; font-weight: 700; color: #64748b;
  border-radius: 7px; cursor: pointer; border: none;
  background: transparent; transition: all .18s ease;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
#scanoutPage .so-tab.active {
  background: #2563eb; color: #fff;
  box-shadow: 0 2px 10px rgba(37,99,235,.28);
}
#scanoutPage .so-tab .tab-count {
  background: rgba(255,255,255,.25); color: inherit;
  border-radius: 5px; padding: 1px 6px; font-size: 10.5px; font-weight: 700;
}
#scanoutPage .so-tab:not(.active) .tab-count {
  background: #f1f5f9; color: #475569;
}

/* ══════════════════════════════════════
   CARD / TABLE WRAPPER
══════════════════════════════════════ */
#scanoutPage .so-card {
  max-width: 960px; margin: 0 auto;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
#scanoutPage .so-empty {
  padding: 56px 20px; text-align: center;
  font-size: 14px; color: #94a3b8; font-weight: 500;
}
#scanoutPage .so-empty svg {
  display:block; margin:0 auto 14px; opacity:.35;
  width:40px; height:40px; stroke:#94a3b8; fill:none; stroke-width:1.5;
}

/* ── Table base ── */
#scanoutPage .tbl-wrap { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
#scanoutPage table { width:100%; border-collapse:collapse; min-width:0; }
#scanoutPage thead tr { background:#f8fafc; border-bottom:1px solid #e2e8f0; }
#scanoutPage thead th {
  padding: 10px 12px; text-align:left;
  font-size:10px; font-weight:700; color:#94a3b8;
  text-transform:uppercase; letter-spacing:.06em; white-space:nowrap;
}
#scanoutPage thead th.center { text-align:center; }
#scanoutPage tbody tr {
  border-bottom: 1px solid #f1f5f9; transition: background .1s;
}
#scanoutPage tbody tr:last-child { border-bottom:none; }
#scanoutPage tbody tr:hover { background:#fafbff; }
#scanoutPage td {
  padding: 11px 12px; font-size:13px; vertical-align:top;
}

/* ══════════════════════════════════════
   TABLE CELLS — CONTENT
══════════════════════════════════════ */
#scanoutPage .so-check {
  width:16px; height:16px; accent-color:#2563eb; cursor:pointer; margin-top:2px;
}
#scanoutPage .ref-badge {
  display:inline-block; padding:3px 8px;
  background:#eff6ff; border:1px solid #dbeafe;
  border-radius:6px; font-size:11.5px; font-weight:700; color:#2563eb;
  white-space: nowrap;
}
#scanoutPage .cust-name { font-size:13px; font-weight:700; color:#0f172a; line-height:1.3; }
#scanoutPage .cust-id   { font-size:11px; color:#94a3b8; margin-top:2px; line-height:1.4; }
#scanoutPage .amount    { font-size:13px; font-weight:700; color:#0f172a; white-space:nowrap; }

/* Note preview */
#scanoutPage .note-preview {
  font-size:11px; color:#b45309; background:#fef3c7;
  border:1px solid #fde68a; border-radius:6px;
  padding:3px 7px; margin:4px 0 2px; line-height:1.4;
}
#scanoutPage .note-time { font-size:10px; color:#92400e; opacity:.7; margin-top:1px; }

/* Phone chip */
#scanoutPage .phone-chip {
  display: inline-block; padding: 3px 9px;
  border-radius: 20px; background: #eff6ff;
  color: #2563eb; font-size: 11.5px; font-weight:600;
  text-decoration: none; margin: 2px 2px 0 0;
  transition: background .15s;
}
#scanoutPage .phone-chip:hover { background:#dbeafe; }

/* Status pills */
#scanoutPage .pill {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 9px; border-radius:20px; font-size:11.5px; font-weight:600;
}
#scanoutPage .pill.pending   { background:#fefce8; color:#ca8a04; }
#scanoutPage .pill.delivered { background:#f0fdf4; color:#16a34a; }
#scanoutPage .pill.returned  { background:#fff1f2; color:#e11d48; }
#scanoutPage .pill-dot { width:6px; height:6px; border-radius:50%; background:currentColor; }

/* ══════════════════════════════════════
   ACTION COLUMN — COMPACT BUTTON STRIP
   All buttons in a tight horizontal row
══════════════════════════════════════ */
#scanoutPage td:last-child {
  white-space: nowrap;
  vertical-align: middle;
}

/* Unified micro-button base */
#scanoutPage .btn-deliver,
#scanoutPage .btn-return,
#scanoutPage .btn-eye,
#scanoutPage .btn-note,
#scanoutPage .btn-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all .15s ease;
  vertical-align: middle;
  margin: 1px;
  padding: 0;
  /* remove any inherited flex/gap/text styles */
  font-family: inherit;
  gap: 0;
  box-shadow: none;
}

/* ── Deliver (✓) — green accent ── */
#scanoutPage .btn-deliver {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #16a34a;
  font-weight: 800;
  font-size: 14px;
}
#scanoutPage .btn-deliver:hover {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,.25);
}
#scanoutPage .btn-deliver:active { transform: scale(.92); }
#scanoutPage .btn-deliver:disabled {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #cbd5e1;
  cursor: not-allowed;
  box-shadow: none;
}
/* Override SVG inside deliver — hide it, we use text ✓ from JS */
#scanoutPage .btn-deliver svg { display: none; }

/* ── Return (↩) — red accent ── */
#scanoutPage .btn-return {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
  font-weight: 700;
  font-size: 14px;
}
#scanoutPage .btn-return:hover {
  background: #e11d48;
  border-color: #e11d48;
  color: #fff;
  box-shadow: 0 2px 8px rgba(225,29,72,.22);
}
#scanoutPage .btn-return:active { transform: scale(.92); }

/* ── Eye (👁) — blue accent ── */
#scanoutPage .btn-eye {
  background: #eff6ff;
  border-color: #bfdbfe;
  font-size: 14px;
}
#scanoutPage .btn-eye:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.22);
}
/* SVG inside btn-eye */
#scanoutPage .btn-eye svg {
  width: 14px; height: 14px;
  stroke: #2563eb; fill: none; stroke-width: 2;
  transition: stroke .15s;
}
#scanoutPage .btn-eye:hover svg { stroke: #fff; }

/* ── Note (📝) — amber ── */
#scanoutPage .btn-note {
  background: #fffbeb;
  border-color: #fde68a;
  font-size: 14px;
}
#scanoutPage .btn-note:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  box-shadow: 0 2px 8px rgba(245,158,11,.22);
}

/* ── Pin (📍/📌) ── */
#scanoutPage .btn-pin {
  background: #f8fafc;
  border-color: #e2e8f0;
  font-size: 14px;
}
#scanoutPage .btn-pin:hover {
  background: #fef3c7;
  border-color: #fde68a;
}
#scanoutPage .btn-pin.active {
  background: #fbbf24;
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,.3);
}

/* ── Action-bar (bulk deliver) ── */
#scanoutPage .so-action-bar {
  max-width: 960px; margin: 12px auto 0;
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 11px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  gap: 12px;
}
#scanoutPage .so-sel-info { font-size:13px; color:#64748b; font-weight:500; }
#scanoutPage .so-sel-info span { font-weight:700; color:#2563eb; }

/* Bulk-deliver button (action bar) — keep pill-style here */
#scanoutPage .so-action-bar .btn-deliver {
  width: auto;
  height: auto;
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: none;
}
#scanoutPage .so-action-bar .btn-deliver svg { display: inline; width:15px; height:15px; stroke:#fff; fill:none; stroke-width:2.5; }
#scanoutPage .so-action-bar .btn-deliver:hover {
  background: #1d4ed8;
  color: #fff;
  box-shadow: 0 3px 12px rgba(37,99,235,.3);
}

/* ── Select-all row ── */
#scanoutPage .sel-all-wrap {
  padding: 9px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: #475569;
  cursor: pointer; user-select: none;
}
#scanoutPage .sel-all-wrap:hover { background: #f1f5f9; }

/* ══════════════════════════════════════
   PINNED ROW
══════════════════════════════════════ */
#scanoutPage .so-row.pinned-row,
#scanoutPage .pinned-row {
  background: linear-gradient(90deg, #fff7ed, #ffffff);
  border-left: 3px solid #f59e0b;
}
#scanoutPage .pin-badge {
  display:inline-flex; align-items:center; gap:4px;
  font-size:10px; font-weight:700; color:#b45309;
  background:#fef3c7; border:1px solid #fde68a;
  padding:2px 6px; border-radius:6px; margin-left:6px;
}

/* ══════════════════════════════════════
   MODALS — Overlay
══════════════════════════════════════ */
#scanoutPage .so-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: soFadeIn .18s ease;
}
@keyframes soFadeIn { from{opacity:0} to{opacity:1} }

/* ── Confirm modal ── */
#scanoutPage .so-modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 430px;
  box-shadow: 0 20px 60px rgba(0,0,0,.16);
  animation: soSlideUp .2s ease; overflow: hidden;
}
@keyframes soSlideUp { from{transform:translateY(14px);opacity:0} to{transform:translateY(0);opacity:1} }

#scanoutPage .so-modal-head {
  padding: 20px 20px 0; display:flex; align-items:center; gap:12px;
}
#scanoutPage .so-modal-icon {
  width:40px; height:40px; border-radius:10px;
  background:#eff6ff; display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
#scanoutPage .so-modal-icon svg { width:20px; height:20px; stroke:#2563eb; fill:none; stroke-width:2.5; }
#scanoutPage .so-modal-title { font-size:15px; font-weight:700; color:#0f172a; }
#scanoutPage .so-modal-sub   { font-size:12px; color:#64748b; margin-top:3px; }
#scanoutPage .so-modal-body  { padding:14px 20px; }
#scanoutPage .so-modal-list  { max-height:200px; overflow-y:auto; }
#scanoutPage .so-modal-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:7px 10px; border-radius:8px; margin-bottom:4px;
  background:#f8fafc; font-size:12.5px;
}
#scanoutPage .so-modal-item .mi-ref  { font-weight:700; color:#2563eb; }
#scanoutPage .so-modal-item .mi-name { color:#475569; }
#scanoutPage .so-modal-item .mi-amt  { font-weight:700; color:#0f172a; }
#scanoutPage .so-modal-foot {
  padding: 12px 20px 18px; display:flex; gap:10px;
}
#scanoutPage .btn-cancel {
  flex:1; padding:10px; border:1px solid #e2e8f0; border-radius:9px;
  background:#f8fafc; font-family:'Plus Jakarta Sans',sans-serif;
  font-size:13px; font-weight:600; color:#475569; cursor:pointer;
  transition:all .15s;
}
#scanoutPage .btn-cancel:hover { background:#f1f5f9; }
#scanoutPage .btn-confirm {
  flex:2; padding:10px; border:none; border-radius:9px;
  background:#2563eb; color:#fff;
  font-family:'Plus Jakarta Sans',sans-serif;
  font-size:13px; font-weight:700; cursor:pointer;
  transition:all .15s;
}
#scanoutPage .btn-confirm:hover { background:#1d4ed8; box-shadow:0 3px 12px rgba(37,99,235,.3); }

/* ── Detail modal ── */
#scanoutPage .so-detail-modal {
  background:#fff; border-radius:16px;
  width:100%; max-width:500px;
  box-shadow:0 20px 60px rgba(0,0,0,.15);
  animation:soSlideUp .2s ease; overflow:hidden;
}
#scanoutPage .sdm-head {
  padding:16px 20px; border-bottom:1px solid #f1f5f9;
  display:flex; align-items:center; justify-content:space-between;
}
#scanoutPage .sdm-head-left { display:flex; align-items:center; gap:12px; }
#scanoutPage .sdm-icon {
  width:38px; height:38px; border-radius:10px;
  background:linear-gradient(135deg,#2563eb,#3b82f6);
  display:flex; align-items:center; justify-content:center;
}
#scanoutPage .sdm-icon svg { width:17px; height:17px; stroke:#fff; fill:none; stroke-width:2.5; }
#scanoutPage .sdm-title { font-size:15px; font-weight:700; color:#0f172a; }
#scanoutPage .sdm-ref   { font-size:11.5px; color:#64748b; margin-top:2px; }
#scanoutPage .btn-close {
  width:30px; height:30px; border:1px solid #e2e8f0; border-radius:8px;
  background:#f8fafc; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:all .15s;
}
#scanoutPage .btn-close:hover { background:#fee2e2; border-color:#fecaca; }
#scanoutPage .btn-close svg { width:13px; height:13px; stroke:#64748b; fill:none; stroke-width:2.5; }
#scanoutPage .btn-close:hover svg { stroke:#e11d48; }
#scanoutPage .sdm-body { padding:16px 20px; display:flex; flex-direction:column; gap:12px; }
#scanoutPage .sdm-section-title {
  font-size:10px; font-weight:700; color:#94a3b8;
  text-transform:uppercase; letter-spacing:.07em; margin-bottom:7px;
}
#scanoutPage .sdm-grid { display:grid; grid-template-columns:1fr 1fr; gap:9px; }
#scanoutPage .sdm-field { background:#f8fafc; border-radius:9px; padding:9px 11px; }
#scanoutPage .sdm-field.full { grid-column:1/-1; }
#scanoutPage .sdm-label { font-size:10px; color:#94a3b8; font-weight:600; margin-bottom:3px; }
#scanoutPage .sdm-value { font-size:13px; font-weight:600; color:#0f172a; }
#scanoutPage .sdm-value.blue  { color:#2563eb; }
#scanoutPage .sdm-value.green { color:#16a34a; }

/* ── Return reason modal ── */
#scanoutPage .return-reason-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 220px; overflow-y: auto;
  padding-right: 4px;
}
#scanoutPage .reason-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 8px;
  background: #f8fafc; border: 1px solid #f1f5f9;
  font-size: 12.5px; font-weight:500; color:#334155;
  cursor: pointer; transition: background .12s;
}
#scanoutPage .reason-item:hover { background: #eff6ff; border-color:#bfdbfe; }
#scanoutPage .reason-item input { accent-color:#2563eb; width:14px; height:14px; flex-shrink:0; }
#scanoutPage #soReturnRemark {
  width: 100%; padding: 9px 11px;
  border: 1px solid #e2e8f0; border-radius:9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px; color:#0f172a; margin-top:8px;
  resize: vertical; min-height: 60px;
  transition: border-color .15s;
  box-sizing: border-box;
}
#scanoutPage #soReturnRemark:focus { border-color:#2563eb; outline:none; }

/* Note textarea */
#scanoutPage #soNoteText {
  width: 100%; padding: 9px 11px;
  border: 1px solid #e2e8f0; border-radius:9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px; color:#0f172a;
  resize: vertical; min-height: 80px;
  transition: border-color .15s;
  box-sizing: border-box;
}
#scanoutPage #soNoteText:focus { border-color:#2563eb; outline:none; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
#so-toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(6px);
  transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.18); max-width: 300px;
}
#so-toast.show { opacity:1; transform:translateY(0); }

/* ══════════════════════════════════════
   MOBILE  ≤ 640 px
══════════════════════════════════════ */
@media (max-width: 640px) {
  #scanoutPage {
    padding: 0 0 72px;
  }

  /* ── Header ── */
  #scanoutPage .so-header {
    border-radius: 0;
    margin-bottom: 0;
    padding: 11px 14px;
    border-left: none; border-right: none; border-top: none;
  }
  #scanoutPage .so-title { font-size: 14px; }
  #scanoutPage .so-sub   { display: none; }

  /* ── Tabs ── */
  #scanoutPage .so-tabs {
    border-radius: 0; margin: 0 0 10px;
    border-left: none; border-right: none; border-top: none;
    padding: 6px;
  }
  #scanoutPage .so-tab { font-size: 11px; padding: 7px 0; }
  #scanoutPage .so-tab .tab-count { padding: 1px 5px; font-size: 10px; }

  /* ── Card ── */
  #scanoutPage .so-card {
    border-radius: 0;
    border-left: none; border-right: none;
    margin: 0;
  }

  /* ── Table: hide Company col on mobile ── */
  #scanoutPage thead th:nth-child(4),
  #scanoutPage td:nth-child(4) { display: none; }

  /* Tighter cells */
  #scanoutPage thead th { font-size:9px; padding: 8px 8px; }
  #scanoutPage td { padding: 9px 8px; font-size: 12px; }

  /* Ref badge smaller */
  #scanoutPage .ref-badge { font-size: 10.5px; padding: 2px 6px; }

  /* Customer col: reduce */
  #scanoutPage .cust-name { font-size: 12px; }
  #scanoutPage .cust-id   { font-size: 10.5px; }

  /* Amount */
  #scanoutPage .amount { font-size: 12px; }

  /* ── ACTION COLUMN: compact 2×2 grid on mobile ── */
  #scanoutPage td:last-child {
    white-space: normal;
    vertical-align: middle;
    padding: 8px 6px;
  }

  /* Wrap all buttons into a 2-column grid */
  #scanoutPage td:last-child > * {
    /* each button is a grid item */
    display: inline-flex;
  }

  #scanoutPage .btn-deliver,
  #scanoutPage .btn-return,
  #scanoutPage .btn-eye,
  #scanoutPage .btn-note,
  #scanoutPage .btn-pin {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 13px;
    margin: 2px 1px;
  }

  /* ── Action bar ── */
  #scanoutPage .so-action-bar {
    border-radius: 0;
    border-left: none; border-right: none;
    margin: 0; padding: 9px 12px;
  }
  #scanoutPage .so-sel-info { font-size: 12px; }
  #scanoutPage .so-action-bar .btn-deliver {
    font-size: 12px; padding: 8px 14px;
  }

  /* ── Toast ── */
  #so-toast {
    left: 50%; right: auto;
    transform: translateX(-50%) translateY(6px);
    max-width: 88%;
  }
  #so-toast.show { transform: translateX(-50%) translateY(0); }

  /* ── Modals ── */
  #scanoutPage .so-modal,
  #scanoutPage .so-detail-modal {
    border-radius: 14px;
  }
  #scanoutPage .so-overlay { padding: 12px; align-items: flex-end; }
  #scanoutPage .so-modal,
  #scanoutPage .so-detail-modal {
    animation: soSlideUp .22s ease;
    max-width: 100%;
  }

  /* Sel-all row */
  #scanoutPage .sel-all-wrap { font-size: 11.5px; padding: 8px 12px; }
}

/* ══════════════════════════════════════
   VERY SMALL  ≤ 380 px
══════════════════════════════════════ */
@media (max-width: 380px) {
  /* Also hide Amount col to maximise space */
  /* Uncomment if still too tight:
  #scanoutPage thead th:nth-child(5),
  #scanoutPage td:nth-child(5) { display: none; }
  */

  #scanoutPage .btn-deliver,
  #scanoutPage .btn-return,
  #scanoutPage .btn-eye,
  #scanoutPage .btn-note,
  #scanoutPage .btn-pin {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}