/* wagw panel. No external font, image, or stylesheet: everything is served from this server (criterion 11).
   Designed for a phone first; right-to-left in Arabic through the dir attribute and logical properties. */

@font-face {
    font-family: "Noto Sans Arabic";
    src: url("/assets/fonts/NotoSansArabic-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Noto Sans Arabic";
    src: url("/assets/fonts/NotoSansArabic-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

:root {
    --ink: #1c2330;
    --muted: #5d6675;
    --line: #d9dee6;
    --surface: #ffffff;
    --page: #f3f5f8;
    --accent: #0f766e;
    --accent-dark: #0b5a54;
    --accent-ink: #ffffff;
    --ok: #166534;
    --ok-bg: #dcfce7;
    --warn: #92400e;
    --warn-bg: #fef3c7;
    --bad: #991b1b;
    --bad-bg: #fee2e2;
    --info: #1e3a8a;
    --info-bg: #dbeafe;
    --radius: .6rem;
}

* { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    /* Arabic in the platform's own font; Latin letters and digits in the device's own. */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, Arial, sans-serif;
    line-height: 1.7;
}

:lang(ar) body, body:lang(ar) { font-family: "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif; }

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* The bar at the top: the platform, the school, the menu, the language, and logging out. */
.topbar {
    background: var(--surface);
    border-block-end: 1px solid var(--line);
}

.topbar-inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: .5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
}

.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; line-height: 1.3; }

.topbar .spacer { flex: 1; }

.topbar form { margin: 0; }
.topbar button { margin: 0; padding: .3rem .8rem; font-size: .9rem; }

.lang-switch { font-size: .9rem; }

/* On a phone the menu wraps onto a second line rather than hiding items off the edge. */
.nav {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0 .5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0 .25rem;
}

.nav a {
    flex: none;
    padding: .55rem .75rem;
    border-block-end: 3px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.nav a[aria-current="page"] { color: var(--accent); border-block-end-color: var(--accent); }

.page {
    max-width: 64rem;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

.page.narrow { max-width: 28rem; }

.page-header h1 { margin: .5rem 0 .25rem; font-size: 1.5rem; line-height: 1.4; }
.page-header p { margin: 0 0 .5rem; color: var(--muted); }

h2 { margin: 0 0 .75rem; font-size: 1.1rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-block: 1rem;
}

.card.success { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }

.columns { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }

/* Forms: one field under the other, big enough for a thumb. */
label { display: block; margin-block: .75rem .25rem; font-weight: 600; }

input, select, textarea {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

textarea { min-height: 7rem; resize: vertical; }

input[type="checkbox"], input[type="radio"] { width: auto; margin-inline-end: .4rem; }

.code-input { font-size: 1.6rem; letter-spacing: .3em; text-align: center; direction: ltr; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

button, a.button {
    display: inline-block;
    margin-block-start: .9rem;
    padding: .65rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

button.primary, a.button.primary, a.button { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, a.button:hover { background: var(--accent-dark); color: var(--accent-ink); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { margin: 0; padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; font-weight: 400; }
button.wide, a.button.wide { width: 100%; text-align: center; }
button:disabled { opacity: .55; cursor: progress; }
/* A choice that is not available yet, such as the assistant's rule before the assistant is on. */
span.button.disabled {
    display: inline-block;
    margin-block-start: .9rem;
    padding: .65rem 1.2rem;
    border: 1px dashed var(--line);
    border-radius: .5rem;
    color: var(--muted);
    font-weight: 600;
    cursor: not-allowed;
}

.help { margin: .35rem 0 0; color: var(--muted); font-size: .92rem; }

/* Messages above a form or a page. */
.alert { margin-block: 1rem; padding: .75rem 1rem; border-radius: .5rem; border: 1px solid transparent; }
.alert.bad, .message { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.message { margin-block: 1rem; padding: .75rem 1rem; border-radius: .5rem; }

.notice {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: .5rem;
    background: var(--warn-bg);
    color: var(--warn);
    font-size: .9rem;
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: .1rem .7rem; border-radius: 1rem; background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: .9rem; }
.badge[data-state="connected"], .badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge[data-state="banned"], .badge[data-state="logged_out"], .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--page); color: var(--muted); }

/* Tables scroll sideways on a phone instead of breaking the page. */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .55rem .6rem; border-block-end: 1px solid var(--line); text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }

/* Numbers, ids, keys, and codes read left to right inside Arabic text. */
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.secret {
    display: block;
    margin-block: .5rem;
    padding: .6rem .75rem;
    border: 1px dashed var(--accent);
    border-radius: .5rem;
    background: #fff;
    direction: ltr;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
    user-select: all;
}

.qr {
    display: block;
    width: 100%;
    max-width: 264px;
    height: auto;
    margin: 1rem auto .5rem;
    padding: .5rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: .5rem;
    image-rendering: pixelated;
}

.qr svg { display: block; width: 100%; height: auto; }

.code {
    margin: 1rem 0 0;
    padding: .75rem;
    border: 2px dashed var(--accent);
    border-radius: .5rem;
    text-align: center;
    direction: ltr;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: .2em;
}

.steps { margin: 0; padding-inline-start: 1.25rem; }
.steps li { margin-block: .35rem; }

[hidden] { display: none !important; }

/* An error page of the panel (D099). */
.error-page { max-width: 32rem; margin: 3rem auto; text-align: center; }
.error-page .error-status { margin: 0; font-size: 2.5rem; font-weight: 700; color: var(--muted); }
.muted { color: var(--muted); }

@media (min-width: 48rem) {
    .page { padding-top: 1.5rem; }
    .page-header h1 { font-size: 1.7rem; }
}

/* The numbers list (D100). */
.number-list { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.number-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-block-end: .5rem; }
.number-head h2 { margin: 0; }
.actions { margin: .75rem 0 0; }

/* A number's page (D100). */
.health-events { margin: 0; padding-inline-start: 1.1rem; }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--bad); }
.danger-zone label { font-weight: 400; }

/* The messages list (D101). */
.filter-grid { display: grid; gap: 0 .75rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.filters .export { margin-inline-start: 1rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; }
.badge.status-delivered, .badge.status-read, .badge.status-received { background: var(--ok-bg); color: var(--ok); }
.badge.status-failed { background: var(--bad-bg); color: var(--bad); }
.badge.status-queued, .badge.status-sending, .badge.status-sent { background: var(--info-bg); color: var(--info); }

/* A message's page (D101). */
.message-text { white-space: normal; overflow-wrap: anywhere; background: var(--page); border-radius: .5rem; padding: .75rem 1rem; }
.timeline { margin: 0; padding-inline-start: 1.25rem; }
.timeline li { margin-block: .35rem; }

/* Templates (D103). */
.chip { display: inline-block; padding: 0 .5rem; border-radius: 1rem; background: var(--info-bg); color: var(--info); font-size: .9rem; }

/* Webhooks (D104). */
.badge.webhook-active { background: var(--ok-bg); color: var(--ok); }
.badge.webhook-failing { background: var(--bad-bg); color: var(--bad); }
.badge.webhook-disabled { background: var(--page); color: var(--muted); }
.kinds { border: 0; padding: 0; margin: .75rem 0 0; }
.kinds legend { font-weight: 600; padding: 0; margin-block-end: .25rem; }
.kinds label { font-weight: 400; margin-block: .25rem; }

/* Usage (D106). */
.big-number { margin: .25rem 0; font-size: 2rem; font-weight: 700; }

/* The admin incidents page (D107). */
.badge.severity-critical { background: var(--bad-bg); color: var(--bad); }
.badge.severity-warning { background: var(--warn-bg); color: var(--warn); }
.badge.severity-info { background: var(--info-bg); color: var(--info); }

/* The owners' link to deleting the school's data, out of the way at the foot of every page (D121). */
.footer { max-width: 72rem; margin: 2rem auto 1.5rem; padding: 0 1rem; text-align: center; font-size: 0.875rem; }
.footer a { color: var(--bad); }

/* The admin's health and security pages (A4, D141): one line per check, its level in words as well as colour. */
.check-list { list-style: none; margin: 0; padding: 0; }
.check { display: flex; gap: .75rem; align-items: baseline; padding-block: .5rem; border-block-end: 1px solid var(--line); }
.check:last-child { border-block-end: 0; }
.check > .badge { flex: none; min-inline-size: 6rem; text-align: center; }
.check .hint { display: block; margin-block-start: .25rem; color: var(--muted); font-size: .9rem; }
.checks h2 .badge { margin-inline-start: .5rem; vertical-align: middle; }
.update { border-block-start: 1px solid var(--line); padding-block: .75rem; }
.update h3 { margin: 0 0 .5rem; font-size: 1rem; }
.update dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
.update dt { font-weight: 600; color: var(--muted); }
.update dd { margin: 0; }
.update pre { margin: 0 0 .35rem; padding: .35rem .6rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--page); border-radius: .35rem; }
@media (max-width: 40rem) { .update dl { grid-template-columns: minmax(0, 1fr); } .update dt { margin-block-start: .5rem; } }
/* The admin's mail page (D161). */
.help.bad { color: var(--bad); }
p.label { margin-block: .75rem .25rem; font-weight: 600; }
form.card h2:not(:first-of-type) { margin-top: 1.75rem; }

/* The assistant's page: a rating's two buttons on one line, and a decision's notes. */
form.inline { display: inline; margin: 0; }
form.inline button.link { margin: 0 .2rem; font-size: 1.1rem; text-decoration: none; }
form.inline button.link[aria-pressed="true"] { outline: 2px solid var(--accent); border-radius: .3rem; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* Conversations: the count of those waiting for a person, beside the menu link, and their rows. */
.nav .count { display: inline-block; min-width: 1.4em; margin-inline-start: .25rem; padding: 0 .35rem; border-radius: 1rem; background: var(--bad); color: #fff; font-size: .8rem; text-align: center; }
tr.waiting td { background: var(--warn-bg); }
.thread .turn { margin: 0 0 .9rem; padding: .6rem .8rem; border-radius: .6rem; max-width: 85%; }
.thread .turn.in { background: var(--page); margin-inline-end: auto; }
.thread .turn.out { background: var(--ok-bg); margin-inline-start: auto; }
.thread .turn p { margin: .2rem 0; }
