/* styles.css — Screen A (responsive admin panel). agent1. */
.app-a { min-height: 100vh; }

/* Login gate */
.login-gate {
  min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4);
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
}
.login-box { width: min(420px, 100%); text-align: center; }
.login-box .logo { width: 72px; height: 72px; margin: 0 auto var(--sp-3); }
.login-box .field { text-align: start; }

/* Shell layout */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand-700); color: #fff; padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; padding: 4px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: #dbeef1; font: inherit; font-weight: 600;
  cursor: pointer; text-align: start; position: relative;
}
.nav-item > :first-child { font-size: 1.15rem; }
.nav-item span:nth-child(2) { flex: 1; }
.nav-item:hover { background: rgba(255,255,255,.10); }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; }
.nav-item .count-badge { position: static; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.section-title { font-size: 1.2rem; margin: 0; }
.icon-btn2 { display: none; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  width: 42px; height: 42px; font-size: 1.2rem; cursor: pointer; }
.content { padding: var(--sp-5); }

/* Section helpers */
.section-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* --- breakpoints ---------------------------------------------------------
 * Screen A had exactly one (860px): phone-drawer or full desktop, nothing in
 * between and nothing above. The three rules below cover what phase 7 measured.
 *
 * The grids need their OWN breakpoint because the shared ones in base.css only
 * know the window width, while here the sidebar permanently eats 260px. At a
 * 1024px iPad the content box is 749px, so a `.grid-4` was drawing 163px tiles —
 * wide enough for the number and not for the Arabic label under it.
 */
@media (min-width: 861px) and (max-width: 1150px) {
  .app-a .grid-4, .app-a .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Very wide screens: cap the measure. Text set across 2237px is not a layout,
   it is a stretch — a card ran the full width of a 2560px TV. Tables and charts
   keep the room they need inside the capped column. */
@media (min-width: 1800px) {
  .content { max-width: 1560px; margin-inline: auto; width: 100%; }
}

/* Mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  /*
   * The closed drawer is parked outside the viewport with translateX(110%),
   * and a transform still counts towards scrollable overflow — so on a phone
   * every section of Screen A carried ~40px of sideways scroll with nothing in
   * it, in RTL and LTR alike. Found at 360px while checking the reports page.
   *
   * `clip`, not `hidden`, on purpose: `hidden` would make .shell a scroll
   * container and the sticky topbar inside it would start sticking to the
   * wrong thing. `clip` cuts the overflow without creating one.
   */
  .shell { overflow-x: clip; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 200;
    transform: translateX(-110%); transition: transform .25s ease;
  }
  /*
   * ONLY the transform flips for RTL — `translateX` is physical, so the drawer
   * has to be pushed the other way to leave the screen. The INSET must not
   * flip: `inset-inline-start` is already logical and resolves to the right
   * edge in RTL by itself.
   *
   * This rule used to also set `inset-inline-start: auto; inset-inline-end: 0`,
   * meaning to "pin it to the right" — but in RTL the inline END is the LEFT
   * side, so it pinned the drawer to the left and then pushed it 286px right.
   * Two visible bugs came out of that on every Arabic phone: closed, a 74px
   * teal strip sat over the right edge of every page and cut off the section
   * title; open, the drawer slid in from the LEFT while the button that opens
   * it is on the right. Found in a screenshot at 360px — the geometry reads
   * looked plausible right up until the page was actually rendered.
   */
  [dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open { transform: none; }
  .icon-btn2 { display: inline-flex; align-items: center; justify-content: center; }
  .content { padding: var(--sp-4); }
}
.scrim { position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 150; }

/* --- users: temporary password + permission matrix ---------------------- */
.temp-pass {
  font-size: 1.5rem; font-weight: 700; letter-spacing: 4px;
  padding: 12px 20px; margin: 10px auto; display: inline-block;
  border-radius: var(--r-2); background: var(--surface-2);
  border: 1px dashed var(--brand-600); color: var(--brand-700);
}
.perm-list { display: grid; gap: 6px; margin-top: 10px; max-height: 46vh; overflow-y: auto; }
.perm-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 8px 10px; border-radius: var(--r-2); background: var(--surface-2);
}
.perm-row:hover { background: var(--surface-3, var(--surface-2)); }
.perm-row input { inline-size: 18px; block-size: 18px; accent-color: var(--brand-600); }
.perm-row span { flex: 1; }

/* --- reports ------------------------------------------------------------ */
/* The third line of a KPI tile: what the number was measured over. A tile that
   shows an average without saying how many requests produced it invites the
   reader to trust one data point as much as a hundred. */
.stat .s { margin-top: 4px; line-height: 1.35; }
.stat .n { line-height: 1.15; }

.rep-chart { width: 100%; height: auto; display: block; }

/* Proportion bar inside a table cell. Width is the only thing that carries the
   value, so it stays readable when the colour does not print. */
.rep-bar-cell { width: 42%; min-width: 90px; }
.rep-bar {
  display: block; height: 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); overflow: hidden;
}
.rep-bar > i { display: block; height: 100%; border-radius: var(--radius-pill); }

.rep-controls .field label { font-size: .8rem; }
.rep-controls .row { gap: var(--sp-3); }

/* The QR keeps its white background and quiet zone in both themes — a scanner
   needs the contrast, and a dark card behind a transparent code kills it. */
.qr-holder { display: inline-block; background: #fff; padding: 10px; border-radius: 10px; margin: 8px 0; }
.qr-holder svg { display: block; }

/* A request past its SLA deadline. Deliberately not a colour change on the
   status pill: the status is still "accepted" and saying otherwise would be a
   lie. Lateness is a second, separate fact about the same request. */
.sla-late {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: .72rem; font-weight: 700; padding: 2px 8px; margin-inline-start: 6px;
  border-radius: var(--radius-pill); background: var(--danger); color: #fff;
}

/* On a phone the proportion bar is redundant — the percentage is already a
   number in the column beside it — and keeping it forced the status table into
   a sideways scroll. Dropping it is better than scrolling to read it. */
@media (max-width: 560px) {
  .rep-bar-cell { display: none; }
}
