/* ===========================================================================
   TBC Conversions brand system
   Palette and type sourced from tbcconversions.com: deep brand navy as
   committed chrome, azure as the single interactive accent, cool
   (navy-tinted, not plain-grey) neutrals everywhere else. Fonts are
   self-hosted (vendor/fonts/) rather than linked from a CDN, matching how
   sql.js/SheetJS are vendored elsewhere in this app - no runtime dependency
   on an external host.
   =========================================================================== */

@font-face {
  font-family: 'Jost';
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/jost-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/jost-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/jost-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/opensans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/opensans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/opensans-700.woff2') format('woff2');
}

:root {
  color-scheme: light dark;

  --navy-950: #0B2439;
  --navy-800: #123B52;
  --azure-500: #2EA3F2;
  --azure-600: #1C8FDE;
  --azure-contrast: #06202E;

  --bg: #F3F7FA;
  --panel: #FFFFFF;
  --border: #DCE6ED;
  --text: #17232C;
  --muted: #5B6E7D;

  --header-bg: var(--navy-950);
  --header-fg: rgba(255, 255, 255, 0.92);
  --header-fg-muted: rgba(255, 255, 255, 0.65);
  --header-border: rgba(255, 255, 255, 0.16);

  --accent: var(--azure-500);
  --accent-contrast: var(--azure-contrast);

  --danger: #C7373F;
  --danger-bg: #FDECEE;
  --forced-bg: #E8F6F0;
  --forced-border: #2F9E6E;

  --row-alt: rgba(11, 36, 57, 0.04);
  --row-hover: rgba(11, 36, 57, 0.08);

  --font-display: 'Jost', 'Century Gothic', 'Trebuchet MS', Helvetica, Arial, sans-serif;
  --font-body: 'Open Sans', -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy-950: #081824;
    --navy-800: #0E2C3D;
    --azure-500: #4FB3FF;
    --azure-600: #7CC6FF;
    --azure-contrast: #06202E;

    --bg: #0A1620;
    --panel: #10222E;
    --border: #223140;
    --text: #E7EEF3;
    --muted: #93A8B8;

    --header-bg: #061119;
    --header-fg: rgba(255, 255, 255, 0.92);
    --header-fg-muted: rgba(255, 255, 255, 0.6);
    --header-border: rgba(255, 255, 255, 0.12);

    --danger: #FF6B72;
    --danger-bg: #3A1B1D;
    --forced-bg: #12291F;
    --forced-border: #4FC793;

    --row-alt: rgba(255, 255, 255, 0.04);
    --row-hover: rgba(255, 255, 255, 0.08);
  }
}

* { box-sizing: border-box; }

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--azure-500);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
}

/* ---- Header / brand chrome (always navy, in both themes - a committed
   page-scale color, not just an accent) ---- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--header-bg);
  color: var(--header-fg);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  height: 26px;
  width: auto;
  display: block;
}

.brand-mark-lg {
  height: 48px;
}

header h1 {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--header-fg);
}

nav.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* Non-developer users only have one tab (Configure a Build) - give it its
   own full-width row so it centers regardless of the title/actions widths
   on either side, instead of sitting wherever flex space-between leaves it. */
nav.tabs.tabs-centered {
  flex: 1 1 100%;
  justify-content: center;
}

nav.tabs button {
  background: none;
  border: 1px solid var(--header-border);
  color: var(--header-fg-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

nav.tabs button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--header-fg);
}

nav.tabs button.active {
  background: var(--azure-500);
  border-color: var(--azure-500);
  color: var(--azure-contrast);
  font-weight: 700;
}

header .muted { color: var(--header-fg-muted); }

header button.secondary {
  border-color: var(--header-border);
  color: var(--header-fg-muted);
}

header button.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--header-fg);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

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

.panel h2 {
  margin: 0 0 0.9rem;
  padding-bottom: 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--azure-500);
}

.panel h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
}

select, input[type=text], input[type=number], input[type=password], textarea {
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
  width: 100%;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.plain-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
}

.option-row:hover:not(.blocked):not(.forced):not(.unpriced) {
  background: var(--row-hover);
}

.option-row input[type=checkbox] {
  accent-color: var(--azure-500);
  width: 16px;
  height: 16px;
}

.option-row.blocked {
  background: var(--danger-bg);
  color: var(--danger);
  cursor: not-allowed;
}

/* A manager-only state (see specialistRowPriceInfo()/
   specialistOptionVisibilityFromPriceInfo() in app.js) - deliberately not
   the same red as .blocked above, which means "conflicts with your other
   choices", not "nobody's priced this yet". --border rather than
   --row-hover for the background - a manager isn't hovering these rows,
   and --row-hover's tint is too close to the real :hover state to read as
   a distinct third colour at rest. Text uses --muted, same colour the
   .code column already uses for de-emphasis. */
.option-row.unpriced {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.option-row.forced {
  background: var(--forced-bg);
  border-color: var(--forced-border);
  cursor: default;
}

/* Fixed-width lead column shared by every option list (standard, required,
   custom) - the checkbox in custom-option rows, an empty spacer of the same
   width in the checkbox-less standard/required rows - so the code column
   after it starts at the same x position everywhere, not just within a
   single list. */
.row-lead {
  flex: 0 0 1.5rem;
}

/* Fixed-width code column, wide enough for the longest real code
   (S91+S99+SW1) to stay on one line - so names always start in the same
   place regardless of how long an individual option's code is. */
.code {
  flex: 0 0 7rem;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.name {
  flex: 1;
}

.price {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  margin-left: auto;
  padding-left: 0.6rem;
}

.tag.common {
  color: var(--azure-600);
  border-color: var(--azure-600);
}

.tag {
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid currentColor;
}

/* ---- Collapsed Standard/Required specification summary ----
   Non-actionable (nothing here can be unchecked), so it starts collapsed
   to one line and expands on click - see renderOptionsPanel(). */
.spec-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  text-align: left;
}

.spec-summary:hover {
  border-color: var(--azure-500);
}

.spec-summary strong {
  font-variant-numeric: tabular-nums;
}

.spec-summary .chevron {
  flex: none;
  color: var(--azure-600);
  font-size: 0.8rem;
  font-weight: 700;
}

button.primary,
button.secondary {
  font-family: inherit;
  transition: background-color 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

button.primary {
  background: var(--azure-500);
  color: var(--azure-contrast);
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

button.primary:active:not(:disabled) {
  filter: brightness(0.95);
}

button.secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
}

button.secondary:hover:not(:disabled) {
  background: var(--row-hover);
  border-color: var(--muted);
}

button.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

button.danger {
  color: var(--danger);
  border-color: var(--danger);
}

button.danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: var(--row-alt);
}

tbody tr:hover {
  background: var(--row-hover);
}

tr.row-unmatched {
  background: var(--danger-bg);
  color: var(--danger);
}

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

.actions-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ---- Manage Catalog: grouped tab nav (replaces one long wrapping row of
   buttons) - see renderGroupedCatalogTabs() in app.js. ---- */
.catalog-groups {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.catalog-group-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.catalog-group-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.catalog-group-row button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.catalog-group-row button:hover:not(.active) {
  border-color: var(--azure-500);
  color: var(--azure-600);
}

.catalog-group-row button.active {
  background: var(--azure-500);
  color: var(--azure-contrast);
  border-color: var(--azure-500);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(11,36,57,0.08), 0 8px 24px rgba(11,36,57,0.16);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 1px 2px rgba(11,36,57,0.1), 0 16px 48px rgba(11,36,57,0.28);
}

.stale-pricing-popup {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  max-width: 340px;
  box-shadow: 0 8px 24px rgba(11,36,57,0.2);
  z-index: 90;
}

.stale-pricing-popup p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.redflag-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}

.redflag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.redflag-label {
  display: flex;
  align-items: center;
}

.redflag-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.redflag-total {
  border-top: 2px solid var(--text);
  border-bottom: none;
  font-weight: 700;
  font-size: 1.05rem;
  padding-top: 0.6rem;
  margin-top: 0.25rem;
}

/* Standard/required option lists are informational, not actionable (nothing
   here can be unchecked) - kept visually quieter than "Custom options" below
   them so the list the user actually has to make decisions in reads first. */
.spec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.spec-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid transparent;
  border-bottom: 1px dashed var(--border);
}

form.inline-add {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 0.75rem;
}

.choice-screen {
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
}

.choice-screen h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.choice-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.choice-btn {
  min-width: 240px;
  padding: 0.95rem 1.5rem;
  font-size: 1.02rem;
}

/* ---------------------------------------------------------------------
   Landing menu (post-login, choose minibus vs specialist) - two plain
   choice cards, styled from the same tokens as .panel/button.primary
   rather than any photography. See renderLandingMenu() in app.js.
   --------------------------------------------------------------------- */

.landing {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

.landing-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  margin-bottom: 1rem;
}

.landing-header h1 { margin: 0; }
.landing-header p { margin: 0; }

.landing-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
  margin: 2.5rem 0;
}

.landing-choice {
  flex: 1 1 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 36, 57, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.landing-choice:hover,
.landing-choice:focus-visible {
  border-color: var(--azure-500);
  box-shadow: 0 8px 20px rgba(11, 36, 57, 0.12);
  transform: translateY(-2px);
}

.landing-choice-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.landing-choice-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.landing-choice-arrow {
  margin-top: 0.5rem;
  color: var(--azure-500);
  font-weight: 700;
  transition: transform 0.15s ease;
}

.landing-choice:hover .landing-choice-arrow {
  transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
  .landing-choice { transition: none; }
  .landing-choice-arrow { transition: none; }
}

/* ---------------------------------------------------------------------
   Section-level navigation transition - landing menu <-> a configurator,
   both directions (see navigateWithTransition() in app.js). A brief fade
   + small vertical drift on the whole #app root: enough to soften the cut
   between screens without it becoming a set piece of its own. Deliberately
   not used for ordinary in-app renderApp() calls (tab switches, field
   edits, etc.) - only the handful of call sites that cross the landing
   menu boundary opt into it.
   --------------------------------------------------------------------- */

#app.app-nav-out {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#app.app-nav-in {
  opacity: 0;
  transform: translateY(6px);
}

#app.app-nav-in.app-nav-in-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

@media (prefers-reduced-motion: reduce) {
  #app.app-nav-out,
  #app.app-nav-in,
  #app.app-nav-in.app-nav-in-active {
    transition: none;
  }
}
