/* The pharmacy module: the counter (نقطة البيع), its dialogs, the purchase
   entry, boards and lists, the 80 mm receipt and the A4 label sheet.
   Flat, tokens only (dark mode follows), logical properties only. */

/* ------------------------------------------------------------ small bits */

.ph-sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}
.ph-warn {
  color: var(--warn);
}
.ph-flag {
  padding: 0 7px;
  font-size: 0.7rem;
  line-height: 1.5;
  vertical-align: 0.1em;
  border-color: transparent;
}
.ph-flag-ctl {
  background: var(--danger-soft);
  color: var(--danger);
}
.ph-flag-rx {
  background: var(--violet-soft);
  color: var(--violet);
}
.ph-flag-cold {
  background: var(--info-soft);
  color: var(--info);
}
.ph-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ph-inline input {
  min-height: 36px;
  padding-block: 4px;
}
.ph-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.ph-inline-form .field {
  margin: 0;
  min-width: 180px;
}
.ph-mini-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ph-mini-form input {
  max-width: 100px;
  min-height: 34px;
  padding-block: 4px;
}
.ph-qty-in,
.ph-price-in {
  max-width: 120px;
  min-height: 36px !important;
  padding-block: 4px !important;
}
.ph-section-title {
  margin: 28px 0 12px;
}
.ph-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: flex-start;
  margin-block-end: 8px;
}
.ph-bulk fieldset {
  margin: 0;
}
.ph-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0 14px;
}
.ph-request-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 90px minmax(0, 1.3fr) minmax(0, 1.3fr) auto;
  gap: 0 12px;
  align-items: end;
  margin-block-end: 8px;
}
.ph-request-form .btn {
  margin-block-end: 14px;
}
.ph-row-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) auto auto;
  gap: 10px;
  align-items: center;
  padding-block: 8px;
  border-block-end: 1px solid var(--line);
}
.ph-row-form .check {
  margin: 0;
}
.ph-visit-list li {
  font-size: 0.88rem;
  padding: 7px 0;
}
.ph-chronic {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-block-start: 8px;
}
.ph-cust-money {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block: 6px;
}

/* ------------------------------------------------------------ the counter */

.ph-pos kbd,
.ph-keys kbd,
.ph-dlg kbd {
  display: inline-block;
  min-width: 22px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-block-end-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font: 600 0.72rem/1.6 ui-monospace, monospace;
  text-align: center;
}
.btn-primary kbd {
  background: transparent;
  border-color: currentColor;
  color: inherit;
  opacity: 0.8;
}
.ph-pos-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 14px;
}
.ph-pos-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ph-pos-title h1 {
  margin: 0;
  font-size: 1.4rem;
}
.ph-pos-title a.pill:hover {
  text-decoration: none;
  border-color: var(--brand);
}
.ph-pos-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ph-pos-tools .count {
  height: 20px;
  min-width: 20px;
}
.ph-shift-gate {
  border-color: var(--brand);
  max-width: 760px;
}
.ph-shift-gate h2 {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ph-pos-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 1100px) {
  .ph-pos-grid {
    grid-template-columns: minmax(0, 1fr) 370px;
  }
  .ph-pos-side {
    position: sticky;
    inset-block-start: calc(var(--top-h) + 14px);
  }
}
.ph-pos-side {
  display: grid;
  gap: 14px;
}
.ph-pos-side > .card {
  margin: 0;
  padding: 16px;
}
.ph-pos-side .card-head {
  margin-block-end: 8px;
}
.ph-pos-side .card-head h2 a {
  color: var(--ink);
}

.ph-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 16px 10px;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--brand);
}
.ph-search:focus-within {
  border-color: var(--brand);
}
.ph-search input {
  flex: 1;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  min-height: 58px !important;
  padding: 0 !important;
  font-size: 1.1rem;
}
.ph-results {
  position: absolute;
  inset-inline: -2px;
  inset-block-start: calc(100% + 6px);
  z-index: 40;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.ph-res {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 120px;
  gap: 4px 12px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.ph-res:hover,
.ph-res[aria-selected='true'] {
  background: var(--brand-soft);
}
.ph-res small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}
.ph-res-name strong {
  font-weight: 600;
}
.ph-res-stock {
  font-size: 0.85rem;
}
.ph-res-price {
  text-align: end;
  font-weight: 600;
}
.ph-res-shelf {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--muted);
}
.ph-res-none {
  padding: 12px;
  margin: 0;
}
.ph-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-block-start: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}
.ph-notice span {
  flex: 1;
}
.ph-notice a {
  color: inherit;
  text-decoration: underline;
}
.ph-notice-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.ph-notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.ph-cart {
  margin-block-start: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ph-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 46px 16px;
  text-align: center;
  color: var(--ink-2);
}
.ph-cart-empty p {
  margin: 0;
}
.ph-cart-empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-block-end: 8px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.ph-cart-empty-icon .ic {
  width: 30px;
  height: 30px;
}
.ph-line {
  display: grid;
  grid-template-columns: auto 128px auto minmax(0, 1fr) 110px 34px;
  grid-template-areas:
    'name name name name total x'
    'packs qty price disc total .';
  gap: 8px 14px;
  align-items: center;
  padding: 12px 14px;
  border-block-end: 1px solid var(--line);
  border-inline-start: 3px solid transparent;
}
.ph-line-name {
  grid-area: name;
}
.ph-packs {
  grid-area: packs;
}
.ph-qty {
  grid-area: qty;
}
.ph-line-price {
  grid-area: price;
}
.ph-line-disc {
  grid-area: disc;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ph-line-disc::before {
  content: 'خصم';
  font-size: 0.8rem;
  color: var(--muted);
}
.ph-line-total {
  grid-area: total;
}
.ph-line-x {
  grid-area: x;
}
.ph-line:last-child {
  border-block-end: 0;
}
.ph-line.is-sel {
  border-inline-start-color: var(--brand);
  background: var(--surface-2);
}
.ph-line.is-short {
  border-inline-start-color: var(--danger);
}
.ph-line-name {
  min-width: 0;
}
.ph-line-name strong {
  font-weight: 600;
}
.ph-line-meta {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}
.ph-packs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  overflow: hidden;
}
.ph-packs button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.ph-packs button:first-child {
  border-inline-start: 0;
}
.ph-packs button[aria-pressed='true'] {
  background: var(--brand);
  color: var(--on-brand);
}
.ph-qty {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
}
.ph-qty .icon-btn {
  width: 34px;
  height: 34px;
}
.ph-qty input {
  min-height: 34px !important;
  padding: 0 !important;
  border: 0 !important;
  text-align: center;
  font-weight: 700;
  background: transparent !important;
}
.ph-line-price {
  font-size: 0.88rem;
}
.ph-line-price small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}
.ph-line-disc input {
  max-width: 96px;
  min-height: 34px !important;
  padding: 4px 8px !important;
  text-align: center;
}
.ph-line-total {
  text-align: end;
  font-size: 1.05rem;
}
.ph-line-x {
  width: 34px;
  height: 34px;
  color: var(--muted);
}
.ph-line-x:hover {
  color: var(--danger);
}
.ph-alts {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--ink-2);
}

.ph-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-block-start: 16px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* customer and payment */
.ph-cust-search {
  position: relative;
}
.ph-cust-new summary {
  font-size: 0.85rem;
}
.ph-cust-new .grid-2 {
  gap: 8px;
  margin-block: 8px;
}
.ph-totals > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-block: 4px;
  font-size: 0.9rem;
}
.ph-cart-disc label {
  color: var(--ink-2);
}
.ph-cart-disc input {
  max-width: 110px;
  min-height: 34px !important;
  padding: 4px 8px !important;
}
.ph-due {
  margin-block-start: 6px;
  padding-block-start: 10px !important;
  border-block-start: 1px solid var(--line);
}
.ph-due strong {
  font-size: 1.7rem;
  line-height: 1.2;
  color: var(--brand-ink);
}
.ph-rx,
.ph-rx-photo {
  margin-block: 8px;
}
.ph-rx p {
  margin: 0 0 6px;
}
.ph-rx-photo label {
  cursor: pointer;
}
.ph-pays {
  margin-block-start: 10px;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--line);
}
.ph-pay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 34px;
  gap: 8px;
  align-items: center;
  margin-block-end: 8px;
}
.ph-pay-row select,
.ph-pay-row input,
.ph-tender input {
  min-height: 40px;
  padding-block: 6px;
}
.ph-pay-add {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-block-end: 8px;
}
.ph-tender {
  display: grid;
  grid-template-columns: auto 110px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-block: 4px 8px;
  font-size: 0.88rem;
}
.ph-change {
  text-align: end;
}
.ph-change strong {
  font-size: 1.15rem;
  color: var(--ok);
}
.ph-credit {
  font-size: 0.88rem;
}
.ph-credit.is-off {
  opacity: 0.6;
}
.ph-pay-actions {
  margin-block-start: 12px;
}
.ph-pay-actions .btn-row {
  justify-content: space-between;
}
.ph-more summary {
  list-style: none;
}
.ph-more summary::-webkit-details-marker {
  display: none;
}
.ph-more input {
  margin-block-start: 6px;
  min-height: 36px;
}

/* dialogs */
.ph-dlg {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
}
.ph-dlg-wide {
  width: min(660px, calc(100% - 32px));
}
.ph-dlg::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.ph-dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-block-end: 10px;
}
.ph-dlg-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.ph-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.ph-done h2 {
  margin: 4px 0 0;
}
.ph-done p {
  margin: 0;
}
.ph-done-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}
.ph-change[hidden] {
  display: none;
}
.ph-done .ph-change {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-block: 10px;
  padding: 12px 26px;
  border-radius: var(--radius);
  background: var(--ok-soft);
  color: var(--ok);
  text-align: center;
}
.ph-done .ph-change strong {
  font-size: 2.2rem;
  line-height: 1.2;
}
.ph-done-actions {
  justify-content: center;
}

/* phone: the total and the pay button above the tab bar */
.ph-paybar {
  display: none;
}
@media (max-width: 1023px) {
  .ph-paybar:not([hidden]) {
    position: fixed;
    inset-inline: 0;
    inset-block-end: calc(var(--tab-h) + env(safe-area-inset-bottom));
    z-index: 25;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border-block-start: 1px solid var(--line);
  }
  .ph-paybar strong {
    font-size: 1.2rem;
  }
  .ph-pos-body .main {
    padding-block-end: 84px;
  }
  .ph-keys {
    display: none;
  }
}
@media (max-width: 760px) {
  .ph-pos-title h1 {
    font-size: 1.2rem;
  }
  .ph-line {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'name name x'
      'packs packs packs'
      'qty price total'
      'disc disc disc';
    gap: 8px;
    padding: 12px;
  }
  .ph-packs {
    justify-self: start;
  }
  .ph-qty {
    width: 128px;
  }
  .ph-res {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .ph-res-stock {
    grid-column: 1;
    grid-row: 2;
  }
  .ph-res-price {
    grid-row: 1 / span 2;
    grid-column: 2;
  }
  .ph-request-form,
  .ph-row-form {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------ purchase entry */

.ph-plines {
  display: grid;
  gap: 8px;
}
.ph-pline {
  display: grid;
  grid-template-columns: minmax(170px, 2.2fr) 74px 66px 98px 66px minmax(80px, 1fr) 130px 96px 34px;
  gap: 8px;
  align-items: center;
}
.ph-pline input {
  min-height: 40px;
  padding: 6px 8px;
}
.ph-pline-head {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.ph-pline-item {
  position: relative;
}
.ph-pline-total {
  text-align: end;
  font-weight: 600;
}
.ph-ptotals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  justify-content: flex-end;
  margin-block: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
@media (max-width: 1100px) {
  .ph-pline-head {
    display: none;
  }
  .ph-pline {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }
  .ph-pline-item {
    grid-column: 1 / -1;
  }
  .ph-pline-total {
    grid-column: span 3;
  }
}

/* -------------------------------------------------- deliveries, refills */

.ph-board {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .ph-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .ph-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.ph-board-col {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.ph-board-col h2 {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 4px;
  font-size: 0.95rem;
}
.ph-ticket {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.ph-ticket:hover {
  border-color: var(--brand);
  text-decoration: none;
}
.ph-ticket-head,
.ph-ticket-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ph-refills {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.ph-refills .card {
  margin: 0;
}
.ph-refill-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
}

/* ------------------------------------------------------------ printouts */

.ph-print-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.82rem;
  text-align: end;
}
.ph-print-brand img,
.ph-print-brand .logo-mark {
  max-height: 46px;
  width: auto;
  height: 40px;
}
.ph-sheet-wide {
  max-width: 287mm;
  page: phwide;
}
.ph-receipt-logo {
  max-height: 14mm;
  max-width: 40mm;
  margin-inline: auto;
  display: block;
}
.ph-receipt-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}
.ph-receipt td small {
  display: block;
  font-size: 10.5px;
  color: #333;
}
.ph-receipt-name {
  display: block;
  font-weight: 600;
  text-align: start;
}
.ph-receipt .total-row td {
  border-block-start: 1px solid #000;
}
.ph-receipt-code {
  margin: 6px auto 2px;
  width: 62%;
}
.ph-receipt-code svg {
  width: 100%;
  height: auto;
}
.ph-slip-to {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-block: 6px;
  padding: 6px;
  border: 1px dashed #777;
  text-align: start;
  font-size: 12px;
}
.ph-slip-to strong {
  font-size: 14px;
}

.ph-labels {
  display: grid;
  grid-template-columns: repeat(3, 70mm);
  grid-auto-rows: 37mm;
  width: 210mm;
  margin: 16px auto;
  background: #fff;
  color: #000;
  page: phlabels;
}
.ph-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1mm;
  padding: 2mm 3mm;
  border: 1px dashed #bbb;
  overflow: hidden;
  text-align: center;
}
.ph-label strong {
  font-size: 11pt;
  line-height: 1.15;
  max-height: 2.4em;
  overflow: hidden;
}
.ph-label-price {
  font-size: 12pt;
  font-weight: 700;
}
.ph-label-price small {
  font-weight: 400;
  font-size: 8pt;
}
.ph-label svg {
  width: 52mm;
  height: 13mm;
}
.ph-label-none,
.ph-label-shelf {
  font-size: 8pt;
  color: #444;
}
@media print {
  .ph-labels {
    margin: 0;
  }
  .ph-label {
    border-color: transparent;
  }
}
@page phlabels {
  size: A4;
  margin: 0;
}
@page phwide {
  size: A4 landscape;
  margin: 10mm;
}
@media (max-width: 1023px) {
  .ph-pos kbd {
    display: none;
  }
}
.ph-nowrap td.num,
.ph-nowrap th {
  white-space: nowrap;
}
@media (max-width: 560px) {
  .ph-hero .hero-nums {
    grid-template-columns: 1fr 1fr;
  }
  .ph-hero .hero-nums strong {
    font-size: 1.25rem;
  }
}
