/* Co-Mac staff parts finder, styled to match comac.nz (Shopify Dawn theme "Co-Mac Live").
   From the live theme: blue header and footer #0f73c2, navy text #374261 (body copy at 75%),
   green pill buttons #8dbf42 with white labels, gold #ffd700, Open Sans 600 body and 700 headings,
   search box border #d5dde4 with 6px corners, square form inputs, 12px card corners, pill badges. */

@font-face { font-family: 'Open Sans'; font-weight: 400; font-display: swap; src: url('fonts/open-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-weight: 600; font-display: swap; src: url('fonts/open-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-weight: 700; font-display: swap; src: url('fonts/open-sans-latin-700-normal.woff2') format('woff2'); }

:root {
  --blue: #0f73c2;
  --navy: #374261;
  --text: rgba(55, 66, 97, 0.75);
  --green: #8dbf42;
  --green-600: #7cad35;
  --gold: #ffd700;
  --gold-hover: #ffe14a;
  --line: #d5dde4;
  --line-soft: #e8edf2;
  --tint: #f3f7fb;
  --placeholder: #8a939c;
  --surface: #ffffff;
  --warn-bg: #fff4d1;
  --warn-line: #e9c65a;
  --warn-ink: #634800;
  --danger: #a8261e;
  --font: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --appbar-h: 72px;
  --sidebar-w: 280px;
  --thread-w: 46rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.0375em;
  color: var(--text);
  background: var(--surface);
}
button, input, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }

/* Product code badge: gold pill, click to copy */
.tag {
  position: relative;
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  background: var(--gold);
  border: 0;
  border-radius: 999px;
  padding: 0 0.7em;
  margin-right: 0.4em;
  cursor: copy;
}
.tag:hover { background: var(--gold-hover); }
.tag.copied::after {
  content: 'Copied';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  color: #fff;
  background: var(--navy);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Buttons, as on comac.nz */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 47px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
}
.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.btn-new svg { width: 1rem; height: 1rem; stroke-width: 2.5; }
.btn-primary:hover, .btn-new:hover { background: var(--green-600); }
.btn-quiet { background: none; border: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; padding: 0.25rem 0; }
.btn-small { border: 1px solid var(--navy); background: var(--surface); color: var(--navy); border-radius: 999px; padding: 0.3rem 0.9rem; font-weight: 600; font-size: 0.85rem; }

/* Blue header band, as on comac.nz */
.appbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: var(--appbar-h);
  padding: 0 1.5rem;
  background: var(--blue);
  color: #fff;
}
.appbar :focus-visible { outline-color: #fff; }
.appbar-logo { display: block; width: 140px; height: auto; }
.me-bar { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: 15px; }
.me-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me form { margin: 0; }
.btn-menu { display: none; border: 0; background: none; padding: 0.4rem; margin-left: -0.4rem; border-radius: 6px; color: #fff; }

/* ---------- Sign in ---------- */
.login { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.login-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: clamp(2rem, 10vh, 6rem) 1.25rem 3rem; }
.login-form { width: 100%; max-width: 24rem; display: flex; flex-direction: column; }
.login-form h1 { font-size: 2rem; line-height: 1.25; font-weight: 700; color: var(--navy); margin: 0 0 0.4rem; }
.login-lede { margin: 0 0 1.25rem; }
.login-form label { font-weight: 700; font-size: 15px; color: var(--navy); margin-top: 1.1rem; margin-bottom: 0.4rem; }
.login-form input {
  min-height: 45px;
  padding: 0 15px;
  border: 1px solid rgba(55, 66, 97, 0.55);
  border-radius: 0;
  background: var(--surface);
  color: var(--navy);
}
.login-form .btn-primary { margin-top: 1.6rem; }
.hint { font-size: 13px; margin: 0.4rem 0 0; }
.login-error { margin: 0.25rem 0; padding: 0.65rem 0.85rem; border-radius: 6px; background: #fdecea; color: var(--danger); font-weight: 700; }

/* ---------- App layout ---------- */
/* Browser extensions (password managers, Hudu, Grammarly) add their own elements to <body>.
   The header, sidebar and chat are pinned to the first two rows and any extra rows get no
   height, so those elements can't take a slice of the screen or push the layout around. */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-auto-rows: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.app .appbar { grid-area: 1 / 1 / 2 / 3; }

.sidebar {
  grid-area: 2 / 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.history { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.history h3 { font-size: 13px; font-weight: 700; color: var(--navy); margin: 1rem 0.65rem 0.3rem; }
.history h3:first-of-type { margin-top: 0.2rem; }
.history ul { list-style: none; margin: 0; padding: 0; }
.chat-link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  color: var(--text);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-link:hover { background: var(--tint); color: var(--navy); }
.chat-link[aria-current='true'] { background: rgba(15, 115, 194, 0.08); color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.history-empty { font-size: 14px; margin: 0.4rem 0.65rem; }
.me-drawer { display: none; }

.main { grid-area: 2 / 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.titlebar { padding: 0.9rem 1.5rem; border-bottom: 1px solid var(--line-soft); }
.chat-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 1.75rem 1.5rem 1rem; scroll-behavior: smooth; }
.thread > * { max-width: var(--thread-w); margin-left: auto; margin-right: auto; }

/* Empty state */
.empty { padding: clamp(1.25rem, 7vh, 4.5rem) 0 1rem; }
.empty h2 { font-size: clamp(1.75rem, 3.2vw, 2.1rem); line-height: 1.25; font-weight: 700; color: var(--navy); margin: 0 0 0.5rem; }
.empty p { margin: 0 0 1.6rem; max-width: 36rem; }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.example {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--navy);
  font-size: 15px;
  line-height: 1.5;
}
.example:hover { border-color: var(--blue); color: var(--blue); }

/* Messages */
.msg { margin-top: 1.5rem; margin-bottom: 0; }
.msg:first-child { margin-top: 0; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user p {
  margin: 0;
  max-width: min(85%, 34rem);
  background: var(--navy);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  padding: 0.6rem 1rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.answer { overflow-wrap: anywhere; }
.answer p { margin: 0 0 0.8rem; max-width: 42rem; }
.answer p:last-child { margin-bottom: 0; }
.answer ul, .answer ol { margin: 0 0 0.8rem; padding-left: 1.3rem; }
.answer strong { font-weight: 700; color: var(--navy); }
.answer a.lnk-text { color: var(--blue); }
.parts { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 0.9rem; }
.part {
  display: grid;
  grid-template-columns: minmax(4.75rem, max-content) minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0.5rem;
  padding: 0.8rem 1rem;
  line-height: 1.6;
  color: var(--navy);
}
.part + .part { border-top: 1px solid var(--line-soft); }
.part .tag { justify-self: start; }
.part-text { min-width: 0; }
.lnk-view, .lnk-admin {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.6;
  text-decoration: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.05rem 0.7rem;
  margin-left: 0.2rem;
  white-space: nowrap;
}
.lnk-view { color: var(--blue); }
.lnk-admin { color: var(--navy); }
.lnk-view:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.lnk-admin:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.badge-draft {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #6b4f00;
  background: #fff0c4;
  border-radius: 999px;
  padding: 0 0.55rem;
  white-space: nowrap;
}
.answer p.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-weight: 700;
}

/* Product cards, laid out like the comac.nz search results: photo, name, price and code,
   then the points that matter for the question and an outlined button. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.85rem; margin: 0 0 0.9rem; }
.card { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card-is-best { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.card-top { position: relative; }
.card-media { display: block; aspect-ratio: 1 / 1; background: var(--surface); border-bottom: 1px solid var(--line-soft); text-decoration: none; }
.card-media img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 0.6rem; }
.card-nophoto { display: grid; place-items: center; width: 100%; height: 100%; background: var(--tint); font-size: 13px; color: var(--placeholder); }
.card-badges { position: absolute; left: 0.5rem; bottom: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.card-badge { font-size: 12px; font-weight: 700; line-height: 1.7; letter-spacing: 0.02em; border-radius: 999px; padding: 0 0.6rem; }
.card-best { background: var(--green); color: var(--navy); }
.card-draft { background: #fff0c4; color: #6b4f00; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem 0.85rem 0.85rem; }
.card-title { margin: 0; font-size: 14px; line-height: 1.4; font-weight: 700; color: var(--navy); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card-price { font-size: 15px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.card-price small { font-size: 12px; font-weight: 600; color: var(--text); }
.card-meta .tag { margin-right: 0; font-size: 0.85rem; }
.card-points { margin: 0; padding-left: 1.05rem; font-size: 13px; line-height: 1.5; color: var(--navy); }
.card-points li + li { margin-top: 0.15rem; }
.card-action {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--navy);
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.card-action:hover { background: var(--navy); color: #fff; }

.msg-meta { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.45rem; font-size: 13px; }
.fb { border: 0; background: none; padding: 0.3rem; border-radius: 6px; color: var(--text); line-height: 0; }
.fb svg { width: 1.05rem; height: 1.05rem; }
.fb:hover { background: var(--tint); color: var(--navy); }
.fb[aria-pressed='true'].fb-up { color: #4f7f17; background: #e8f3da; }
.fb[aria-pressed='true'].fb-down { color: var(--danger); background: #fdecea; }
.took { margin-left: 0.4rem; }
.fb-note { display: flex; align-items: flex-end; gap: 0.5rem; margin-top: 0.5rem; max-width: 34rem; }
.fb-note label { flex: 1; display: flex; flex-direction: column; gap: 0.3rem; font-size: 14px; font-weight: 700; color: var(--navy); }
.fb-note input { min-height: 38px; border: 1px solid rgba(55, 66, 97, 0.55); border-radius: 0; padding: 0 0.7rem; background: var(--surface); color: var(--navy); }
.fb-note input:focus-visible, .login-form input:focus-visible { outline: 3px solid rgba(15, 115, 194, 0.28); outline-offset: 0; border-color: var(--blue); }
.fb-thanks { font-size: 13px; margin: 0.4rem 0 0; }

.searching { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: bob 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bob { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-4px); opacity: 1; } }

.msg-error p { margin: 0 0 0.5rem; color: var(--danger); font-weight: 700; }

/* Composer, shaped like the comac.nz search box */
.composer {
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  width: calc(100% - 3rem);
  max-width: var(--thread-w);
  border-radius: 6px;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 12rem;
  resize: none;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  background: var(--surface);
  padding: 0.7rem 0.9rem;
  line-height: 1.45;
  color: #1a1a1a;
  outline: 0;
}
.composer textarea::placeholder { color: var(--placeholder); opacity: 1; }
.composer:focus-within { box-shadow: 0 0 0 3px rgba(15, 115, 194, 0.22); }
.composer:focus-within textarea { border-color: var(--blue); }
.btn-send {
  flex: none;
  width: 52px;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
}
.btn-send svg { stroke-width: 2.5; }
.btn-send:hover { background: var(--green-600); }
.btn-send:disabled { background: #cfd8e0; cursor: not-allowed; }
.composer-note { text-align: center; font-size: 13px; margin: 0.5rem 1rem 0.9rem; }

.scrim { display: none; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 860px) {
  :root { --appbar-h: 60px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .app .appbar { grid-column: 1; }
  .appbar { padding: 0 0.75rem; gap: 0.75rem; }
  .appbar-logo { width: 110px; }
  .btn-new { margin-left: auto; }
  .me-bar { display: none; }
  .btn-menu { display: inline-flex; }
  .main { grid-area: 2 / 1; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    z-index: 20;
    border-right: 0;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, 0.3); }
  .me-drawer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.8rem 0.65rem 0;
    border-top: 1px solid var(--line);
    color: var(--navy);
    font-size: 15px;
  }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 25, 40, 0.45); z-index: 10; }
  .titlebar { padding: 0.75rem 1rem; }
  .thread { padding: 1.1rem 1rem 0.75rem; }
  .composer { width: calc(100% - 1.5rem); }
  .examples { grid-template-columns: minmax(0, 1fr); }
}

/* Two cards side by side on phones, so a set of photos can still be scanned at a glance */
@media (max-width: 520px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .card-body { padding: 0.6rem; gap: 0.4rem; }
  .card-title { font-size: 13px; }
  .card-meta { flex-wrap: wrap; }
  .card-price { font-size: 14px; }
  .card-points { font-size: 12px; }
}

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