/*
  B Dynamic Logistics - Operations Dashboard host page styling.
  Brand palette, RAG status colours, and typography are fixed by BDL's design
  guidelines - see the project README before changing any of the tokens below.
*/

:root {
  --bdl-navy: #122038;
  --bdl-navy-tint: #1c3155;
  --bdl-orange: #fe5000;
  --bdl-white: #ffffff;

  /* RAG status colours - mandatory for any colour-coded status. Never substitute. */
  --bdl-status-red: #c8342e;
  --bdl-status-amber: #e8a33d;
  --bdl-status-green: #2e9e5b;

  --font-heading: "Century Gothic", "Apple Gothic", Futura, "Trebuchet MS", Arial, sans-serif;
  --font-body: Arial, Helvetica, sans-serif;

  --focus-ring: 3px solid var(--bdl-orange);
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #122038;
}

/* Locked to the viewport so the report fills whatever is left after the
   masthead and footer - the page itself never scrolls. dvh tracks mobile
   browser toolbars; the vh line is the fallback for older browsers. */
body {
  font-family: var(--font-body);
  color: var(--bdl-navy);
  background: var(--bdl-navy);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  color: var(--bdl-navy);
  margin: 0;
}

/* Keyboard focus must always be visible - never suppressed. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bdl-white);
  color: var(--bdl-navy);
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.masthead {
  background: var(--bdl-navy);
  color: var(--bdl-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Organisation and title on one line keeps the masthead to a single slim row. */
.masthead__brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  line-height: 1.2;
}

.masthead__org {
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.masthead__title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
}

.masthead__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.masthead__viewer {
  font-size: 0.875rem;
  opacity: 0.9;
}

.button {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: bold;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out;
}

.button--primary {
  background: var(--bdl-white);
  color: var(--bdl-navy);
  border-color: var(--bdl-white);
}

.button--primary:hover {
  background: transparent;
  color: var(--bdl-white);
  border-color: var(--bdl-white);
}

/* Quiet, compact masthead action (sign out) - shouldn't compete with the report. */
.button--ghost {
  background: transparent;
  color: var(--bdl-white);
  border-color: rgba(255, 255, 255, 0.5);
  font-size: 0.8125rem;
  padding: 0.25rem 0.75rem;
}

.button--ghost:hover {
  border-color: var(--bdl-white);
}

.button--ghost:disabled {
  opacity: 0.6;
  cursor: default;
}

.button--secondary {
  background: transparent;
  color: var(--bdl-navy);
  border-color: var(--bdl-navy);
}

.button--secondary:hover {
  background: var(--bdl-navy);
  color: var(--bdl-white);
}

/* The report is the hero: chrome around it stays minimal and quiet. */
/* min-height: 0 lets this flex item shrink below its content's size, so the
   report is sized by the viewport rather than pushing the footer off-screen. */
.report-shell {
  flex: 1;
  min-height: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* White card: the page behind it is navy, and the panel's text is navy. */
.status-panel {
  margin: auto;
  max-width: 32rem;
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bdl-white);
  border-radius: var(--radius);
}

.status-panel__link {
  color: var(--bdl-navy);
  font-weight: bold;
}

.status-panel[hidden] {
  display: none;
}

.status-panel__heading {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.status-panel__message {
  margin: 0 0 1rem;
  line-height: 1.5;
}

/* Status border accents use only the mandatory RAG palette - never a substitute colour. */
.status-panel[data-variant="error"] {
  border-top: 4px solid var(--bdl-status-red);
}

.status-panel[data-variant="warning"] {
  border-top: 4px solid var(--bdl-status-amber);
}

.status-panel[data-variant="success"] {
  border-top: 4px solid var(--bdl-status-green);
}

.report-host {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  border: 0;
  background: #0F1B2D;
}

.report-host[hidden] {
  display: none;
}

/* Pinned to the host's edges rather than relying on the SDK's inline
   height: 100%, which doesn't reliably resolve inside a flex item - when it
   doesn't, the iframe grows to the report's natural height and runs off the
   bottom of the screen. !important is needed to beat the SDK's inline styles. */
.report-host iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
}

.footer {
  padding: 0.1rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--bdl-white);
  opacity: 0.75;
}

@media (max-width: 640px) {
  .masthead {
    padding: 0.25rem 0.75rem;
  }

  .masthead__title {
    font-size: 0.95rem;
  }

  /* No room for both on a phone - the title carries the context. */
  .masthead__org {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
