/* The Automations section.
 *
 * Layout only, plus the few pieces app.css does not already own. Everything
 * else, the tokens, .card, .btn, .field, .in, .muted, .err, .sheet, .scrim and
 * .toast, comes from app.css so this page cannot drift from the app the reps
 * already use. Same arrangement as team.css, and the two local inks are the
 * same two, for the same measured reasons.
 */

html, body.fc-au { height: auto; min-height: 100%; overflow: visible; }
body.fc-au {
  background: var(--bg-soft);
  --warn-ink: #b42318;          /* the brand --red on --red-tint is 4.44:1, under AA */
  --warn-line: rgba(180, 35, 24, 0.30);
  --note-ink: #8a4708;          /* darker than --amber, because these blocks carry small type */
}

.au {
  max-width: 1180px; margin: 0 auto;
  padding: calc(var(--fshell-top-h, 0px) + 14px) 16px calc(var(--fshell-bottom-h, 0px) + 28px);
}

/* ----------------------------------------------------------------- head */
.au-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 14px; }
.au-head img { height: 38px; width: auto; flex: none; }
.au-head-t { min-width: 0; flex: 1 1 240px; }
.au-head h1 { font-size: 21px; }
.au-head .sub { color: var(--mute); font-size: 13.5px; margin-top: 2px; }
.au-who {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 52px; padding: 0 4px 0 12px;
  margin-left: auto; max-width: 100%; min-width: 0;
  border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2);
}
.au-who b { font-family: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.au-who button {
  border: 0; background: transparent; color: var(--blue-deep); font-family: var(--head); font-weight: 700;
  font-size: 12.5px; cursor: pointer; padding: 0 12px; min-height: 44px; border-radius: 999px;
}
.au-who button:hover { background: var(--blue-tint); }
.au-load { color: var(--mute); font-size: 14px; padding: 24px 2px; }

/* ----------------------------------------------------------------- grid */
.au-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.au-grid > .card { padding: 16px; min-width: 0; }
.au-step { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 12px; }
.au-step h2 { font-size: 16px; }
.au-count { color: var(--mute); font-size: 13px; }
/* app.css's .btn.small is 38px, under the 44px this page holds itself to, so
   the header button is the full primitive with a tighter box. */
.au-step .btn { margin-left: auto; padding: 10px 14px; font-size: 14px; }

/* ------------------------------------------------------------- the rows */
.au-rows { display: grid; gap: 10px; }
.au-row {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fff;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
/* Paused is the quiet state, not an error. It is still a real row somebody
   wrote and will switch on again. */
.au-row.off { background: var(--bg-soft); }
.au-row-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.au-id { flex: 1; min-width: 0; }
.au-id b { font-family: var(--head); font-weight: 800; font-size: 15.5px; display: block; letter-spacing: -0.01em; }
.au-when { display: block; color: #4a5567; font-size: 13px; margin-top: 2px; }
.au-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.au-fact {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px;
  border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line);
  font-size: 12.5px; color: #3d4859;
}
.au-fact b { font-family: var(--head); font-weight: 700; color: var(--ink); }
.au-row.off .au-fact { background: #fff; }

/* The last run, in its own colour, because it is the only thing on this row
   that says whether the thing actually works. */
.au-last { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-family: var(--head); font-weight: 700; border: 1px solid; }
.au-last.sent { background: var(--blue-tint); border-color: var(--blue-line); color: #0b4f96; }
.au-last.partial, .au-last.skipped { background: var(--amber-bg); border-color: rgba(181, 71, 8, 0.28); color: var(--note-ink); }
/* Waiting is not a verdict. It reads like the resting state it is, not like a
   warning, because the run has not gone wrong: it has not finished. */
.au-last.waiting { background: var(--blue-tint); border-color: var(--blue-line); color: #0b4f96; }
.au-last.failed { background: var(--red-tint); border-color: var(--warn-line); color: var(--warn-ink); }
.au-last.none { background: var(--bg-soft); border-color: var(--line); color: #3d4859; }

.au-row-go { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.au-row-go .spacer { flex: 1; }
.au-row-go .btn { padding: 10px 14px; font-size: 14px; }

/* The switch. The same control as the one on /team and on /hours: same 62x44
   hit box, same 50x30 track, same 24px knob, same travel. One control that
   behaves two ways in one product is two controls. */
.au-sw { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 5px 12px 5px 4px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
.au-sw.on { background: var(--blue-tint); border-color: var(--blue-line); }
.au-switch { width: 62px; height: 44px; padding: 0; border: 0; background: transparent; flex: none;
  cursor: pointer; display: grid; place-items: center; border-radius: 12px; }
.au-switch i { display: block; width: 50px; height: 30px; border-radius: 999px; position: relative;
  /* 4.61:1 on white, measured through the same canvas the contrast sweep uses.
     A switch is a control, so its off state needs 3:1 or it is not visibly a
     switch at all. */
  background: #6a7688; transition: background 140ms; }
.au-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.3); transition: transform 140ms; }
.au-switch[aria-checked="true"] i { background: var(--blue-deep); }
.au-switch[aria-checked="true"] i::after { transform: translateX(20px); }
.au-switch:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.au-sw-t { min-width: 0; flex: 1; font-size: 13.5px; line-height: 1.35; }
.au-sw-t b { font-family: var(--head); font-weight: 700; display: block; color: var(--ink); }
.au-sw-say { display: block; color: var(--ink-2); font-size: 12.5px; }

/* --------------------------------------------------------- blocks */
.au-note {
  background: var(--amber-bg); border: 1px solid rgba(181, 71, 8, 0.28); color: var(--note-ink);
  border-radius: 10px; padding: 9px 11px; font-size: 12.5px; line-height: 1.45;
}
.au-stop {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--red-tint); border: 1px solid var(--warn-line); color: var(--warn-ink);
  border-radius: 10px; padding: 10px 11px; font-size: 13px; line-height: 1.45;
}
.au-stop svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.au-stop b { font-family: var(--head); font-weight: 800; display: block; margin-bottom: 1px; }
.au-stop .grow { min-width: 0; }
.au-good {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--blue-tint); border: 1px solid var(--blue-line); color: #0b4f96;
  border-radius: 10px; padding: 10px 11px; font-size: 13px; line-height: 1.45;
}
.au-good svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.au-good b { font-family: var(--head); font-weight: 800; display: block; margin-bottom: 1px; }
.au-good .grow { min-width: 0; }
.au-empty { color: var(--mute); font-size: 14px; line-height: 1.5; padding: 6px 2px 2px; }

/* ---------------------------------------------------------------- sheet */
.au-sheet-p { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.au-sheet-p + .field { margin-top: 12px; }
.au-sheet-go { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.au-sheet-go .btn { flex: 1 1 150px; }
.au-x {
  margin-left: auto; width: 44px; height: 44px; border: 0; background: var(--bg-soft);
  border-radius: 11px; cursor: pointer; color: #4a5567; font-size: 20px; line-height: 1; flex: none;
}
.au-x:hover { background: var(--line); color: var(--ink); }
.au-link {
  border: 0; background: transparent; color: var(--blue-deep); cursor: pointer;
  font-family: var(--head); font-weight: 700; font-size: 13.5px;
  min-height: 44px; padding: 0 10px; border-radius: 10px; margin-top: 8px;
}
.au-link:hover { background: var(--blue-tint); }
/* app.css sizes the passcode toggle at 34px, under the 44px this page holds
   itself to. Scoped here rather than changed in app.css, which is the map's
   and the booker's too. */
body.fc-au .pw-toggle { min-height: 44px; right: 3px; }

/* A pick list that is a real 44px target per option, rather than a native
   select whose options cannot be sized at all. */
.au-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.au-pick {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 13px;
  border-radius: 11px; border: 1.5px solid var(--line); background: #fff; cursor: pointer;
  font-family: var(--head); font-weight: 700; font-size: 13.5px; color: var(--ink-2); text-align: left;
}
.au-pick[aria-pressed="true"], .au-pick[aria-checked="true"] {
  border-color: var(--blue); background: var(--blue-tint); color: #0b4f96;
}
.au-pick:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.au-lab { display: block; font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--mute); margin: 14px 0 6px; }

/* ------------------------------------------------------------- actions */
.au-acts { display: grid; gap: 10px; }
.au-act { border: 1px solid var(--line); border-radius: 12px; padding: 11px; background: #fff; min-width: 0; }
.au-act-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.au-act-top .au-n { font-family: var(--head); font-weight: 800; font-size: 13px; color: var(--mute); }
.au-act-top .btn { margin-left: auto; padding: 10px 13px; font-size: 13.5px; }
.au-ta { width: 100%; min-height: 88px; border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 12px;
  background: #fff; outline: none; font: inherit; font-size: 16px; line-height: 1.45; resize: vertical; }
.au-ta:focus { border-color: var(--blue); }
/* A wait is not a message, and the list reads better when that is visible at a
   glance rather than only in the words on its own button. Tinted ground, no
   white card, so the eye skips it on the way down the list. */
/* The waiting strip. Same shape as the warning block above it so the two stack
   without either looking like a different kind of thing, but blue, because a
   message that is on its way is not a problem. */
.au-wait-strip {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px;
  padding: 12px 13px; border-radius: 12px;
  background: var(--blue-tint); border: 1px solid var(--blue-line); color: #0b4f96;
}
.au-wait-strip svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.au-wait-strip b { display: block; font-family: var(--head); font-size: 14.5px; }
.au-wait-strip .grow { min-width: 0; font-size: 13.5px; line-height: 1.45; }

.au-act.is-wait { background: var(--blue-tint); border-color: var(--blue-line); }
.au-wait { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.au-wait .field { margin: 0; min-width: 0; }
.au-wait-n { flex: 0 1 130px; }
.au-wait-u { flex: 1 1 150px; }
.au-wait .in { background: #fff; }

.au-len { color: var(--mute); font-size: 12px; margin-top: 4px; display: block; }
.au-len.over { color: var(--warn-ink); font-weight: 700; }

/* The merge fields, as buttons rather than a list to copy by hand. */
.au-merge { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.au-chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); cursor: pointer;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 12.5px; color: #3d4859;
}
.au-chip:hover { background: var(--blue-tint); border-color: var(--blue-line); color: #0b4f96; }

/* ------------------------------------------------------------ the test */
.au-msg { border: 1px solid var(--line); border-radius: 12px; padding: 11px; background: #fff; }
.au-msg + .au-msg { margin-top: 8px; }
.au-msg .to { font-family: var(--head); font-weight: 700; font-size: 12.5px; color: var(--mute); display: block; }
.au-msg .subject { font-family: var(--head); font-weight: 700; font-size: 13.5px; display: block; margin-top: 3px; }
.au-msg .body { font-size: 13.5px; line-height: 1.5; color: var(--ink); margin-top: 5px; white-space: pre-wrap; word-break: break-word; }
.au-msg .out { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line); font-size: 12px; color: #3d4859; margin-top: 6px; }

/* ---------------------------------------------------------------- runs */
.au-run { display: flex; align-items: flex-start; gap: 9px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.au-run:first-child { border-top: 0; }
.au-run .grow { flex: 1; min-width: 0; }
.au-run b { font-family: var(--head); font-weight: 700; display: block; }
.au-run small { color: var(--mute); font-size: 12.5px; }

/* ---------------------------------------------------------------- toast */
body.fc-au #toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  bottom: calc(var(--fshell-bottom-h, 0px) + 14px);
}

/* --------------------------------------------------------------- denied */
#denied { z-index: 30; }
#denied .gate-in {
  padding-top: calc(var(--safe-t) + var(--fshell-top-h, 0px) + 20px);
  padding-bottom: calc(var(--safe-b) + var(--fshell-bottom-h, 0px) + 24px);
}
.au-denied-h { font-size: 18px; }
.au-denied-p { margin-top: 8px; font-size: 14px; }
.au-denied-go { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.au-denied-go .btn { flex: 1 1 150px; }

/* -------------------------------------------------------------- desktop */
@media (min-width: 760px) {
  .au-head h1 { font-size: 24px; }
  .au-grid > .card { padding: 20px; }
}
@media (min-width: 900px) {
  body.fc-au #toast { left: auto; right: 24px; transform: none; bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .au *, .au *::before, .au *::after, .au-switch i, .au-switch i::after {
    transition-duration: 0.01ms !important; animation-duration: 0.01ms !important;
  }
}
@media (max-width: 600px) {
  .au-head { align-items: center; }
  .au-head img { order: 1; }
  .au-who { order: 2; margin-left: auto; }
  .au-head-t { order: 3; flex: 1 1 100%; }
}
