/* components.css: buttons, forms, cards, tables, badges, dialogs, toasts, tabs, accordions, steps. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 46px; padding: 0.6rem 1.25rem; font-weight: 600; font-size: 1rem; line-height: 1.2;
  border-radius: 6px; border: 2px solid transparent; text-decoration: none; cursor: pointer;
  background: var(--accent-fill); color: var(--on-accent);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-hi); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--plate); border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #3A0A04; }
.btn-dark { background: var(--deep); color: var(--ink); }
.btn-dark:hover { background: var(--plate-deep); }
.btn-sm { min-height: 40px; padding: 0.3rem 0.9rem; font-size: 0.9375rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-align: left; font: inherit; color: inherit; }
.linklike:hover, .textlink:hover { color: var(--accent); }
.textlink { font-family: var(--font-display); font-weight: 600; text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; min-width: 0; }
.field > label, .field > legend, .lbl { display: block; font-weight: 600; font-size: 0.9688rem; margin-bottom: 0.35rem; padding: 0; }
.field .opt { font-weight: 400; color: var(--muted); }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"],
input[type="date"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: 46px; padding: 0.55rem 0.8rem; font: inherit; font-size: 1.0625rem;
  background: var(--plate-deep); color: var(--ink); border: 2px solid var(--line); border-radius: 6px;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); margin: 0; flex: none; }
.check { display: flex; gap: 0.65rem; align-items: flex-start; cursor: pointer; font-weight: 400 !important; }
.check input { margin-top: 0.3rem; }
.hint { margin-top: 0.4rem; font-size: var(--step--1); color: var(--muted); line-height: 1.45; }
.hint.error, .error-text { color: var(--bad); font-weight: 600; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 36rem) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.row-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* Segmented chips (radio look) */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 1rem; border: 2px solid var(--line);
  border-radius: 999px; font-family: var(--font-display); font-weight: 500; font-size: 0.9688rem; transition: all 0.15s;
}
.chip input:checked + span { background: var(--accent-fill); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.chip:hover span { border-color: var(--muted); }
.tag-chip { display: inline-block; padding: 0.15rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; font-family: var(--font-display); font-size: 0.8125rem; color: var(--muted); }

/* Color swatches */
.swatch-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.swatch { position: relative; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.swatch span { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--c); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line); transition: box-shadow 0.15s; }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 4px; }
.swatch.silk span { background: linear-gradient(135deg, var(--c), #fff 45%, var(--c) 60%); }

/* Quantity stepper */
.qty { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 6px; }
.qty button { width: 42px; height: 42px; background: none; border: 0; cursor: pointer; font-size: 1.25rem; line-height: 1; }
.qty button:hover { background: var(--plate); }
.qty output, .qty input { min-width: 2.5rem; text-align: center; font-family: var(--font-display); font-weight: 600; background: none; border: 0; min-height: 0; padding: 0; width: 3rem; }

/* ---------- Surfaces ---------- */
.card { background: var(--plate); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel { background: var(--plate); border: 1px solid var(--line); border-radius: 10px; padding: clamp(1rem, 2.5vw, 1.5rem); }
.panel > h2, .panel > h3 { margin-bottom: 0.9rem; }
.well { background: var(--plate-deep); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid var(--line); font-family: var(--font-display); font-size: 0.9688rem; }
.kv:first-child { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }
.notice { padding: 0.8rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--plate-deep); font-size: var(--step--1); }
.notice.proto { border-color: var(--star); background: rgba(255, 193, 90, 0.08); }
.notice.ok { border-color: var(--ok); background: rgba(91, 208, 139, 0.08); }
.notice.bad { border-color: var(--bad); background: rgba(255, 156, 143, 0.08); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 0.4rem; }
.empty .btn { margin-top: 1rem; }

/* Badges / status */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.12rem 0.65rem; border-radius: 999px; font-family: var(--font-display); font-size: 0.8125rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.badge::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.s-received, .s-pending, .s-open { color: var(--info); }
.s-printing, .s-queued, .s-priced { color: var(--warn); }
.s-ready, .s-shipped { color: var(--accent); }
.s-delivered, .s-approved, .s-closed-ok, .s-paid { color: var(--ok); }
.s-issue, .s-cancelled, .s-refunded, .s-closed { color: var(--bad); }
.s-neutral { color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--plate); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9688rem; min-width: 38rem; }
table.data th, table.data td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { background: var(--plate-deep); font-size: 0.8438rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.data tbody tr:last-child td, table.data tbody tr:last-child th { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(76, 141, 255, 0.05); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data a { text-underline-offset: 3px; }
table.data tbody th { font-weight: 600; }

/* Tabs / filter bar */
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 42px; padding: 0 1rem; border: 2px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; font-family: var(--font-display); font-weight: 500; text-decoration: none; font-size: 0.9688rem; }
.tab:hover { border-color: var(--muted); }
.tab[aria-selected="true"], .tab[aria-pressed="true"], .tab[aria-current="true"], .tab.on { background: var(--accent-fill); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.tab .n { font-size: 0.8125rem; opacity: 0.8; }
.toolbar { display: flex; gap: 0.75rem 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
.toolbar .tools { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar select { width: auto; min-width: 11rem; }

/* Accordion */
details.acc { border-top: 1px solid var(--line); }
details.acc:last-of-type { border-bottom: 1px solid var(--line); }
details.acc summary { list-style: none; cursor: pointer; padding: 1rem 2.5rem 1rem 0; position: relative; font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; min-height: 48px; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: "+"; position: absolute; right: 0.25rem; top: 50%; transform: translateY(-50%); font-size: 1.5rem; font-weight: 400; color: var(--accent); }
details.acc[open] summary::after { content: "−"; }
details.acc .acc-body { padding: 0 0 1.1rem; color: var(--muted); max-width: 46rem; }

/* Steps */
.steps { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); counter-reset: step; }
.steps > li { border-top: 3px solid var(--accent); padding-top: 0.9rem; counter-increment: step; }
.steps > li::before { content: counter(step); display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--accent); margin-bottom: 0.3rem; }
.steps h3 { font-size: 1.25rem; margin-bottom: 0.4rem; }
.steps p { color: var(--muted); font-size: 1rem; }

/* Progress */
.progress { height: 0.6rem; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent-fill); border-radius: 4px; }
.tracker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.25rem; margin-top: 0.8rem; }
.tracker li { font-family: var(--font-display); font-size: 0.8125rem; color: var(--muted); text-align: center; padding-top: 0.6rem; border-top: 4px solid var(--line); }
.tracker li.done { border-color: var(--accent); color: var(--ink); }
.tracker li.now { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* ---------- Product card ---------- */
.products { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); }
.pcard { display: flex; flex-direction: column; background: var(--plate); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.pcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.pcard .pimg { aspect-ratio: 1 / 1; background: var(--plate-deep); display: block; overflow: hidden; }
.pcard .pimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .pbody { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.pcard h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.pcard h3 a { text-decoration: none; }
.pcard h3 a::after { content: ""; position: absolute; inset: 0; }
.pcard { position: relative; }
.pcard .pmeta { color: var(--muted); font-size: 0.9rem; }
.pcard .pprice { margin-top: auto; padding-top: 0.5rem; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ph { background: repeating-linear-gradient(135deg, #16324b 0 8px, #12293f 8px 16px); display: grid; place-items: center; color: var(--muted); font-family: var(--font-display); font-size: 0.9rem; text-align: center; width: 100%; height: 100%; }

/* ---------- Dialog / drawer ---------- */
dialog { padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--plate); color: var(--ink); width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 1.5rem); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
dialog::backdrop { background: rgba(3, 9, 16, 0.7); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 1.4rem; }
.dlg-body { padding: 1.25rem 1.4rem; overflow: auto; max-height: calc(100vh - 12rem); }
.dlg-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--line); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; border-radius: 0; border-width: 0 0 0 1px; width: min(26rem, 100vw); flex-direction: column; }
dialog.drawer[open] { display: flex; }
dialog.drawer .dlg-body { flex: 1; max-height: none; }
.close-x { min-height: 40px; padding: 0 0.9rem; background: none; border: 2px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 600; }
.close-x:hover { border-color: var(--ink); }

/* Cart lines */
.cart-line { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: 0.2rem 0.9rem; align-items: center; padding: 1rem 0; border-top: 1px solid var(--line); }
.cart-line:first-child { border-top: 0; }
.cart-line img, .cart-line .ph { width: 4.5rem; height: 4.5rem; object-fit: cover; border-radius: 6px; grid-row: 1 / span 2; }
.cart-line .t { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
.cart-line .m { color: var(--muted); font-size: 0.875rem; }
.cart-line .p { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.cart-line .ctl { grid-column: 2 / -1; display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* Toast */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 300; display: grid; gap: 0.5rem; max-width: calc(100vw - 2rem); }
.toast { background: var(--ink); color: var(--paper); padding: 0.75rem 1rem; border-radius: 8px; font-family: var(--font-display); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); animation: toast-in 0.25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dropzone */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem; text-align: center; min-height: 9rem; padding: 1.25rem; border: 2px dashed var(--accent); border-radius: 10px; background: var(--plate-deep); cursor: pointer; transition: background-color 0.15s; font-family: var(--font-display); }
.dropzone:hover, .dropzone.over { background: rgba(76, 141, 255, 0.1); }
.dropzone strong { font-size: 1.125rem; }
.dropzone small { font-family: var(--font-body); color: var(--muted); font-size: 0.9rem; }
.dropzone:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Misc */
.divider { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.price-big { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 1.5rem + 2vw, 3rem); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.4rem; margin: 2rem 0 0.6rem; }
.prose p, .prose li { color: #C9D9E4; }
.prose p + p { margin-top: 0.9rem; }
.prose ul { list-style: disc; padding-left: 1.3rem; margin: 0.6rem 0; }
.prose li + li { margin-top: 0.35rem; }
.prose a { text-underline-offset: 3px; }
.prose a:hover { color: var(--accent); }

/* Out-of-stock colors and materials on the quote page */
.swatch.out span:first-of-type { background: repeating-linear-gradient(45deg, var(--c) 0 4px, transparent 4px 8px); opacity: .55; }
.swatch.out input { cursor: not-allowed; }
.chip.out { opacity: .5; text-decoration: line-through; }
.chip.out input { cursor: not-allowed; }
.cwait { margin-top: .75rem; }

/* Long names (like a custom photo file name) wrap instead of running out of the box */
.cart-line > div { min-width: 0; }
.cart-line .t, .cart-line .m, .kv span, .kv b { overflow-wrap: anywhere; word-break: break-word; }
.kv { gap: .75rem; }
.kv span { min-width: 0; }

/* low-stock colors: amber dot on the swatch and a warning note under the row */
.swatch.low::after { content: ""; position: absolute; right: -1px; top: -1px; width: 13px; height: 13px; border-radius: 50%; background: #f5a524; border: 2px solid var(--paper); pointer-events: none; }
#clow { margin: .5rem 0 0; }
#clow.hot { font-weight: 600; }
.notice.warn { border-color: #f5a524; background: rgba(245, 165, 36, 0.10); }

/* summary rows: the amount never breaks into pieces ("Fre / e"); the label wraps instead */
#ssum .kv b, #sum .kv b { white-space: nowrap; word-break: normal; overflow-wrap: normal; flex-shrink: 0; }
/* long text in a row (like a history note) wraps in its own column and never squeezes the date */
.hist .kv { align-items: flex-start; }
.hist .kv > span:first-child { flex: 0 0 auto; white-space: nowrap; }
.hist .kv > b { min-width: 0; overflow-wrap: anywhere; }
