/* Reusable components. Values come from tokens.css only. */

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--yo-s2);
  height: var(--yo-control-h); padding: 0 18px;
  border-radius: var(--yo-r-control); border: 1px solid transparent;
  font-size: var(--yo-fs-body); font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background var(--yo-ease), border-color var(--yo-ease), color var(--yo-ease), box-shadow var(--yo-ease);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--yo-focus); }
.btn-primary { background: var(--yo-red); color: var(--yo-surface); }
.btn-primary:hover { background: var(--yo-red-hover); }
.btn-secondary { background: var(--yo-surface); color: var(--yo-ink); border-color: var(--yo-border-strong); }
.btn-secondary:hover { background: var(--yo-hover); }
.btn-ghost { background: transparent; color: var(--yo-text); }
.btn-ghost:hover { background: var(--yo-hover); }
.btn-danger { background: var(--yo-surface); color: var(--yo-error); border-color: var(--yo-border-strong); }
.btn-danger:hover { background: var(--yo-error-bg); border-color: var(--yo-error); }
.btn-danger-solid { background: var(--yo-error); color: var(--yo-surface); }
.btn-danger-solid:hover { filter: brightness(0.94); }
.btn-sm { height: 34px; padding: 0 12px; font-size: var(--yo-fs-small); border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: var(--yo-fs-body-lg); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled {
  background: var(--yo-disabled-bg); color: var(--yo-subtle); border-color: var(--yo-border);
  cursor: not-allowed; pointer-events: none;
}
.btn .spinner { width: 16px; height: 16px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--yo-ink); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--yo-s4); }
.label { font-size: var(--yo-fs-small); font-weight: 600; color: var(--yo-ink); }
.label .req { color: var(--yo-red); margin-left: 2px; }
.help { font-size: var(--yo-fs-small); color: var(--yo-muted); }
.error-text { font-size: var(--yo-fs-small); color: var(--yo-error); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.error-text svg { flex: 0 0 auto; margin-top: 2px; }
.input, .select {
  width: 100%; height: var(--yo-control-h); padding: 0 14px;
  border: 1px solid var(--yo-border-strong); border-radius: var(--yo-r-control);
  background: var(--yo-surface); color: var(--yo-ink); font-size: var(--yo-fs-body-lg);
  transition: border-color var(--yo-ease), box-shadow var(--yo-ease);
}
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input::placeholder { color: var(--yo-subtle); }
.input:focus, .select:focus { outline: none; border-color: var(--yo-red); box-shadow: var(--yo-focus); }
.input[disabled], .select[disabled] { background: var(--yo-disabled-bg); color: var(--yo-muted); }
.input.is-invalid { border-color: var(--yo-error); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px var(--yo-error-bg); }
.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-group .addon {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 36px; border: 0; background: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--yo-muted); cursor: pointer;
}
.input-group .addon:hover { background: var(--yo-hover); color: var(--yo-ink); }
.check { display: inline-flex; align-items: center; gap: var(--yo-s2); font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--yo-red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--yo-s4) var(--yo-s5); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .field + .field { margin-top: 0; }
.form-actions { display: flex; gap: var(--yo-s3); margin-top: var(--yo-s5); flex-wrap: wrap; align-items: center; }
.form-actions.between { justify-content: space-between; align-items: flex-end; }
.form-actions.end { justify-content: flex-end; }
.form-actions.flush-top { margin-top: 0; }
.form-actions .field.fixed { flex: 0 1 320px; }

.output-choice { border: 0; margin: 0 0 var(--yo-s5); padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--yo-s3); }
.output-choice legend { margin-bottom: var(--yo-s3); }
.output-choice .help, .output-choice .error-text { grid-column: 1 / -1; }
.choice {
  display: flex; gap: var(--yo-s3); align-items: flex-start; padding: var(--yo-s4);
  border: 1px solid var(--yo-border-strong); border-radius: var(--yo-r-control); cursor: pointer;
  transition: border-color var(--yo-ease), background var(--yo-ease);
}
.choice:hover { border-color: var(--yo-ink); }
.choice:has(input:checked) { border-color: var(--yo-red); background: var(--yo-red-soft); }
.choice:focus-within { box-shadow: var(--yo-focus); }
.choice input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--yo-red); flex: 0 0 auto; }
.choice .text { font-weight: 600; color: var(--yo-ink); }
.choice .text small { display: block; margin-top: 2px; font-weight: 400; color: var(--yo-muted); font-size: var(--yo-fs-small); }
.choice.is-disabled { cursor: not-allowed; background: var(--yo-surface-alt); }
.choice.is-disabled .text { color: var(--yo-muted); }

/* ------------------------------------------------------------ surfaces */
.card {
  background: var(--yo-surface); border: 1px solid var(--yo-border);
  border-radius: var(--yo-r-card); padding: var(--yo-s5);
}
.card + .card { margin-top: var(--yo-s5); }
.card-head { display: flex; align-items: center; gap: var(--yo-s3); margin-bottom: var(--yo-s4); }
.card-head h2, .card-head h3 { flex: 1; }
.card-head p { color: var(--yo-muted); }
.card.flush { padding: 0; overflow: hidden; }
.card.inline-card { display: flex; gap: var(--yo-s3); flex-wrap: wrap; align-items: center; }
.card.inline-card > p { flex: 1; min-width: 240px; }
.card.flush > .card-head { padding: var(--yo-s5) var(--yo-s5) 0; }
.divider { border: 0; border-top: 1px solid var(--yo-border); margin: var(--yo-s5) 0; }

/* ------------------------------------------------------------ status pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--yo-r-pill); font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--yo-success-bg); color: var(--yo-success); }
.pill-warning { background: var(--yo-warning-bg); color: var(--yo-warning); }
.pill-error { background: var(--yo-error-bg); color: var(--yo-error); }
.pill-info { background: var(--yo-info-bg); color: var(--yo-info); }
.pill-neutral { background: var(--yo-neutral-bg); color: var(--yo-neutral); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px;
  border: 1px solid var(--yo-border); border-radius: 6px; background: var(--yo-surface);
  font-size: var(--yo-fs-label); font-weight: 600; color: var(--yo-text); white-space: nowrap;
}
.badge svg { color: var(--yo-muted); }
.env-badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--yo-warning-bg); color: var(--yo-warning); font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.neutral-badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--yo-neutral-bg); color: var(--yo-neutral); font-size: var(--yo-fs-label); font-weight: 600;
  vertical-align: middle;
}

/* ------------------------------------------------------------ tables */
.table-wrap { position: relative; width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--yo-fs-body); }
.table th {
  text-align: left; padding: 12px var(--yo-s4); white-space: nowrap;
  font-size: var(--yo-fs-label); font-weight: 600; color: var(--yo-muted);
  border-bottom: 1px solid var(--yo-border); background: var(--yo-surface);
}
.table td { padding: 0 var(--yo-s4); height: 60px; border-bottom: 1px solid var(--yo-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--yo-surface-alt); }
.table .actions { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 600; color: var(--yo-ink); }
.table .sub { display: block; font-size: var(--yo-fs-label); color: var(--yo-muted); }
.table-footer { padding: var(--yo-s3) var(--yo-s4); border-top: 1px solid var(--yo-border); color: var(--yo-muted); font-size: var(--yo-fs-small); }

/* ------------------------------------------------------------ banners */
.banner {
  display: flex; gap: var(--yo-s3); align-items: flex-start;
  padding: 14px var(--yo-s4); border-radius: 12px; border: 1px solid transparent;
  margin-bottom: var(--yo-s5); font-size: var(--yo-fs-body);
}
.banner svg { flex: 0 0 auto; margin-top: 1px; }
.banner .body { flex: 1; }
.banner .title { font-weight: 650; color: var(--yo-ink); }
.banner-error { background: var(--yo-error-bg); border-color: var(--yo-error-bg); color: var(--yo-error); }
.banner-warning { background: var(--yo-warning-bg); color: var(--yo-warning); }
.banner-success { background: var(--yo-success-bg); color: var(--yo-success); }
.banner-info { background: var(--yo-info-bg); color: var(--yo-info); }
.banner .dismiss { border: 0; background: none; cursor: pointer; color: inherit; padding: 2px; border-radius: 6px; }

/* ------------------------------------------------------------ stepper */
.stepper { display: flex; align-items: center; gap: var(--yo-s3); margin: 0 0 var(--yo-s6); padding: 0; list-style: none; max-width: 640px; }
.step { display: flex; align-items: center; gap: var(--yo-s2); color: var(--yo-muted); font-weight: 500; white-space: nowrap; }
.step .num {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--yo-border-strong); background: var(--yo-surface); font-size: var(--yo-fs-small); font-weight: 650;
}
.step.active { color: var(--yo-ink); font-weight: 600; }
.step.active .num { background: var(--yo-red); border-color: var(--yo-red); color: var(--yo-surface); }
.step.done { color: var(--yo-ink); }
.step.done .num { background: var(--yo-red-soft); border-color: var(--yo-red-soft); color: var(--yo-red); }
.step-line { flex: 1; height: 1px; background: var(--yo-border-strong); min-width: 24px; }
.step-line.done { background: var(--yo-red); }

/* ------------------------------------------------------------ dropzone / loader */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  position: relative; gap: var(--yo-s3); padding: var(--yo-s8) var(--yo-s5); min-height: 280px;
  border: 1.5px dashed var(--yo-border-strong); border-radius: var(--yo-r-card);
  background: var(--yo-surface); cursor: pointer;
  transition: border-color var(--yo-ease), background var(--yo-ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--yo-red); background: var(--yo-red-soft); }
.dropzone:focus-within { border-color: var(--yo-red); box-shadow: var(--yo-focus); }
.dropzone .icon-tile { margin-bottom: var(--yo-s2); }
.dropzone .title { font-size: var(--yo-fs-card); font-weight: 650; color: var(--yo-ink); }
.dropzone .file-name { font-weight: 600; color: var(--yo-ink); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.icon-tile {
  width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--yo-red-soft); color: var(--yo-red); flex: 0 0 auto;
}
.icon-tile.neutral { background: var(--yo-neutral-bg); color: var(--yo-neutral); }
.icon-tile.success { background: var(--yo-success-bg); color: var(--yo-success); }
.progress-card { display: flex; align-items: center; gap: var(--yo-s4); }
.progress-card .title { font-weight: 650; color: var(--yo-ink); font-size: var(--yo-fs-card); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--yo-border-strong); border-top-color: var(--yo-red); animation: yo-spin 0.9s linear infinite; flex: 0 0 auto; }
@keyframes yo-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ empty state */
.empty { text-align: center; padding: var(--yo-s8) var(--yo-s5); }
.empty .icon-tile { margin: 0 auto var(--yo-s4); }
.empty h3 { margin-bottom: var(--yo-s2); }
.empty p { color: var(--yo-muted); margin-bottom: var(--yo-s5); }

/* ------------------------------------------------------------ switch */
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: var(--yo-r-pill); background: var(--yo-border-strong); transition: background var(--yo-ease); }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--yo-surface); box-shadow: var(--yo-shadow-knob); transition: transform var(--yo-ease);
}
.switch input:checked + .track { background: var(--yo-red); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--yo-focus); }

/* ------------------------------------------------------------ dialog */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--yo-r-modal);
  box-shadow: var(--yo-shadow-pop); color: var(--yo-text);
}
dialog.modal::backdrop { background: var(--yo-overlay); }
dialog.modal .modal-body { padding: var(--yo-s5) var(--yo-s5) 0; }
dialog.modal h2 { font-size: var(--yo-fs-card); margin-bottom: var(--yo-s2); }
dialog.modal p { color: var(--yo-muted); }
dialog.modal .modal-actions { display: flex; justify-content: flex-end; gap: var(--yo-s3); padding: var(--yo-s5); }

/* ------------------------------------------------------------ menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; min-width: 190px;
  background: var(--yo-surface); border: 1px solid var(--yo-border); border-radius: 12px;
  box-shadow: var(--yo-shadow-pop); padding: 6px;
}
.menu-list a, .menu-list button {
  display: flex; width: 100%; align-items: center; gap: var(--yo-s2); padding: 8px 10px; border: 0; background: none;
  border-radius: 8px; color: var(--yo-text); font-size: var(--yo-fs-small); font-weight: 500; text-align: left; cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--yo-hover); text-decoration: none; }
.menu-list .danger { color: var(--yo-error); }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: 8px; color: var(--yo-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--yo-hover); color: var(--yo-ink); }

/* ------------------------------------------------------------ filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--yo-s3); align-items: flex-end; padding: var(--yo-s4) var(--yo-s5); border-bottom: 1px solid var(--yo-border); }
.filter-bar .field { min-width: 0; flex: 0 1 150px; }
.filter-bar .field.grow { flex: 1 1 160px; }
.filter-bar .field.date { flex: 0 1 140px; }
.filter-bar input[type=date] { padding: 0 10px; }
.filter-bar .field + .field { margin-top: 0; }
.filter-bar .input, .filter-bar .select { height: 40px; font-size: var(--yo-fs-body); }
.filter-bar .label { font-size: var(--yo-fs-label); color: var(--yo-muted); }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; right: var(--yo-s5); bottom: var(--yo-s5); z-index: 60;
  display: flex; gap: var(--yo-s3); align-items: center; padding: 12px var(--yo-s4);
  background: var(--yo-ink); color: var(--yo-surface); border-radius: 12px; box-shadow: var(--yo-shadow-pop);
  font-weight: 500; transition: opacity var(--yo-ease), transform var(--yo-ease);
}
.toast.is-hiding { opacity: 0; transform: translateY(6px); }

@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .output-choice { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .stepper .step span.text { display: none; }
  .stepper .step.active span.text { display: inline; }
  .filter-bar { padding: var(--yo-s4); }
  .filter-bar .field, .filter-bar .field.grow, .filter-bar .field.date { flex: 1 1 100%; }
  .table .hide-sm { display: none; }
  /* Document lists become stacked rows: type + status / VIN / date + actions */
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody { display: block; }
  .table.stack-sm tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    grid-template-areas: "type status" "vin vin" "date actions";
    gap: 6px var(--yo-s3); padding: var(--yo-s3) var(--yo-s4); border-bottom: 1px solid var(--yo-border);
  }
  .table.stack-sm tbody tr:last-child { border-bottom: 0; }
  .table.stack-sm td { display: block; height: auto; padding: 0; border: 0; }
  .table.stack-sm tbody tr:hover td { background: none; }
  .table.stack-sm .c-type { grid-area: type; }
  .table.stack-sm .c-status { grid-area: status; justify-self: end; }
  .table.stack-sm .c-vin { grid-area: vin; font-size: var(--yo-fs-body-lg); overflow-wrap: anywhere; }
  .table.stack-sm .c-date { grid-area: date; color: var(--yo-muted); font-size: var(--yo-fs-small); }
  .table.stack-sm .c-actions { grid-area: actions; }
  .table.stack-sm .hide-sm { display: none; }
}
