/*
 * SHIP shared styling — deliberately hand-written, no build step (no
 * Tailwind/PostCSS pipeline exists in this repo). Matches the visual
 * language of MBE Thames Valley's other internal staff tools (the
 * "Staff Utilities" hub and Print Calculator pages on lshub.co.uk):
 * Quicksand body font, a neutral slate palette, white cards with soft
 * shadows, and a dark primary button — not the Shopify storefront's
 * green/khaki branding, which is customer-facing, not staff-facing.
 */

@font-face {
  font-family: "Quicksand";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/static/fonts/Quicksand-Variable.woff2") format("woff2-variations");
}

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f5f4;
  --color-border: rgba(15, 23, 42, 0.1);
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-disabled: #94a3b8;
  --color-button-bg: #111827;
  --color-button-text: #ffffff;
  --color-badge-bg: #fef3c7;
  --color-badge-text: #92400e;
  --color-badge-border: #fcd34d;
  --color-error-bg: #fef2f2;
  --color-error-text: #b91c1c;
  --color-error-border: #fecaca;
  --color-success-bg: #f0fdf4;
  --color-success-text: #15803d;
  --color-success-border: #bbf7d0;
  --radius-card: 16px;
  --radius-control: 8px;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Quicksand", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--color-text);
}

h1 {
  font-size: 1.6em;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.2;
}

h2 {
  font-size: 1.15em;
  font-weight: 700;
  margin: 0 0 8px;
}

p {
  margin: 0 0 12px;
}

/* Top bar — every page shares this, matching the "Staff Utilities" header. */
.ship-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.ship-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ship-header__brand a {
  font-weight: 700;
  font-size: 1.15em;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.ship-logo {
  height: 32px;
  width: auto;
  display: block;
}

.ship-header__title {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.95em;
}

.ship-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  border: 0.5px solid var(--color-badge-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

.ship-header__nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  margin-left: 16px;
}

.ship-header__nav a:hover {
  color: var(--color-text);
}

/* Page container — every page's body content sits inside this. */
.ship-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.ship-sub {
  color: var(--color-text-muted);
  margin: 0 0 28px;
}

/* Cards — landing-page mode links, confirm screens, booking results. */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card + .card {
  margin-top: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card-link {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}

.card-link:hover {
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
}

.card-link__icon {
  font-size: 28px;
  line-height: 1;
}

.card-link__title {
  font-size: 1.05em;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.card-link__desc {
  font-size: 0.9em;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.55;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
}

form.form-wide {
  max-width: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--color-text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus,
select:focus {
  outline: 2px solid var(--color-button-bg);
  outline-offset: 1px;
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

legend {
  font-weight: 600;
  font-size: 0.9em;
  padding: 0 4px;
}

label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
}

/* Buttons */
button,
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text);
  padding: 9px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s;
}

button:hover,
.btn:hover {
  opacity: 0.85;
}

button[type="submit"],
.btn-primary {
  background: var(--color-button-bg);
  color: var(--color-button-text);
  border-color: var(--color-button-bg);
}

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

/* Quote tables */
.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

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

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

/* Sortable column headers — see app/static/js/quote-table.js */
th[data-sort-type] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-type]:hover {
  color: var(--color-text);
}

th[aria-sort="ascending"]::after {
  content: " \25B2";
}

th[aria-sort="descending"]::after {
  content: " \25BC";
}

/* Per-column filter inputs, in a second header row */
.filter-row th {
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--color-border);
}

.col-filter {
  width: 100%;
  font-size: 12px;
  font-weight: 400;
  padding: 5px 8px;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--color-surface-muted);
}

.toggle {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.toggle button[disabled] {
  background: var(--color-button-bg);
  color: var(--color-button-text);
  opacity: 1;
}

/* Discount switch — toggles Price to Customer between the 80%-margin and
   70%-margin guide for every row. See app/static/js/quote-table.js. */
.discount-switch {
  margin-left: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.discount-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.discount-switch__track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--color-border);
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}

.discount-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3);
  transition: transform 0.15s;
}

.discount-switch input:checked + .discount-switch__track {
  background: var(--color-button-bg);
}

.discount-switch input:checked + .discount-switch__track .discount-switch__thumb {
  transform: translateX(16px);
}

/* "Admin access" switch — hides the wholesale Cost (ex-VAT) column by
   default, since this table can be on screen while a customer is at the
   counter. Off by default; the column only appears once switched on. See
   app/static/js/quote-table.js. */
.cost-column {
  display: none;
}

.table-wrap.show-cost .cost-column {
  display: table-cell;
}

.no-quotes {
  padding: 24px;
  color: var(--color-text-muted);
  margin: 0;
}

/* Status banners */
.errors,
.warning,
.booked,
.validated {
  border-radius: var(--radius-control);
  padding: 14px 16px;
  margin: 0 0 16px;
}

.errors {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border: 1px solid var(--color-error-border);
}

.errors ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.warning {
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  border: 1px solid var(--color-badge-border);
}

.booked,
.validated {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}

.booked a,
.validated a {
  color: var(--color-success-text);
  font-weight: 600;
}

.error {
  color: var(--color-error-text);
}
