/*
 * The client portal.
 *
 * Shares the site's tokens and the console's semantic colours, but not the console's density. A
 * scheduler lives in a table all day and wants rows; a client opens this four times a year to
 * answer one question — when are you coming, what do I owe, may you use the photographs. So the
 * layout is a small number of large, unambiguous blocks rather than a grid of data.
 */

:root {
  --good: #1a7f47;
  --good-bg: #e6f4ec;
  --warn: #8a6100;
  --warn-bg: #fdf3dd;
  --bad: #a32020;
  --bad-bg: #fbeaea;
  --info: #14567a;
  --info-bg: #e4f0f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --good: #62c48c;
    --good-bg: #12301f;
    --warn: #e0b053;
    --warn-bg: #33270a;
    --bad: #ef8080;
    --bad-bg: #3a1616;
    --info: #6bb7dd;
    --info-bg: #102c3c;
  }
}

body.portal {
  background: var(--surface-alt);
}

/* ---------- Shell ---------- */

.portal-bar {
  background: var(--brand-primary);
  color: #f3f6f8;
  border-bottom: 3px solid var(--brand-accent);
}

.portal-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.portal-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}

.portal-brand span { color: var(--brand-accent); }

.portal-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #b9c9d6;
}

.portal-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
}

.portal-tabs-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  gap: 0.25rem;
}

.portal-tabs a {
  display: block;
  padding: 0.85rem 0.9rem;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.portal-tabs a:hover { color: var(--ink); }

.portal-tabs a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--brand-accent);
  font-weight: 600;
}

.portal-tabs .count {
  display: inline-block;
  margin-left: 0.4rem;
  min-width: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--brand-accent);
  color: #14202b;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.portal-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

/* ---------- Blocks ---------- */

.portal-header { margin-bottom: 1.5rem; }

.portal-header h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  margin: 0 0 0.25rem;
}

.portal-header p { color: var(--ink-muted); margin: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.panel-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/*
 * The quote card. This is the screen the whole product turns on, so it is the one thing on the
 * page and the decision sits at the bottom where the eye lands after reading the lines.
 */
.quote-card { border-left: 3px solid var(--brand-accent); }

.quote-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.quote-lines th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--hairline);
}

.quote-lines td {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

.quote-lines td[data-align="end"],
.quote-lines th[data-align="end"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quote-lines .line-note {
  display: block;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.92rem;
}

.total-row.is-grand {
  border-top: 2px solid var(--ink);
  margin-top: 0.4rem;
  padding-top: 0.7rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-display);
}

.total-row span:last-child { font-variant-numeric: tabular-nums; }

.decision {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

.decision .btn { min-width: 9rem; }

/* ---------- Job progress ---------- */

/*
 * A stepper rather than a percentage. "En route" is information a client can act on — it means put
 * the dog inside and unlock the gate. "38%" is not.
 */
.tracker {
  display: flex;
  gap: 0.25rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.tracker li {
  flex: 1;
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-align: center;
  padding-top: 0.55rem;
  border-top: 3px solid var(--hairline);
}

.tracker li[data-state="done"] {
  color: var(--ink);
  border-top-color: var(--good);
}

.tracker li[data-state="current"] {
  color: var(--ink);
  font-weight: 700;
  border-top-color: var(--brand-accent);
}

/* ---------- Media consent ---------- */

.media-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.media-tile {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.media-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-alt);
}

.media-tile .media-body {
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.media-tile .media-phase {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.media-tile .media-caption { font-size: 0.85rem; }

/* Pushes the consent control to the bottom edge so every tile's control lines up. */
.media-tile .media-action { margin-top: auto; }

.consent-note {
  background: var(--info-bg);
  border-left: 3px solid var(--info);
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}

/* ---------- Small pieces ---------- */

.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.pill[data-tone="good"] { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill[data-tone="bad"]  { background: var(--bad-bg);  color: var(--bad);  border-color: transparent; }
.pill[data-tone="info"] { background: var(--info-bg); color: var(--info); border-color: transparent; }

.field-list { display: grid; gap: 0.75rem; margin: 0; }

.field dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}

.field dd { margin: 0; font-size: 0.95rem; }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}

.empty p { margin: 0 0 0.75rem; }

.money { font-variant-numeric: tabular-nums; }

.muted { color: var(--ink-muted); }

.stack { display: grid; gap: 0.75rem; }

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 60;
  max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
  background: var(--brand-primary);
  color: #f3f6f8;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  border-left: 3px solid var(--brand-accent);
}

.toast[data-tone="bad"] { border-left-color: var(--bad); }
.toast[data-tone="good"] { border-left-color: var(--good); }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 180ms ease-out; }

  @keyframes toast-in {
    from { opacity: 0; transform: translateY(0.4rem); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- Threads ---------- */

.thread {
  display: grid;
  gap: 0.75rem;
  max-height: 26rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.message {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  background: var(--surface);
}

/*
 * The client's own messages, set apart. Not a chat-bubble layout: these threads are long-running
 * and mostly one message a day, so alignment games make them harder to read rather than easier.
 * A tinted ground is enough to answer "did I say that or did they".
 */
.message[data-mine="true"] {
  background: var(--surface-alt);
  border-left: 3px solid var(--brand-accent);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.74rem;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}

.message-body {
  margin: 0;
  font-size: 0.92rem;

  /* Message bodies are typed by people and contain pasted registration numbers and URLs. */
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
