/* Team MA shared styles: Melbourne Automation brand tokens, header, panels, buttons, forms.
   Page-specific styles go in each page. */

/* Melbourne Automation brand typeface (self-hosted, SIL OFL). */
@font-face {
  font-family: "Raleway";
  src: url("fonts/Raleway-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand primary colours */
  --ma-orange: #f37721;
  --ma-orange-dark: #d9621a;
  --ma-orange-soft: #fef1e7;
  --ma-grey: #353435;
  --ma-grey-dark: #242324;
  /* Brand secondary colours */
  --ma-green: #557a43;
  --ma-yellow: #f1ad33;

  --bg: #f5f5f4;
  --card: #ffffff;
  --border: #e2e0de;
  --text: #353435;
  --muted: #6b6a6b;
  --success-bg: #e8f0e3;
  --success-text: #3f5c31;
  --warning-bg: #fdf1dc;
  --warning-text: #8a5a06;
  --danger-bg: #fbe4e2;
  --danger-text: #a32a1f;
  --shadow: 0 10px 25px rgba(53, 52, 53, 0.08);
  --radius: 14px;

  /* Side margin shared by headers and page content: small on phones, generous on big screens. */
  --page-pad: clamp(12px, 2.2vw, 40px);
  /* Everything is scaled up on very large screens (see "Large screens" below). Divide any
     viewport height (vh) by this. */
  --ui-zoom: 1;
}

/* Large screens: 1440p, ultrawide and 4K monitors shown without OS scaling would otherwise
   make text and controls tiny. */
@media (min-width: 2200px) and (min-height: 1100px) { :root { --ui-zoom: 1.25; } }
@media (min-width: 2800px) and (min-height: 1500px) { :root { --ui-zoom: 1.5; } }
@media (min-width: 3500px) and (min-height: 1800px) { :root { --ui-zoom: 1.8; } }

html {
  zoom: var(--ui-zoom);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Raleway", Arial, Helvetica, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 {
  font-weight: 700;
}

/* Header */
header {
  position: relative;
  overflow: hidden;
  background: var(--ma-grey);
  color: #fff;
  padding: 16px max(var(--page-pad), env(safe-area-inset-right)) 18px max(var(--page-pad), env(safe-area-inset-left));
  border-bottom: 5px solid var(--ma-orange);
}

/* Angled orange block, echoing the brand graphics style. */
/* The slanted edge keeps the same 30° angle at any screen size or header height; only its
   position moves. --wedge-start is where the edge meets the bottom of the header. */
header::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--wedge-start, 66%);
  width: 200%;
  background: var(--ma-orange);
  transform: skewX(-30deg);
  transform-origin: bottom left;
  pointer-events: none;
}

/* Pages use the full width of the screen. */
.header-inner,
main {
  width: 100%;
  margin: 0 auto;
}

.header-inner {
  position: relative;
  z-index: 1;
}

main {
  padding: 20px max(var(--page-pad), env(safe-area-inset-right)) 32px max(var(--page-pad), env(safe-area-inset-left));
}

a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(243,119,33,0.6);
  outline-offset: 2px;
}

.brand-home {
  display: inline-block;
}

/* Logo on the left, Home button on the right (app pages). */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.header-top .brand-logo {
  margin-bottom: 0;
}

.home-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  color: var(--ma-grey-dark);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: 0.15s ease;
}

.home-button svg {
  width: 18px;
  height: 18px;
  fill: var(--ma-orange);
}

.home-label-short {
  display: none;
}

.home-button:hover {
  background: var(--ma-orange-soft);
  transform: translateY(-1px);
}

.home-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  margin-bottom: 14px;
}

.breadcrumb {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}

.breadcrumb a {
  color: #fff;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--ma-orange);
  text-decoration: underline;
}

.brand-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-title .accent {
  color: var(--ma-orange);
}

.brand-subtitle {
  margin: 4px 0 0;
  font-size: 15px;
  color: rgba(255,255,255,0.86);
  font-weight: 500;
}

/* Panels and layout */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 22px;
}

.panel-meta {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Buttons */
/* Links styled as buttons use class "button" or "button-link". */
button,
a.button,
.button-link {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  background: var(--ma-orange);
  color: var(--ma-grey-dark);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.15s ease;
}

button:hover,
a.button:hover,
.button-link:hover {
  background: var(--ma-orange-dark);
  transform: translateY(-1px);
}

button.secondary,
a.button.secondary {
  background: var(--ma-grey);
  color: #fff;
}

button.secondary:hover,
a.button.secondary:hover {
  background: var(--ma-grey-dark);
}

button.ghost {
  background: var(--ma-orange-soft);
  color: var(--ma-grey);
}

button.ghost:hover {
  background: #fbdcc5;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

button:focus-visible,
a.button:focus-visible,
.button-link:focus-visible {
  outline: 3px solid rgba(243,119,33,0.5);
  outline-offset: 2px;
}

/* Status messages */
.message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fafaf9;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}

.message.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #c8d9bd;
}

.message.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: #f6d493;
}

.message.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #f3c0bb;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 700;
  font-size: 14px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid rgba(243,119,33,0.22);
  border-color: var(--ma-orange);
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* Text boxes that aren't inside a .field still match the rest of the site. :where() keeps this easy to override. */
:where(input[type="search"], input[type="text"], input[type="email"], input:not([type])) {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}

/* Site version (added by shared/version.js) */
.site-version-bar {
  padding: 8px 16px 20px;
  text-align: center;
}

.site-version {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

footer .site-version {
  color: rgba(255, 255, 255, 0.6);
}

/* Job-based apps: step labels, job ID lookup and job details */
.step-label {
  margin: 0 0 4px;
  color: var(--ma-orange-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.job-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}

.job-form .field {
  flex: 1 1 240px;
  max-width: 640px;
}

/* Today's jobs from the signed-in person's simPRO schedule (shared/jobs.js) */
.pick-heading {
  margin: 20px 0 8px;
  font-size: 15px;
  font-weight: 800;
}

.pick-heading + .job-form {
  margin-top: 0;
}

.today-jobs-status {
  margin: 0;
  color: var(--muted);
}

.today-jobs-status.warning {
  color: var(--warning-text);
}

.today-jobs-retry {
  margin-top: 8px;
}

.today-jobs-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.today-job {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--ma-orange);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  font-weight: 500;
}

.today-job:hover {
  background: var(--ma-orange-soft);
  border-color: var(--ma-orange);
  transform: none;
}

.today-job-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.today-job-id {
  font-size: 16px;
}

.today-job-time {
  color: var(--ma-orange-dark);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.today-job-name {
  font-weight: 700;
}

.today-job-meta,
.today-job-status {
  color: var(--muted);
  font-size: 14px;
  word-break: break-word;
}

.job-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  margin: 16px 0 0;
  padding: 16px;
  border-left: 4px solid var(--ma-orange);
  border-radius: 10px;
  background: #fafaf9;
}

.job-details dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.job-details dd {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
  white-space: pre-line;
}

.hidden {
  display: none !important;
}

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

/* Touch screens: controls big enough for a thumb, and 16px text so phones don't zoom in on focus. */
@media (pointer: coarse) {
  :where(button),
  a.button,
  .button-link,
  select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]) {
    min-height: 44px;
  }

  select,
  textarea,
  .field textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
    font-size: 16px;
  }
}

/* Phones, and phones turned sideways: a short header so the page's content is on screen first. */
@media (max-width: 680px), (max-height: 500px) {
  header {
    padding-top: 10px;
    padding-bottom: 12px;
  }

  header::after {
    --wedge-start: 90%;
  }

  .header-inner {
    padding-right: 6%;
  }

  .brand-logo {
    height: 28px;
    margin-bottom: 8px;
  }

  .header-top {
    margin-bottom: 8px;
  }

  /* The Home button already goes where the breadcrumb does. */
  .breadcrumb,
  .brand-subtitle {
    display: none;
  }

  .home-button {
    padding: 8px 14px;
  }

  /* Keep the button short on phones: "Home" instead of "Team MA home". */
  .home-label-full {
    display: none;
  }

  .home-label-short {
    display: inline;
  }

  .brand-title {
    font-size: 22px;
  }
}

@media (max-width: 680px) {
  main {
    padding-top: 12px;
  }

  .panel {
    padding: 14px;
    margin-bottom: 12px;
  }

  .panel-title {
    font-size: 19px;
  }

  .panel-meta {
    font-size: 14px;
  }

  /* Page actions sit two to a row instead of one long stack. */
  .toolbar {
    width: 100%;
    gap: 8px;
  }

  .toolbar > * {
    flex: 1 1 calc(50% - 8px);
  }

  .toolbar button,
  .toolbar a.button,
  .toolbar .button-link,
  .panel-heading > button {
    width: 100%;
  }

  .job-form button {
    width: 100%;
  }

  .job-details {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .job-details dd {
    margin-bottom: 10px;
  }
}
