/* Shared components: Button, Input, Select, Checkbox, Badge, Alert, Card, ProductCard, Pagination,
   Breadcrumbs, DataTable, EmptyState, Modal (dialog), Drawer. States: hover/focus/active/disabled/loading/error/success. */

/* ---------- Button ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--color-text);
  --btn-border: var(--color-border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 10px 20px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover {
  --btn-bg: var(--color-surface);
}
.btn:active {
  --btn-bg: var(--color-surface-2);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn--primary {
  --btn-bg: var(--color-brand);
  --btn-fg: var(--color-on-brand);
  --btn-border: var(--color-brand);
}
.btn--primary:hover {
  --btn-bg: var(--color-brand-hover);
  --btn-border: var(--color-brand-hover);
}
.btn--primary:active {
  --btn-bg: var(--color-brand-active);
  --btn-border: var(--color-brand-active);
}
.btn--secondary {
  --btn-bg: var(--color-bg);
}
.btn--on-dark {
  --btn-fg: var(--color-on-dark);
  --btn-border: rgba(255, 255, 255, 0.35);
}
.btn--on-dark:hover {
  --btn-bg: rgba(255, 255, 255, 0.08);
}
.btn--link {
  --btn-border: transparent;
  padding-inline: var(--space-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: var(--weight-medium);
}
.btn--link:hover {
  --btn-bg: transparent;
  text-decoration-thickness: 2px;
}
.btn--block {
  width: 100%;
}
.btn--sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: var(--text-sm);
}
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: currentColor;
}

/* ---------- Form controls ---------- */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-4);
}
.field__label {
  font-weight: var(--weight-medium);
  font-size: var(--text-base);
}
.field__optional {
  color: var(--color-muted);
  font-weight: var(--weight-regular);
  font-size: var(--text-sm);
}
.field__hint {
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.field__error {
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.field__error::before {
  content: "⚠ ";
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 1rem; /* ≥16px prevents iOS zoom */
  transition: border-color var(--transition);
}
.textarea {
  min-height: 96px;
  resize: vertical;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--color-muted);
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25);
}
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--color-surface);
  color: var(--color-muted);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--tap);
  padding-block: var(--space-2);
  cursor: pointer;
}
.check input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--color-dark);
}
.check input:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.6;
  white-space: nowrap;
  background: var(--color-surface-2);
  color: var(--color-text);
}
.badge--success {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.badge--warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}
.badge--danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}
.badge--info {
  background: var(--color-info-soft);
  color: var(--color-info);
}
.badge--neutral {
  background: var(--color-surface-2);
  color: var(--color-muted);
}
.badge--success::before {
  content: "●";
  font-size: 0.6em;
}

/* ---------- Alert ---------- */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid;
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.alert--info {
  background: var(--color-info-soft);
  border-color: #b7d0ef;
  color: #123e6e;
}
.alert--success {
  background: var(--color-success-soft);
  border-color: #b5dcc4;
  color: #12492a;
}
.alert--warning {
  background: var(--color-warning-soft);
  border-color: #f0d391;
  color: #5c3c00;
}
.alert--error {
  background: var(--color-danger-soft);
  border-color: #f2b8b5;
  color: #7a1810;
}
.alert__title {
  font-weight: var(--weight-semibold);
}

/* ---------- Card ---------- */
.card {
  background: var(--color-bg);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card--surface {
  background: var(--color-surface);
  border-color: transparent;
}
.card__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
}
.card__link {
  color: inherit;
  text-decoration: none;
}
.card__link:hover {
  text-decoration: underline;
}

/* ---------- ProductCard ---------- */
.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.product-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}
.product-card:focus-within {
  box-shadow: var(--focus-ring);
}
.product-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--color-surface);
  display: grid;
  place-items: center;
  overflow: hidden;
}
/* Same fit as the product gallery: the photo never stretches the 4:3 frame. */
.product-card__media img {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-3);
}
.product-card__noimg {
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  flex: 1;
}
.product-card__brand {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.product-card__title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1.35;
}
.product-card__title a {
  color: inherit;
  text-decoration: none;
}
.product-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.product-card__title a:focus-visible {
  outline: none;
}
.product-card__specs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.product-card__footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
}
.price {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}
.price--request {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
}
.price__old {
  color: var(--color-muted);
  font-weight: var(--weight-regular);
  font-size: var(--text-sm);
  text-decoration: line-through;
  margin-left: var(--space-2);
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin: var(--space-4) 0 var(--space-2);
}
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.breadcrumbs li + li::before {
  content: "/";
  margin-right: 4px;
  color: var(--color-border-strong);
}
.breadcrumbs a {
  color: var(--color-muted);
  display: inline-block;
  padding-block: 4px;
}
.breadcrumbs [aria-current] {
  color: var(--color-text);
}

/* ---------- Pagination ---------- */
.pagination {
  margin: var(--space-6) 0;
}
.pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.pagination a,
.pagination span {
  display: inline-grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: var(--border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-weight: var(--weight-medium);
}
.pagination a:hover {
  background: var(--color-surface);
}
.pagination [aria-current="page"] {
  background: var(--color-dark);
  border-color: var(--color-dark);
  color: var(--color-on-dark);
}

/* ---------- DataTable / spec table ---------- */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  border: var(--border);
  border-radius: var(--radius);
}
.table-scroll:focus-visible {
  outline: 3px solid var(--color-focus);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.table th,
.table td,
.prose table th,
.prose table td {
  padding: 10px 14px;
  border-bottom: var(--border);
  text-align: left;
  vertical-align: top;
}
.table tr:last-child > *,
.prose table tr:last-child > * {
  border-bottom: 0;
}
.table th[scope="row"] {
  width: 45%;
  color: var(--color-muted);
  font-weight: var(--weight-regular);
}
.table thead th {
  background: var(--color-surface);
  font-weight: var(--weight-semibold);
}

/* ---------- EmptyState ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.empty-state__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}
.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ---------- Modal (native dialog) ---------- */
.modal {
  width: min(520px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100dvh - 2 * var(--space-4));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--color-text);
  overflow: auto;
  overscroll-behavior: contain;
}
.modal::backdrop {
  background: rgba(16, 23, 34, 0.6);
}
.modal__header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
  background: var(--color-bg);
}
.modal__title {
  margin: 0;
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}
.modal__body {
  padding: 0 var(--space-5) var(--space-5);
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--color-surface);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 23, 34, 0.55);
}
.drawer-backdrop[hidden] {
  display: none;
}

/* ---------- Disclosure (FAQ) ---------- */
.disclosure {
  border-bottom: var(--border);
}
.disclosure summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  padding: var(--space-4) 0;
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  cursor: pointer;
  list-style: none;
}
.disclosure summary::-webkit-details-marker {
  display: none;
}
.disclosure summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: var(--weight-regular);
  color: var(--color-muted);
}
.disclosure[open] summary::after {
  content: "−";
}
.disclosure summary:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}
.disclosure__body {
  padding-bottom: var(--space-4);
}
