/* Trade Ordering Platform — design system.
   Palette/typeface pulled from the real autopartuk.com site (Work Sans,
   deep teal-green accent, near-black header/footer) so this reads as part
   of the same business rather than a generic scaffold. */

:root {
  --color-primary: #1f5c46;
  --color-primary-dark: #143f30;
  --color-primary-light: #2c7a5b;
  --color-dark: #16171a;
  --color-bg: #f2f3f5;
  --color-surface: #ffffff;
  --color-text: #434549;
  --color-text-muted: #75777c;
  --color-border: #e1e3e6;
  --color-danger: #b3261e;
  --color-danger-bg: #fdecea;
  --color-success: #1f5c46;
  --color-success-bg: #e9f3ef;
  --color-warning: #a15c00;
  --color-warning-bg: #fff4e5;
  --radius: 8px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(22, 23, 26, 0.06), 0 1px 8px rgba(22, 23, 26, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Work Sans", Arial, Helvetica, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: "Work Sans", Arial, Helvetica, sans-serif;
  color: var(--color-dark);
  font-weight: 700;
  margin: 0 0 0.6em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.6em; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout shell ---- */

.site-header {
  background: var(--color-dark);
  color: #fff;
}
.site-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.site-header__brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}
.site-header__brand span { color: var(--color-primary-light); }
.site-header__nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.92rem;
}
.site-header__nav a {
  color: rgba(255, 255, 255, 0.85);
}
.site-header__nav a:hover { color: #fff; }
.site-header__cart-count {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  padding: 1px 8px;
  margin-left: 4px;
}

/* Basket hover preview. The dropdown sits flush against the nav link's own
   bottom edge (no gap) so the mouse never leaves .basket-nav while moving
   from the link down into the dropdown — a gap there would make it flicker
   closed before you reach it. */
.basket-nav {
  position: relative;
}
.basket-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  margin-top: 0;
  padding-top: 12px;
  z-index: 20;
}
.basket-nav:hover .basket-dropdown {
  display: block;
}
.basket-dropdown__list {
  list-style: none;
  margin: 0;
  padding: 8px;
  background: var(--color-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
}
.basket-dropdown__list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text);
}
.basket-dropdown__list li:last-child { border-bottom: none; }
.basket-dropdown__name { flex: 1 1 auto; }
.basket-dropdown__qty { color: var(--color-text-muted); }
.basket-dropdown__price { font-weight: 600; white-space: nowrap; }
.basket-dropdown__footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text);
}
.basket-dropdown .btn--block {
  border-radius: 0 0 var(--radius) var(--radius);
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
}
.site-footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.breadcrumb {
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--color-text-muted); }

/* ---- Cards & surfaces ---- */

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card--narrow {
  max-width: 420px;
  margin: 48px auto;
}

/* Order detail: totals / payment / delivery side by side instead of
   stacked full-width blocks, so the page doesn't run on forever. */
.order-summary-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 20px;
  margin-top: 20px;
}
.order-summary-grid > .card {
  flex: 1 1 280px;
  padding: 20px 24px;
}

.summary-list { margin: 0; }
.summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}
.summary-list > div:last-child { border-bottom: none; }
.summary-list dt { color: var(--color-text-muted); margin: 0; }
.summary-list dd { margin: 0; font-weight: 600; }
.summary-list__total dt,
.summary-list__total dd { font-weight: 700; color: var(--color-dark); }

/* ---- Messages ---- */

.messages { list-style: none; margin: 0 0 20px; padding: 0; }
.messages li {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.92rem;
  border-left: 4px solid var(--color-text-muted);
  background: var(--color-bg);
}
.messages li.success { background: var(--color-success-bg); border-color: var(--color-success); color: var(--color-primary-dark); }
.messages li.error { background: var(--color-danger-bg); border-color: var(--color-danger); color: var(--color-danger); }
.messages li.warning { background: var(--color-warning-bg); border-color: var(--color-warning); color: var(--color-warning); }
.messages li.info { background: var(--color-bg); border-color: var(--color-text-muted); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 9px 20px;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn:disabled { background: var(--color-border); color: var(--color-text-muted); cursor: not-allowed; }

.btn--secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn--secondary:hover { background: var(--color-bg); }

.btn--danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger-bg);
}
.btn--danger:hover { background: var(--color-danger-bg); }

.btn--small { padding: 5px 14px; font-size: 0.78rem; }
.btn--block { width: 100%; justify-content: center; }

/* ---- Forms ---- */

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
select,
textarea {
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(31, 92, 70, 0.12);
}
input[type="number"] { width: 5.5em; }
input:disabled, select:disabled, textarea:disabled {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; }

/* The most common choice on the delivery step, so it gets its own
   button-like toggle instead of a plain small checkbox easy to miss. */
.ship-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ship-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
}
.ship-toggle--on {
  border-color: var(--color-primary);
  background: var(--color-success-bg);
  color: var(--color-primary-dark);
}

/* Plain Django {{ form.as_p }} output */
form p { margin-bottom: 16px; }
form p label { display: block; margin-bottom: 4px; font-weight: 600; color: var(--color-text); }
form p input, form p select, form p textarea { width: 100%; }

/* Vehicle lookup on the product list: the picker (four cascading
   dropdowns, shown until a vehicle is chosen) and the banner that replaces
   it once one is. Same card treatment as the filter bar beneath, but not
   sticky — it's a one-off choice, not something to keep at hand while
   scrolling. */
.vehicle-picker,
.vehicle-banner {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 20px;
  margin-bottom: 16px;
}
.vehicle-picker__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.vehicle-picker__title {
  /* Sits inline at the left of the field row, aligned with the inputs'
     baseline (the fields have a label above them, the title doesn't). */
  color: var(--color-dark);
  font-size: 0.95rem;
  line-height: 37px;
  padding-right: 4px;
  white-space: nowrap;
}
.vehicle-picker__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vehicle-picker__field label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.8rem;
}
.vehicle-picker__field .combo { min-width: 9.5em; }
.vehicle-picker__field--year .combo { width: 6.5em; min-width: 0; }
.vehicle-picker__field--version { flex: 1 1 180px; }
.vehicle-picker__field--version .combo { width: 100%; }
@media (min-width: 900px) {
  /* Desktop: one row, always. The three text fields share whatever width
     is left after the title, the fixed-width year box and the buttons
     (Version gets a double share — its labels are long). Below 900px the
     rule above lets the row wrap instead. */
  .vehicle-picker__row { flex-wrap: nowrap; }
  .vehicle-picker__field { flex: 1 1 0; min-width: 0; }
  .vehicle-picker__field .combo { min-width: 0; width: 100%; }
  .vehicle-picker__field--year { flex: 0 0 auto; }
  .vehicle-picker__field--year .combo { width: 6.5em; }
  .vehicle-picker__field--version { flex: 2 1 0; }
  .vehicle-picker__field--actions { flex: 0 0 auto; }
}

/* Fitment disclaimer: one muted line by default, native <details> to
   expand the full wording — always in the HTML, never in the way. */
.fitment-disclaimer {
  flex: 1 1 100%;
  margin: 10px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}
.fitment-disclaimer summary {
  cursor: pointer;
  list-style: none;
}
.fitment-disclaimer summary::-webkit-details-marker { display: none; }
.fitment-disclaimer summary strong { color: var(--color-text); font-weight: 600; }
.fitment-disclaimer__more {
  color: var(--color-primary);
  text-decoration: underline;
  margin-left: 4px;
}
.fitment-disclaimer[open] .fitment-disclaimer__more { display: none; }
.fitment-disclaimer p {
  margin: 6px 0 0;
}

/* Type-to-filter combobox (vehicle picker). A text input with a chevron
   drawn the same way a <select>'s is, and a floating filtered list under
   it — so it reads as a dropdown you can also type into. */
.combo {
  position: relative;
  min-width: 11em;
}
.combo__input {
  width: 100%;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2375777c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.combo__input:disabled {
  background-image: none;
}
.combo__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(22, 23, 26, 0.12);
  z-index: 30;
}
.vehicle-picker__field--version .combo__list { right: auto; min-width: 100%; max-width: 640px; }
.combo__option,
.combo__empty {
  padding: 7px 12px;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo__option { cursor: pointer; }
.combo__option:hover,
.combo__option--active {
  background: var(--color-success-bg);
  color: var(--color-primary-dark);
}
.combo__option--selected { font-weight: 600; }
.combo__empty { color: var(--color-text-muted); }
.vehicle-picker__note {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 6px;
  border-left: 4px solid var(--color-warning);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: 0.88rem;
}

.vehicle-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  align-items: center;
  border-left: 4px solid var(--color-primary);
}
.vehicle-banner__main {
  display: flex;
  flex-direction: column;
  flex: 1 1 220px;
}
.vehicle-banner__eyebrow {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}
.vehicle-banner__title {
  font-size: 1.05rem;
  color: var(--color-dark);
}
.vehicle-banner__version {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.vehicle-banner__specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
}
.vehicle-banner__specs > div { display: flex; flex-direction: column; }
.vehicle-banner__specs dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.vehicle-banner__specs dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-dark);
}
.vehicle-banner__limit {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.vehicle-banner__caveat {
  flex: 1 1 100%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 6px;
  border-left: 4px solid var(--color-warning);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: 0.88rem;
}

/* Filter bar on the product list. Sticks to the top of the viewport while
   scrolling through a long results table, so the filters are always at
   hand. Needs a solid background + shadow (already has both) so the table
   scrolling underneath it is fully hidden, not overlapping — the earlier
   "blocks the table" complaint turned out to be about the Django admin's
   changelist filter, not this one. */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.filter-bar__row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}
.filter-bar__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-bar__field label {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.8rem;
}
.filter-bar__field--search {
  flex: 1 1 200px;
}
.filter-bar__field--search input {
  width: 100%;
}

/* "In stock only" — was a plain small checkbox + label that read as an
   afterthought next to a row of proper dropdowns. Styled as a bordered
   toggle (same idea as .ship-toggle on the basket page: lights up green
   once checked) sized to match the height of the <select>s beside it. */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 37px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.filter-toggle:hover {
  border-color: var(--color-primary);
}
.filter-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--color-primary);
}
.filter-toggle.filter-toggle--on {
  /* Two classes, not one — needs to outrank .filter-bar__field label's
     (0,1,1) specificity, which otherwise wins the `color` property back to
     the default text colour regardless of rule order. */
  border-color: var(--color-primary);
  background: var(--color-success-bg);
  color: var(--color-primary-dark);
}

/* ---- Tables ---- */

.table-scroll {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}
th {
  color: var(--color-text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  background: #fafafb;
}
tbody tr:hover { background: #fafbfa; }
td img { display: block; border-radius: 6px; }

/* Product list: fewer, narrower columns (stock code/brand/design merged,
   bore/max bore merged, qty+add merged) plus wrapping instead of nowrap, so
   the whole table fits without horizontal scrolling on an ordinary desktop
   width instead of needing .table-scroll's overflow-x as the only way to
   see the last few columns. */
.product-table th, .product-table td {
  white-space: normal;
  padding: 10px 12px;
}
.product-table { font-size: 0.83rem; }
.product-table select { max-width: 110px; }
.product-table input[type="number"] { width: 3.5em; }

/* Product photo thumbnail + hover zoom. Wheels are a heavily look-driven
   purchase, so 64px (up from 36px) reads more clearly at a glance, and
   hovering shows a much larger preview via #product-thumb-zoom (a single
   shared, fixed-position <img> — see the inline script in
   product_list.html for why fixed rather than absolute). */
.product-thumb {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
}
.product-thumb-zoom {
  display: none;
  position: fixed;
  width: 260px;
  height: 260px;
  object-fit: cover;
  border-radius: 10px;
  border: 4px solid var(--color-surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  z-index: 50;
  pointer-events: none;
}

/* Whole-row link: the row-link anchor stretches over the entire <tr> via
   ::after so clicking anywhere in the row navigates, while still being a
   real, keyboard/screen-reader-accessible link (not JS-driven). */
.table-row-links tbody tr { position: relative; cursor: pointer; }
.table-row-links .row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* Public catalogue: guests see the table without prices/order columns and
   this one-line prompt to sign in (or to become a dealer) instead. */
.guest-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  padding: 10px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  border-left: 4px solid var(--color-primary);
  background: var(--color-success-bg);
  color: var(--color-primary-dark);
  font-size: 0.9rem;
}
.guest-notice a { font-weight: 600; text-decoration: underline; }

.result-count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* ---- Status badges ---- */

.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge--placed { background: #e8eaf0; color: #3d4560; }
.badge--in_review { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--quote_sent { background: #e6effa; color: #1c5aa3; }
.badge--queued_for_machining { background: #f1e9fa; color: #6a3cad; }
.badge--dispatched { background: var(--color-success-bg); color: var(--color-primary); }

.stock--in { color: var(--color-primary); font-weight: 600; }
.stock--out { color: var(--color-danger); font-weight: 600; }

/* ---- Utility ---- */

.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
/* Basket: one vehicle-details block per line item (each product in the
   basket can be going on a different car), stacked in their own card next
   to Delivery rather than as extra columns in the fitment table — the
   table was the wrong place for free-text vehicle fields since it forced
   them into narrow, horizontally-scrolling cells no matter how the other
   columns were sized. */
.vehicle-details-line {
  padding: 16px 0;
  border-top: 1px solid var(--color-border);
}
.vehicle-details-line:first-of-type {
  border-top: none;
  padding-top: 4px;
}
.vehicle-details-line__title {
  margin: 0 0 12px;
  font-size: 0.95rem;
}
/* "Same vehicle as previous line" — mirrored, read-only fields (see the
   inline script in cart.html), styled to look inert rather than a normal
   editable field. */
.field--linked {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.cluster { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pagination { margin-top: 20px; font-size: 0.88rem; }
.pagination a { margin: 0 8px; }

@media (max-width: 640px) {
  .site-header__inner { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 8px; }
  .page { padding: 20px 14px 48px; }
  .card { padding: 20px; }
}
