/* Styles of the shared UI helpers (ui.js, pager.js), v3.44: toasts, the question dialogs, "show more", the pager.
   Loaded after app.css and shell.css; only these helpers live here. Tokens come from app.css (with fallbacks). */

/* the toast's surface (in the dark one step lighter than the sheets and dialogs it may sit on); the destructive key's
   red (--danger) lives in app.css with .btn-primary.danger, which .ie-btn-danger matches */
:root { --ie-toast-bg: var(--raised, #FFFFFF); --ie-toast-edge: transparent; }
:root[data-theme="dark"] { --ie-toast-bg: #2A2A2A; --ie-toast-edge: rgba(255, 255, 255, 0.08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ie-toast-bg: #2A2A2A; --ie-toast-edge: rgba(255, 255, 255, 0.08); } }

/* IEIcon: a line icon the size of the text around it */
.ie-icon { display: inline-block; width: 1em; height: 1em; flex: 0 0 auto; vertical-align: -0.125em; }

/* read out by screen readers, never seen */
.ie-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ============================================================== Toasts
   The region is a popover in the top layer (above sheets and dialogs); bottom right on a desk, top centre on a
   phone. Empty, it takes no clicks. A page with a bar at the foot lifts it on a desk with --toast-bottom. */
.ie-toasts {
  position: fixed;
  inset: auto max(1.5rem, env(safe-area-inset-right, 0px)) var(--toast-bottom, calc(1.5rem + env(safe-area-inset-bottom, 0px))) auto;
  margin: 0; padding: 0; border: 0; background: none; color: var(--fg); overflow: visible;
  width: min(22.5rem, calc(100vw - 2rem)); height: auto; max-height: none;
  display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem;
  pointer-events: none;
  z-index: var(--z-toast, 100);
}
.ie-toasts[popover]:not(:popover-open) { display: none; }
.ie-toasts > * { pointer-events: auto; }
.ie-toasts > .ie-sr { pointer-events: none; }
.ie-still, .ie-still * { transition: none !important; animation: none !important; }
@media (max-width: 639px) {
  .ie-toasts {
    inset: calc(3.5rem + env(safe-area-inset-top, 0px) + 0.5rem) 1rem auto 1rem;
    width: auto;
    flex-direction: column-reverse;   /* the newest on top, nearest the edge it came from */
  }
}
/* an open side sheet keeps its actions at the bottom right: the toasts move beside it (desk), or above it, into the
   dimmed strip over the bottom sheet (phone), so they never cover the sheet's next action, its title or its close key */
:root:has(dialog.sheet[open]) { --sheet-w: min(92vw, 30rem); }
:root:has(dialog.sheet.co-sheet[open]) { --sheet-w: min(96vw, 34rem); }
:root:has(dialog.sheet.sv-sheet[open]) { --sheet-w: min(96vw, 36rem); }
:root:has(dialog.sheet.cu-sheet[open]) { --sheet-w: min(96vw, 40rem); }
:root:has(dialog.sheet.qt-sheet[open]) { --sheet-w: min(96vw, 46rem); }
:root:has(dialog.sheet.pf-sheet[open]) { --sheet-w: min(96vw, 48rem); }
@media (min-width: 768px) {
  :root:has(dialog.sheet[open]) .ie-toasts { right: calc(var(--sheet-w) + 1.5rem); width: max(14rem, min(22.5rem, calc(100vw - var(--sheet-w) - 3rem))); }
}
@media (max-width: 767px) {
  :root:has(dialog.sheet[open]) .ie-toasts { inset: calc(env(safe-area-inset-top, 0px) + 0.5rem) 1rem auto 1rem; width: auto; flex-direction: column-reverse; }
}

/* one toast: a raised card with a line icon, the message, an optional action and a close button.
   The page scripts' own #toast element gets the same look, inside the region or (without ui.js) on its own. */
.ie-toast, #toast {
  box-sizing: border-box;
  display: flex; align-items: flex-start; gap: 0.625rem;
  width: 100%; max-width: 100%; min-height: 2.75rem;
  margin: 0;
  padding: 0.6875rem 0.5rem 0.6875rem 0.875rem;
  border: 0; border-radius: var(--radius, 0.75rem);
  background: var(--ie-toast-bg); color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--ie-toast-edge), var(--shadow-pop, 0 8px 24px -8px rgba(0, 0, 0, 0.14), 0 0 0 1px var(--ring));
  font-size: var(--fs-body, 0.875rem); line-height: 1.45; font-weight: 500; letter-spacing: 0;
  text-align: left; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: opacity 200ms var(--ease-out, ease-out), transform 200ms var(--ease-out, ease-out);
  @starting-style { opacity: 0; transform: translateY(0.5rem); }
}
.ie-toasts > #toast { position: static; inset: auto; z-index: auto; width: 100%; max-width: 100%; order: 1; }   /* shown last = the newest */
#toast > span:first-child { flex: 1 1 auto; min-width: 0; padding-top: 0.0625rem; text-wrap: pretty; overflow-wrap: anywhere; }
.ie-toast-msg { flex: 1 1 auto; min-width: 0; padding-top: 0.0625rem; text-wrap: pretty; overflow-wrap: anywhere; }
.ie-toast-icon { flex: 0 0 auto; width: 1.125rem; height: 1.125rem; margin-top: 0.125rem; color: var(--text-2, var(--muted)); }
.ie-toast[data-tone="ok"] .ie-toast-icon { color: var(--ok-fg); }
.ie-toast[data-tone="error"] .ie-toast-icon { color: var(--bad-fg); }
.ie-toast-action, #toast .btn {
  flex: 0 0 auto; align-self: flex-start;
  height: 1.75rem; min-height: 1.75rem; margin: -0.0625rem 0 -0.0625rem 0.25rem; padding: 0 0.625rem;
  border: 0; border-radius: var(--radius-s, 0.5rem); box-shadow: none;
  background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg);
  font: inherit; font-size: var(--fs-btn-sm, 0.8125rem); font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms ease, transform 100ms var(--ease-out, ease-out);
}
.ie-toast-x {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem; min-height: 0; margin: -0.0625rem 0; padding: 0;
  border: 0; border-radius: var(--radius-s, 0.5rem); background: transparent; color: var(--muted);
  cursor: pointer; transition: background-color 120ms ease, color 120ms ease;
}
.ie-toast-x svg { width: 1rem; height: 1rem; }
.ie-toast-action:active, #toast .btn:active, .ie-toast-x:active { transform: scale(0.96); transition-duration: 0s; }
.ie-toast-action:focus-visible, #toast .btn:focus-visible, .ie-toast-x:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px var(--fg)); }
@media (hover: hover) and (pointer: fine) {
  .ie-toast-action:hover, #toast .btn:hover { background: color-mix(in srgb, var(--fg) 14%, transparent); }
  .ie-toast-x:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
}
@media (pointer: coarse) {
  .ie-toast-action, #toast .btn { height: 2rem; min-height: 2rem; margin-top: -0.1875rem; margin-bottom: -0.1875rem; }
  .ie-toast-x { width: 2rem; height: 2rem; margin-top: -0.1875rem; margin-bottom: -0.1875rem; }
}
/* leaving along the path it came in; following the finger while dragged; a small bump when repeated */
.ie-toast.ie-leave { opacity: 0; transform: translateY(0.5rem); transition-duration: 150ms; transition-timing-function: ease-in; }
.ie-toast.ie-dragging { transition: none; }
.ie-toast.ie-flung { transition: transform 180ms var(--ease-out, ease-out), opacity 180ms ease; }
.ie-toast.ie-bump { animation: ie-bump 240ms var(--ease-out, ease-out); }
@keyframes ie-bump { from { transform: scale(0.97); } to { transform: none; } }
@media (max-width: 639px) {
  .ie-toast, #toast { width: 100%; @starting-style { opacity: 0; transform: translateY(-0.5rem); } }
  .ie-toast.ie-leave { transform: translateY(-0.5rem); }
  /* without ui.js the page's own toast still sits under the top bar */
  #toast { position: fixed; inset: calc(3.5rem + env(safe-area-inset-top, 0px) + 0.5rem) 1rem auto 1rem; width: auto; z-index: var(--z-toast, 100); }
}
@media (min-width: 640px) {
  #toast { position: fixed; inset: auto max(1.5rem, env(safe-area-inset-right, 0px)) calc(1.5rem + env(safe-area-inset-bottom, 0px)) auto; width: min(22.5rem, calc(100vw - 2rem)); z-index: var(--z-toast, 100); }
}
@media (prefers-reduced-motion: reduce) {
  .ie-toast, #toast { transition: opacity 150ms ease; @starting-style { opacity: 0; transform: none; } }
  .ie-toast.ie-leave { transform: none; }
  .ie-toast.ie-bump { animation: none; }
}
@media (prefers-contrast: more) { .ie-toast, #toast { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-pop, none); } }

/* ============================================================== Questions: IEConfirm, IEAlert, IEPrompt, IEChoose
   On dialog.dlg (app.css: centred from 768px, a bottom sheet below, padding, radius, shadow, backdrop). */
dialog.dlg.ie-ask[open] { display: block; }
.ie-ask-form { display: block; margin: 0; }
.ie-ask-title {
  margin: 0; padding: 0;
  font-size: var(--fs-dialog, 1.0625rem); line-height: var(--lh-dialog, 1.4); font-weight: 600; letter-spacing: var(--ls-dialog, -0.015em);
  color: var(--fg); text-wrap: balance;
}
.ie-ask-body { margin-top: 0.5rem; color: var(--text-2, var(--muted)); font-size: var(--fs-body, 0.875rem); line-height: var(--lh-body, 1.5); overflow-wrap: anywhere; }
.ie-ask-body p { margin: 0; text-wrap: pretty; }
.ie-ask-body p + p { margin-top: 0.5rem; }
.ie-ask-fields { display: grid; gap: 0.875rem; margin-top: 1.125rem; }
.ie-ask-field { margin: 0; }
.ie-ask-field textarea { resize: vertical; min-height: 4.5rem; }
.ie-ask-error { margin: 0; color: var(--bad-fg); font-size: var(--fs-meta, 0.8125rem); line-height: var(--lh-meta, 1.45); }
.ie-ask-actions { margin-top: 1.5rem; }
.ie-ask-actions.ie-ask-stack { flex-direction: column-reverse; align-items: stretch; }
.ie-ask-actions.ie-ask-stack .btn { width: 100%; flex: 0 0 auto; }
@media (max-width: 767px) {
  dialog.dlg.ie-ask { padding-top: 1.5rem; }
  .ie-ask-title, .ie-ask-body { text-align: left; }
}
@media (max-width: 639px) {
  .ie-ask-actions { margin-top: 1.25rem; }
  .ie-ask-actions:not(.ie-ask-stack) .btn { flex: 1 1 0; }
}

/* ============================================================== IEMore: "10 nga 124 · Shfaq 10 të tjera" */
.ie-more-hide { display: none !important; }
.ie-more {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  font-size: var(--fs-meta, 0.8125rem); line-height: var(--lh-meta, 1.45); color: var(--muted);
}
.ie-more-count { font-variant-numeric: tabular-nums; }
.ie-more-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin-left: auto; }
.ie-more-btn {
  height: var(--h-btn-sm, 2rem); padding: 0 0.75rem;
  border: 0; border-radius: var(--radius-s, 0.5rem); background: transparent; color: var(--fg);
  font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms ease, transform 100ms var(--ease-out, ease-out);
}
.ie-more-btn.ie-more-main { background: var(--panel-2); }
.ie-more-btn:active { transform: scale(0.97); transition-duration: 0s; }
.ie-more-btn:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px var(--fg)); }
@media (pointer: coarse) { .ie-more-btn { height: 2.75rem; } }
@media (hover: hover) and (pointer: fine) {
  .ie-more-btn:hover { background: var(--panel-2); }
  .ie-more-btn.ie-more-main:hover { background: color-mix(in srgb, var(--fg) 8%, var(--panel-2)); }
}
/* phone: the count and the quiet links on one line, the next rows as one wide key under them */
@media (max-width: 639px) {
  .ie-more { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.5rem 0.25rem; }
  .ie-more-actions { display: contents; }
  .ie-more-count { grid-column: 1; grid-row: 1; }
  .ie-more-btn[data-k="less"] { grid-column: 2; grid-row: 1; }
  .ie-more-btn[data-k="all"] { grid-column: 3; grid-row: 1; }
  .ie-more-btn { padding: 0 0.5rem; }
  .ie-more-btn.ie-more-main { grid-column: 1 / -1; grid-row: 2; width: 100%; height: max(var(--h-btn, 2.5rem), 2.75rem); }
}

/* ============================================================== The pager (pager.js); replaces the v3.43.4 look in
   app.css: one static line under the list, never floating over the rows. */
.pager, .pager.stuck {
  position: static; inset: auto; z-index: auto;
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  width: auto; max-width: none; margin: 0.75rem 0 0; padding: 0;
  border: 0; border-radius: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  font-size: var(--fs-meta, 0.8125rem); line-height: var(--lh-meta, 1.45); color: var(--text-2, var(--muted));
  font-variant-numeric: tabular-nums;
  transition: opacity 150ms ease;
}
.pager.loading { opacity: 0.55; }
.pager-range { margin: 0; padding: 0; white-space: nowrap; color: var(--text-2, var(--muted)); font-weight: 500; }
.pager-of { color: var(--muted); font-weight: 400; }
.pager-controls { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.pager-size {
  height: var(--h-toolbar, 2rem); min-height: 0; width: auto; margin: 0; padding: 0 1.75rem 0 0.625rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s, 0.5rem); box-shadow: none;
  -webkit-appearance: none; appearance: none;
  background: var(--field-bg, var(--panel)) var(--icon-chevron, none) no-repeat right 0.5rem center / 1rem 1rem;
  color: var(--fg); font: inherit; font-weight: 500; cursor: pointer;
}
.pager-steps { display: flex; align-items: center; gap: 0.125rem; }
.pager-nums { display: flex; align-items: center; gap: 0.125rem; }
.pager-step, .pager-num {
  display: grid; place-items: center;
  height: 2rem; min-width: 2rem; min-height: 0; margin: 0; padding: 0 0.375rem;
  border: 0; border-radius: var(--radius-s, 0.5rem); background: transparent; box-shadow: none;
  color: var(--text-2, var(--muted)); font: inherit; font-weight: 500; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 100ms var(--ease-out, ease-out);
}
.pager-step svg { width: 1rem; height: 1rem; }
.pager-step:disabled { opacity: 0.35; cursor: default; }
.pager-num[aria-current="page"] { background: var(--panel-2); color: var(--fg); font-weight: 600; box-shadow: none; border: 0; }
.pager-step:active:not(:disabled), .pager-num:active { transform: scale(0.95); transition-duration: 0s; }
.pager-gap { width: 1.25rem; text-align: center; color: var(--muted); }
.pager-compact { display: none; }
.pager-jumpbox { display: inline-flex; align-items: center; gap: 0.375rem; margin: 0 0 0 0.25rem; white-space: nowrap; color: var(--muted); font-size: inherit; font-weight: 400; }
.pager-jump {
  width: 2.75rem; height: var(--h-toolbar, 2rem); min-height: 0; margin: 0; padding: 0 0.25rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s, 0.5rem); background: var(--field-bg, var(--panel)); box-shadow: none;
  color: var(--fg); font: inherit; font-variant-numeric: tabular-nums; text-align: center;
}
.pager-jump[aria-invalid="true"] { border-color: var(--bad-fg); }
.pager-size:focus-visible, .pager-jump:focus-visible, .pager-jump:focus { outline: none; border-color: var(--fg); box-shadow: var(--input-ring, 0 0 0 3px color-mix(in srgb, var(--fg) 10%, transparent)); }
.pager-step:focus-visible, .pager-num:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px var(--fg)); }
@media (hover: hover) and (pointer: fine) {
  .pager-step:not(:disabled):hover, .pager-num:not([aria-current]):hover { background: var(--panel-2); color: var(--fg); }
  .pager-size:hover { border-color: color-mix(in srgb, var(--fg) 25%, var(--line-strong)); }
}
/* touch: 40px targets, 16px text in the fields (no zoom on iOS) */
@media (pointer: coarse) {
  .pager-step, .pager-num { height: 2.75rem; min-width: 2.75rem; }
  .pager-size, .pager-jump { height: 2.5rem; font-size: 1rem; }
}
/* phone: "1–10 nga 45"  ‹ 2 / 5 › on one line */
@media (max-width: 639px) {
  .pager, .pager.stuck { gap: 0.5rem; flex-wrap: wrap; }   /* at a larger text size the steps go under the range */
  .pager-controls { margin-left: auto; }
  .pager-size, .pager-nums, .pager-jumpbox, .pager-gap { display: none; }
  .pager-compact { display: inline-block; min-width: 3.5rem; text-align: center; color: var(--fg); font-weight: 500; }
}

/* ============================================================== IEMenu: "⋯" and its menu (the .menu look of app.css),
   in the top layer so a table's scroll box never clips it; placed by ui.js from the button's corner */
.ie-menu { display: inline-flex; position: relative; vertical-align: middle; }
.ie-menu-btn { color: var(--muted); }
/* touch screens: the row menus are 44px everywhere */
@media (pointer: coarse) { .ie-menu-btn { width: 2.75rem; min-width: 2.75rem; height: 2.75rem; min-height: 2.75rem; } }
.ie-menu-btn[aria-expanded="true"] { background: var(--panel-2); color: var(--fg); }
@media (hover: hover) and (pointer: fine) { .ie-menu-btn:hover { color: var(--fg); } }
.menu.ie-menu-pop { position: fixed; inset: auto; right: auto; margin: 0; min-width: 12rem; max-width: min(18rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); overflow-y: auto; color: var(--fg); text-align: left; white-space: nowrap; }
.menu.ie-menu-pop[popover]:not(:popover-open), .menu.ie-menu-pop[hidden] { display: none; }
.menu.ie-menu-pop:popover-open { opacity: 1; transform: none; transition: opacity 150ms var(--ease-out, ease-out), transform 150ms var(--ease-out, ease-out); @starting-style { opacity: 0; transform: scale(0.96); } }
.menu.ie-menu-pop:focus { outline: none; }
.ie-menu-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; text-decoration: none; color: inherit; cursor: pointer; }
.ie-menu-item[aria-disabled="true"] { color: var(--faint, var(--muted)); cursor: default; }
.ie-menu-sep { height: 1px; margin: 0.25rem -0.375rem; background: var(--line); }
@media (prefers-reduced-motion: reduce) { .menu.ie-menu-pop:popover-open { @starting-style { transform: none; } } }
/* phone cards: a lone "⋯" sits at the card's top right, beside its title */
@media (max-width: 639px) {
  table:not(.table-custom-phone) > tbody > tr > td:is(.actions, .actions-cell, .cell-actions):has(> .ie-menu:only-child) { position: absolute; top: 0.375rem; right: 0.375rem; display: block; grid-column: auto; }
  table:not(.table-custom-phone) > tbody > tr:has(> td:is(.actions, .actions-cell, .cell-actions) > .ie-menu:only-child) > td.head { padding-right: 2.5rem; }
}

/* ============================================================== IEProgress (v3.56): "16 nga 24 m³ të hedhura"
   The one bar of an order's progress on every page: the figure quiet above a thin bar; neutral before the pour,
   blue (--info-fg) while the order runs, green (--ok-fg) once it is done. .ie-prog-bare keeps the bar alone. */
.ie-prog { display: grid; gap: 0.3125rem; min-width: 0; font-size: var(--fs-meta, 0.8125rem); line-height: var(--lh-meta, 1.45); color: var(--muted); font-variant-numeric: tabular-nums; }
.ie-prog-text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.625rem; min-width: 0; }
.ie-prog-m3 { white-space: nowrap; }
.ie-prog-n { color: var(--fg); font-weight: 600; }
.ie-prog-sub { white-space: nowrap; }
.ie-prog-sub[hidden] { display: none; }
.ie-prog-bar { display: block; height: 0.375rem; border-radius: 999px; background: var(--panel-2, #F2F2F3); overflow: hidden; }
.ie-prog-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--fg); transition: width 400ms var(--ease-out, ease-out); }
.ie-prog.is-running .ie-prog-fill { background: var(--info-fg, #1D4ED8); }
.ie-prog.is-done .ie-prog-fill { background: var(--ok-fg, #15803D); }
.ie-prog.is-done .ie-prog-n { color: var(--ok-fg, #15803D); }
.ie-prog-bare .ie-prog-text { display: none; }
.ie-prog-sm .ie-prog-bar { height: 0.25rem; }
@media (prefers-reduced-motion: reduce) { .ie-prog-fill { transition: none; } }
@media print { .ie-prog-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; } }

@media print {
  .ie-toasts, .ie-more, .pager, #toast, .ie-menu { display: none !important; }
  .ie-more-hide { display: revert !important; }
}
