/* =====================================================================
   MES mobile-first pages (mes-*): «امروز», new-order wizard, orders, order details.
   Uses the lavender.css tokens (--lv-*). Loaded after lavender.css.
   Colour meaning never changes: pistachio = in progress, apricot = waiting/paused, raspberry = late.
   ===================================================================== */
.mes-m { max-width: 1180px; margin: 0 auto; color: var(--lv-aubergine); }
.mes-muted { color: var(--lv-muted); font-size: 14px; }
.mes-grow { flex: 1; min-width: 0; }
.mes-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mes-h1 { font-size: 28px; font-weight: 900; margin: 0; color: var(--lv-aubergine); }
.mes-h2 { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 900; margin: 22px 2px 12px; color: var(--lv-aubergine); }
.mes-count { background: var(--lv-lilac); color: var(--lv-lavandin-deep); border-radius: 999px; padding: 0 10px; font-size: 14px; line-height: 26px; }
.mes-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.mes-dot.is-waiting { background: var(--lv-apricot); }
.mes-dot.is-running { background: var(--lv-pistachio); }
.mes-dot.is-late { background: var(--lv-raspberry); }

/* buttons: finger-sized */
.mes-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 10px 20px; border: 1.5px solid transparent; border-radius: 16px; font-size: 17px; font-weight: 700; line-height: 1.4; cursor: pointer; text-decoration: none !important; font-family: inherit; transition: background-color .15s ease; }
.mes-btn i { font-size: 22px; }
.mes-btn-block { display: flex; width: 100%; }
.mes-btn-hero { display: flex; width: 100%; min-height: 72px; font-size: 21px; font-weight: 900; border-radius: 20px; }
.mes-btn-hero i { font-size: 26px; }
.mes-btn-primary { background: var(--lv-lavandin); color: #fff !important; }
.mes-btn-primary:hover, .mes-btn-primary:active { background: var(--lv-lavandin-deep); }
.mes-btn-start { background: var(--lv-pistachio); color: var(--lv-aubergine) !important; }
.mes-btn-pause { background: var(--lv-apricot); color: var(--lv-aubergine) !important; }
.mes-btn-light { background: #fff; border-color: var(--lv-line-strong); color: var(--lv-aubergine) !important; }
.mes-btn-light:hover { background: var(--lv-lilac-soft); }
.mes-btn-danger { background: #fff; border-color: var(--lv-raspberry); color: var(--lv-raspberry-ink) !important; }
.mes-btn[disabled] { opacity: .45; cursor: not-allowed; }
.mes-icon-btn { position: relative; width: 52px; height: 52px; flex-shrink: 0; border: 0; border-radius: 16px; background: var(--lv-lilac-soft); color: var(--lv-aubergine) !important; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }
.mes-badge { position: absolute; top: -4px; left: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--lv-raspberry-deep); color: #fff; font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }

/* sections + cards: one column on phones, three on tablet/desktop */
.mes-sections { display: grid; grid-template-columns: 1fr; gap: 0 18px; }
@media (min-width: 768px) { .mes-sections { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mes-card { display: block; background: #fff; border: 1px solid var(--lv-line); border-right: 6px solid var(--lv-line-strong); border-radius: 20px; padding: 14px; margin-bottom: 12px; color: var(--lv-aubergine) !important; text-decoration: none !important; }
a.mes-card:hover { border-color: var(--lv-line-strong); }
.mes-card.is-waiting, .mes-card.is-paused, .mes-card.is-assigned { border-right-color: var(--lv-apricot); }
.mes-card.is-running { border-right-color: var(--lv-pistachio); }
.mes-card.is-late, .mes-card.is-delayed { border-right-color: var(--lv-raspberry); }
.mes-card.is-completed { border-right-color: var(--lv-lavandin); }
.mes-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mes-card-head:last-child { margin-bottom: 0; }
.mes-thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 14px; object-fit: cover; background: var(--lv-lilac-soft); color: var(--lv-lavandin); display: inline-flex; align-items: center; justify-content: center; font-size: 28px; }
.mes-card-title { display: block; font-size: 18px; font-weight: 700; line-height: 1.5; }
.mes-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; margin-top: 8px; }
.mes-timer { direction: ltr; font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--lv-pistachio-ink); }
.mes-timer.is-late { color: var(--lv-raspberry-ink); }
.mes-card.is-paused .mes-timer { color: var(--lv-apricot-ink); }
.mes-note { border-radius: 12px; padding: 8px 12px; margin-top: 10px; font-size: 15px; font-weight: 500; }
.mes-note.is-paused, .mes-note.is-waiting { background: var(--lv-apricot-soft); color: var(--lv-apricot-ink); }
.mes-note.is-late { background: var(--lv-raspberry-soft); color: var(--lv-raspberry-ink); }
.mes-note.is-running { background: var(--lv-pistachio-soft); color: var(--lv-pistachio-ink); }
.mes-chip { display: inline-flex; align-items: center; padding: 2px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.mes-chip.is-free, .mes-chip.is-completed { background: var(--lv-lilac); color: var(--lv-lavandin-deep); }
.mes-chip.is-running { background: var(--lv-pistachio-soft); color: var(--lv-pistachio-ink); }
.mes-chip.is-waiting, .mes-chip.is-paused, .mes-chip.is-assigned { background: var(--lv-apricot-soft); color: var(--lv-apricot-ink); }
.mes-chip.is-late, .mes-chip.is-delayed { background: var(--lv-raspberry-soft); color: var(--lv-raspberry-ink); }
.mes-chip.is-pending, .mes-chip.is-cancelled { background: #EEE9F4; color: var(--lv-muted); }
.mes-empty { border: 1.5px dashed var(--lv-line-strong); border-radius: 18px; padding: 18px 16px; text-align: center; color: var(--lv-aubergine); font-size: 16px; line-height: 1.8; margin: 0 0 12px; }
.mes-progress { height: 10px; background: var(--lv-lilac-soft); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.mes-progress > span { display: block; height: 100%; background: var(--lv-pistachio); border-radius: 999px; }

/* tucked-away sections */
.mes-fold { display: block !important; padding: 0 !important; background: #fff; border: 1px solid var(--lv-line); border-radius: 18px; margin: 12px 0; }
.mes-fold > summary { list-style: none; cursor: pointer; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 18px; font-size: 17px; font-weight: 700; }
.mes-fold > summary::-webkit-details-marker { display: none; }
.mes-fold > summary::after { content: "▾"; color: var(--lv-muted); }
.mes-fold[open] > summary::after { content: "▴"; }
.mes-fold > :not(summary) { margin: 0 16px 16px; }
.mes-more { margin-top: 24px; }
.mes-links { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 768px) { .mes-links { grid-template-columns: repeat(3, 1fr); } }

/* bottom sheet (full screen on phones) */
.mes-backdrop { position: fixed; inset: 0; z-index: 1090; background: rgba(42, 27, 61, .5); display: none; }
body.mes-sheet-on .mes-backdrop { display: block; }
body.mes-sheet-on { overflow: hidden; }
.mes-sheet { position: fixed; inset: auto 0 0 0; z-index: 1100; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--lv-float); transform: translateY(105%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
.mes-sheet.open { transform: none; visibility: visible; }
body.mes-sheet-on .swal2-container { z-index: 1110; } /* a question asked from an open sheet (finish) shows above it */
@media (max-width: 767.98px) { .mes-sheet-full { top: 0; max-height: none; border-radius: 0; } }
@media (min-width: 768px) { .mes-sheet { max-width: 640px; margin: 0 auto; } }
.mes-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.mes-sheet-title { display: block; font-size: 21px; font-weight: 900; line-height: 1.5; }
.mes-op-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 768px) { .mes-op-list { grid-template-columns: 1fr 1fr; } }
.mes-op-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 10px 14px; border: 2px solid var(--lv-line-strong); border-radius: 18px; background: #fff; color: var(--lv-aubergine); font-size: 18px; font-weight: 700; text-align: right; cursor: pointer; font-family: inherit; }
.mes-op-btn:hover:not([disabled]), .mes-op-btn:focus-visible { border-color: var(--lv-lavandin); background: var(--lv-lilac-soft); }
.mes-op-btn[disabled] { opacity: .5; cursor: not-allowed; }
.mes-op-avatar { width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; background: var(--lv-lilac); color: var(--lv-lavandin-deep); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 900; }
.mes-op-name { flex: 1; min-width: 0; }
.mes-op-name small { display: block; color: var(--lv-muted); font-size: 13px; font-weight: 500; }

/* new-order wizard: big tiles, +/- stepper, quick chips */
.mes-hidden { display: none !important; }
.mes-wizard { max-width: 920px; }
.mes-search { min-height: 56px; font-size: 17px; border-radius: 16px; margin-bottom: 12px; }
.mes-tiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 768px) { .mes-tiles { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .mes-tiles { grid-template-columns: repeat(3, 1fr); } .mes-tiles.is-wide { grid-template-columns: repeat(2, 1fr); } }
.mes-tile { position: relative; display: flex; align-items: center; gap: 12px; min-height: 84px; padding: 10px 14px; margin: 0; border: 2px solid var(--lv-line-strong); border-radius: 18px; background: #fff; cursor: pointer; }
.mes-tile[hidden] { display: none; }
.mes-tile input { position: absolute; opacity: 0; pointer-events: none; }
.mes-tile:has(input:checked) { border-color: var(--lv-lavandin); background: var(--lv-lilac-soft); }
.mes-tile:has(input:focus-visible) { box-shadow: var(--lv-ring); }
.mes-tile-text { flex: 1; min-width: 0; }
.mes-tile-text b { display: block; font-size: 18px; line-height: 1.5; }
.mes-tile-text small { display: block; color: var(--lv-muted); font-size: 14px; line-height: 1.6; }
.mes-stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mes-stepper .mes-btn { width: 88px; height: 88px; padding: 0; flex-shrink: 0; border-radius: 22px; }
.mes-stepper .mes-btn i { font-size: 34px; }
.mes-stepper input { flex: 1; min-width: 0; height: 88px; text-align: center; font-size: 44px; font-weight: 900; border: 2px solid var(--lv-line-strong); border-radius: 22px; background: #fff; color: var(--lv-aubergine); }
.mes-stepper input:focus { outline: none; border-color: var(--lv-lavandin); box-shadow: var(--lv-ring); }
.mes-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.mes-chips .mes-btn { padding: 0; font-size: 19px; }
.mes-summary { margin-bottom: 14px; }
.mes-summary-text { font-size: 22px; font-weight: 900; line-height: 1.7; margin: 4px 0 0; }
.mes-toggle { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 10px 16px; margin-bottom: 14px; border: 2px solid var(--lv-line-strong); border-radius: 18px; background: #fff; cursor: pointer; }
.mes-toggle input { width: 28px; height: 28px; accent-color: var(--lv-raspberry); flex-shrink: 0; }
.mes-toggle b { display: block; font-size: 18px; }
.mes-toggle small { display: block; color: var(--lv-muted); font-size: 14px; }
.mes-toggle:has(input:checked) { border-color: var(--lv-raspberry); background: var(--lv-raspberry-soft); }
.mes-wizard .mes-btn-hero { margin-top: 8px; }
/* room for the bottom tab bar under the last button (the wizard's «اجزا» step, the semi-finished stock list) */
@media (max-width: 991.98px) { .mes-wizard, .mes-wip { padding-bottom: 72px; } }

/* orders list: DataTable on tablet/desktop, cards on phones */
.mes-order-cards { display: none; }
.mes-filters > .row { margin-left: 0; margin-right: 0; }
@media (max-width: 767.98px) {
    body .content-body table#batch-listing.table { display: none !important; }
    .mes-order-cards { display: block; margin-top: 8px; }
}
@media (min-width: 768px) { .mes-filters { border: 0; margin: 0; } .mes-filters > summary { display: none; } .mes-filters > :not(summary) { margin: 0; } }
@media (max-width: 767.98px) { #batch-listing_wrapper .dataTables_length { display: none; } }
.mes-card.is-completed .mes-timer { color: var(--lv-muted); font-size: 18px; }

/* ===== MES shared (helpers for every MES page) ===== */
/* scrollable table with a fade hint on the trailing edge; first/last column stay reachable on phones */
.mes-table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; background:
    linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) left center / 28px 100% no-repeat local,
    linear-gradient(to left, rgba(94,68,133,.18), rgba(94,68,133,0)) left center / 14px 100% no-repeat scroll; }
.mes-table-wrap > table { margin-bottom: 0; }
@media (max-width: 767.98px) {
    .mes-table-wrap th:last-child, .mes-table-wrap td:last-child { position: sticky; left: 0; background: #fff; box-shadow: 8px 0 8px -8px rgba(30,29,32,.18); }
    .mes-table-wrap th:first-child, .mes-table-wrap td:first-child { position: sticky; right: 0; background: #fff; z-index: 1; }
}
/* numbers, times and clocks that must not flip inside RTL text */
.mes-num { unicode-bidi: isolate; direction: ltr; display: inline-block; font-variant-numeric: tabular-nums; }
td.mes-num, th.mes-num { display: table-cell; text-align: right; } /* on a cell, inline-block breaks the table row */
/* icon-only button: 44x44 touch target + visible keyboard focus */
.mes-icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--lv-lavandin-deep); cursor: pointer; }
.mes-icon-btn:hover { background: var(--lv-line); }
.mes-icon-btn:focus-visible { outline: none; box-shadow: var(--lv-ring); }
.mes-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
/* delay text: bold, and pages should pair it with the word «تأخیر» so colour is not the only cue */
.mes-delay { color: #B3274F; font-weight: 700; font-variant-numeric: tabular-nums; }
