/* Ajialuna Staff - the Family Service Desk screens (the approved design's list and request).
   Tokens only (tokens.css). Logical properties only, so one rule serves Arabic (rtl) and English (ltr).
   What the design system already has (buttons, chips, fields, alerts, the table) is used from components.css. */

.aj-hint { margin: 0; font: var(--text-caption); color: var(--ink-muted); }
.aj-empty { margin: 0; padding: var(--space-6); text-align: center; color: var(--ink-muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.aj-main .aj-alert { max-width: none; }

/* ── The box "what needs you now" ─────────────────────────────────────── */
.aj-attn { gap: var(--space-4); }
.aj-attn-title { margin: 0; font: var(--text-title); }
.aj-attn-line { margin: 0; font: var(--text-body-strong); }
.aj-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.aj-tile {
  display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4);
  border-radius: var(--radius-md); border: 1px solid transparent; text-decoration: none;
}
.aj-root a.aj-tile { color: var(--ink); }
.aj-tile-num { align-self: flex-start; font: 500 32px/44px var(--font-mono); }
.aj-tile-label { font: var(--text-label); }
.aj-tile--waiting { background: var(--warning-tint); }
.aj-tile--waiting .aj-tile-num, .aj-tile--waiting .aj-tile-label { color: var(--warning-ink); }
.aj-root a.aj-tile--overdue { background: var(--danger); color: var(--on-danger); }
.aj-tile--overdue .aj-tile-label { font-weight: 600; }
.aj-tile--progress { background: var(--brand-tint); }
.aj-tile--progress .aj-tile-num, .aj-tile--progress .aj-tile-label { color: var(--brand-strong); }
.aj-tile--quiet { background: var(--surface-sunken); border-color: var(--line); }
.aj-tile--quiet .aj-tile-num, .aj-tile--quiet .aj-tile-label { color: var(--ink-muted); }
.aj-tile:hover { border-color: var(--line-strong); }
.aj-tile[aria-current="page"] { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── The bar over the list ────────────────────────────────────────────── */
.aj-desk-list { display: flex; flex-direction: column; gap: var(--space-4); }
.aj-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.aj-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); flex-grow: 1; }
.aj-filters .aj-btn, .aj-pager .aj-btn { min-height: var(--tap-min); }
.aj-search { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 280px; max-width: 420px; margin: 0; }
.aj-search-row { display: flex; gap: var(--space-2); }
.aj-search-row .aj-input { min-height: var(--tap-min); }
.aj-export { margin: 0; }
.aj-filter-note { margin: 0; font: var(--text-label); }

/* The parent's signal on the WhatsApp follow-up («تم حل المشكلة» / «إلغاء الطلب»): information, never a status. */
.aj-chip--signal { background: var(--success-tint); color: var(--success-ink); }

/* ── The list: a table on a desk, cards on a phone ────────────────────── */
.aj-desk-table .aj-table { min-width: 920px; }
.aj-desk-table td:first-child .aj-cell-sub { text-align: end; }
.aj-reqcards { display: none; margin: 0; padding: 0; list-style: none; flex-direction: column; gap: var(--space-3); }
.aj-reqcard {
  display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); text-decoration: none;
}
.aj-root a.aj-reqcard { color: var(--ink); }
.aj-reqcard--overdue { border-color: var(--danger); }
.aj-reqcard-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.aj-reqcard-id { font-weight: 600; color: var(--brand-strong); }
.aj-reqcard-student { display: flex; flex-direction: column; }
.aj-reqcard-kind { font: var(--text-label); font-weight: 400; }
.aj-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.aj-pager-summary { font: var(--text-label); font-weight: 400; color: var(--ink-muted); }
.aj-btn[aria-disabled="true"] { pointer-events: none; }

/* ── One request ──────────────────────────────────────────────────────── */
.aj-back { align-self: flex-start; display: inline-flex; align-items: center; min-height: var(--tap-min); font: var(--text-label); text-decoration: none; }
.aj-case-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.aj-case { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-6); }
.aj-case-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-6); }
.aj-case-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-6); }
.aj-case-facts { display: flex; flex-direction: column; gap: var(--space-6); }
.aj-msg { padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); white-space: pre-line; overflow-wrap: anywhere; }
.aj-msg:empty { display: none; }
.aj-reply { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.aj-reply textarea.aj-input { min-height: 128px; }
.aj-reply-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.aj-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-3); }
.aj-action { flex: 0 1 auto; }
.aj-action[open] { flex-basis: 100%; }
.aj-action > summary { list-style: none; min-height: var(--tap-min); }
.aj-action > summary::-webkit-details-marker { display: none; }
.aj-action[open] > summary { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-strong); }
.aj-action-form {
  display: flex; flex-direction: column; gap: var(--space-3); margin-block-start: var(--space-3);
  padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface);
}
.aj-action-form .aj-btn { align-self: flex-start; }
.aj-dl--stack { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
.aj-dl--stack > div { display: flex; flex-direction: column; }
.aj-card--tint { background: var(--brand-tint); border-color: transparent; padding: var(--space-4); gap: var(--space-1); }
.aj-others-title { margin: 0; font: var(--text-label); font-weight: 600; color: var(--brand-strong); }
.aj-others { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.aj-others li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); font: var(--text-label); font-weight: 400; }
.aj-timeline { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.aj-timeline li { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); padding-block: var(--space-3); }
.aj-timeline li + li { border-block-start: 1px solid var(--line); }
.aj-timeline-when { flex: 0 0 150px; font: var(--text-data); color: var(--ink-muted); text-align: end; }
.aj-timeline-what { flex: 1 1 240px; display: flex; flex-direction: column; }
.aj-timeline-what .aj-cell-main { font-weight: 500; }
.aj-timeline-what .aj-cell-sub { font: var(--text-caption); color: var(--ink-muted); }
.aj-timeline-body { padding-block: var(--space-1); white-space: pre-line; overflow-wrap: anywhere; }
.aj-sms-banner form { margin: 0; }
.aj-contact-note > summary { cursor: pointer; padding-block: var(--space-2); }
.aj-contact-note .aj-field { margin-block-start: var(--space-2); }
.aj-case-surveys > details > summary, .aj-case-smslog > details > summary { cursor: pointer; list-style-position: inside; }
.aj-case-surveys > details > summary .aj-h2, .aj-case-smslog > details > summary .aj-h2 { display: inline; }
.aj-case-surveys .aj-table-wrap, .aj-case-smslog .aj-table-wrap { margin-block-start: var(--space-4); }
.aj-case-surveys .aj-hint, .aj-case-smslog .aj-hint { margin-block-start: var(--space-3); }

/* ── Phone (the phone artboards, about 390 px) ────────────────────────── */
@media (max-width: 640px) {
  .aj-attn-title { font: var(--text-heading); }
  .aj-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .aj-tile { padding: var(--space-3); }
  .aj-search { max-width: none; flex-basis: 100%; }
  .aj-desk-table { display: none; }
  .aj-reqcards { display: flex; }
  .aj-pager .aj-btn-row { flex-grow: 1; }
  .aj-pager .aj-btn-row .aj-btn { flex: 1 1 0; }

  /* One column, in the phone artboard's order: target, message, reply, actions, details and others, timeline,
     then the surveys and the SMS log. The two wrappers step aside; the details' landmark (aside) keeps its box. */
  .aj-case { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: var(--space-4); }
  .aj-case-main, .aj-case-side { display: contents; }
  .aj-case-facts { gap: var(--space-4); }
  .aj-case-target { order: 1; }
  .aj-case-message { order: 2; }
  .aj-case-reply { order: 3; }
  .aj-case-actions { order: 4; }
  .aj-case-facts { order: 5; }
  .aj-case-timeline { order: 7; }
  .aj-case-surveys { order: 8; }
  .aj-case-smslog { order: 9; }
  .aj-reply-buttons { flex-direction: column; align-items: stretch; }
  .aj-reply-buttons .aj-btn { width: 100%; }
  .aj-dl--stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aj-timeline li { flex-direction: column; }
  .aj-timeline-when { flex-basis: auto; font: var(--text-caption); font-family: var(--font-mono); }
}
