/* screens/products.css — products screen styles (Stage 9 retrofit owner: this file).
 *
 * The list follows the Stage 9 orders-list idiom (toolbar--card filter bar +
 * table-card--sticky + cursor-pager footer); the edit form renders .card
 * sections with the components.css 32px control contract. The image
 * uploader, OG preview, source autocomplete and the suggest-fields /
 * quick-create modals keep their pre-Stage 9 class names (the components'
 * JS emits them), re-expressed on brand tokens. */

/* ============ products list (Stage 9 orders-list idiom) ============ */

/* Page head with a trailing action (New product / Save). */
.page-head--split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--brand-size-md);
}

/* Status pill strip takes its own toolbar row above search + selects. */
[data-products-toolbar] .filter-strip {
  flex: 1 1 100%;
}

/* Pill tones, the filter-pill chrome, and the 32px control contract
 * come from components.css/admin.css — the interim re-assertions that
 * guarded against the old admin.css overrides were removed once those
 * overrides were deleted. */

.admin-thumb {
  display: block;
  width: var(--brand-size-xxl);
  height: var(--brand-size-xxl);
  object-fit: cover;
  border-radius: var(--brand-border-radius-sm);
  background: var(--brand-color-fill);
}

.admin-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-color-text-tertiary);
  font-size: var(--brand-font-size-sm);
}

/* ============ product edit layout (main column + OG rail) ============ */

.form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--brand-size-lg);
  align-items: start;
}

@media (min-width: 1024px) {
  .form-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

/* Hide the OG-preview side panel on the create flow at all widths —
   the product does not exist yet, so the preview is dead weight and
   drops awkwardly below the form on mobile. Edit keeps it. */
.form-layout--create {
  grid-template-columns: 1fr;
}

.form-layout--create .form-side {
  display: none;
}

.form-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-lg);
}

.form-side {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-lg);
  position: sticky;
  top: calc(var(--brand-control-height-lg) + var(--brand-size-xs));
  align-self: start;
}

/* ============ product edit sections (fieldset.card extension) ============ */

/* .card supplies the surface/border/radius/shadow; the fieldset
 * extension adds the stacked layout and legend typography. */
.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-md);
  margin: 0;
}

.form-section legend {
  padding: 0;
  font-size: var(--brand-font-size-lg);
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text);
}

/* Suggest-fields button sits next to the Details legend. */
.form-section__legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--brand-size-xs);
  flex-wrap: wrap;
}

.form-section__legend-row legend {
  padding: 0;
}

.form-layout .field {
  gap: var(--brand-size-xxs);
}

.form-layout .field label {
  font-size: var(--brand-font-size-sm);
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text-secondary);
  text-transform: none;
  letter-spacing: normal;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--brand-size-md);
}

.variant-list {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-md);
}

.variant-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--brand-size-md);
  align-items: end;
  background: var(--brand-color-fill);
  border-radius: var(--brand-border-radius);
  padding: var(--brand-size-md);
}

.pricing-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--brand-size-md);
}

.pricing__preview {
  margin: 0;
  font-size: var(--brand-font-size);
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-primary);
  background: var(--brand-color-fill);
  border-radius: var(--brand-border-radius);
  padding: var(--brand-size-md);
}

.lifecycle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--brand-size);
  flex-wrap: wrap;
}

.lifecycle-buttons {
  display: flex;
  gap: var(--brand-size-xs);
  flex-wrap: wrap;
}

/* Collapsible "More details" wrapper on the create flow. Mirrors the
   fieldset/card look so it reads as another section. */
.form-more-details {
  border: var(--brand-line-width) solid var(--brand-color-border-secondary);
  border-radius: var(--brand-border-radius-lg);
  background: var(--brand-color-bg-container);
  box-shadow: 0 1px 2px var(--brand-color-fill-quaternary); /* elevation kit recipe */
  padding: 0;
}

.form-more-details > summary {
  cursor: pointer;
  padding: var(--brand-size-md);
  font-size: var(--brand-font-size);
  font-weight: var(--brand-font-weight-strong);
  list-style: none;
}

.form-more-details > summary::-webkit-details-marker {
  display: none;
}

.form-more-details[open] > summary {
  border-bottom: var(--brand-line-width) solid var(--brand-color-border-secondary);
}

.form-more-details > .form-section {
  border: 0;
  box-shadow: none;
  padding: var(--brand-size-md);
}

/* Colorway sibling list on the edit page. */
.colorway-sibling-list {
  list-style: none;
  margin: var(--brand-size-xs) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-xxs);
}

.colorway-sibling-link {
  color: var(--brand-color-link);
  text-decoration: none;
}

.colorway-sibling-link:hover {
  text-decoration: underline;
}

/* Sticky save bar for the product form on mobile — mirrors the
   order-detail sticky action bar pattern. Keeps Create/Save reachable
   after a long scroll. Desktop stays inline. */
@media (max-width: 700px) {
  .product-edit-actions {
    position: sticky;
    bottom: 0;
    background: var(--brand-color-bg-container);
    border-top: var(--brand-line-width) solid var(--brand-color-border-secondary);
    padding: var(--brand-size-xs);
    margin: var(--brand-size-sm) calc(-1 * var(--brand-size-sm)) 0;
    box-shadow: 0 -4px 12px var(--brand-color-fill); /* elevation kit recipe */
    z-index: 5;
  }
}

/* Mobile-first create form: stack the row grids that would otherwise
   get cramped on a ~360px phone. Desktop keeps the multi-column rules
   above. */
@media (max-width: 640px) {
  .variant-row,
  .pricing-row,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .image-tiles {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* ============ image uploader ============ */

.image-uploader {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

.image-uploader__drop {
  border: calc(2 * var(--brand-line-width)) dashed var(--brand-color-border);
  border-radius: var(--brand-border-radius);
  padding: var(--brand-size-lg);
  text-align: center;
  cursor: pointer;
  background: var(--brand-color-fill-tertiary);
}

.image-uploader__drop.is-drag-over {
  background: var(--brand-color-fill);
  border-color: var(--brand-color-primary);
}

.image-uploader__input {
  display: none;
}

.image-uploader__status {
  font-size: var(--brand-font-size-sm);
  margin: 0;
}

.image-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--brand-size-sm);
  list-style: none;
  padding: 0;
  margin: 0;
}

.image-tile {
  background: var(--brand-color-bg-container);
  border: var(--brand-line-width) solid var(--brand-color-border-secondary);
  border-radius: var(--brand-border-radius);
  padding: var(--brand-size-xs);
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-xs);
}

.image-tile__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--brand-border-radius-sm);
  overflow: hidden;
  background: var(--brand-color-fill);
}

.image-tile__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-tile__controls {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-xs);
}

.image-tile__main {
  display: flex;
  align-items: center;
  gap: var(--brand-size-xs);
  font-size: var(--brand-font-size-sm);
}

.image-tile__buttons {
  display: flex;
  gap: var(--brand-size-xxs);
  justify-content: flex-end;
}

/* ============ source autocomplete ============ */

.autocomplete {
  position: relative;
  max-width: 360px;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  list-style: none;
  margin: var(--brand-size-xxs) 0 0;
  padding: var(--brand-size-xxs);
  background: var(--brand-color-bg-container);
  border: var(--brand-line-width) solid var(--brand-color-border);
  border-radius: var(--brand-border-radius);
  box-shadow: 0 4px 12px var(--brand-color-fill); /* elevation kit recipe */
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--brand-size-xs);
  padding: var(--brand-size-xs) var(--brand-size-sm);
  cursor: pointer;
  border-radius: var(--brand-border-radius-sm);
}

.autocomplete-item:hover,
.autocomplete-item:focus {
  background: var(--brand-color-fill-quaternary);
}

.autocomplete-item__main {
  display: flex;
  flex-direction: column;
}

.autocomplete-item__name {
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text);
}

.autocomplete-item__meta {
  font-size: var(--brand-font-size-sm);
  color: var(--brand-color-text-tertiary);
}

.autocomplete-empty {
  padding: var(--brand-size-sm);
  color: var(--brand-color-text-tertiary);
  text-align: center;
  font-size: var(--brand-font-size-sm);
}

.autocomplete-new-wrap {
  border-top: var(--brand-line-width) solid var(--brand-color-border-secondary);
  padding-top: var(--brand-size-xxs);
  margin-top: var(--brand-size-xxs);
  list-style: none;
}

.autocomplete-new {
  display: block;
  width: 100%;
  padding: var(--brand-size-xs) var(--brand-size-sm);
  color: var(--brand-color-link);
  font-size: var(--brand-font-size-sm);
  font-weight: var(--brand-font-weight-strong);
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

/* Blocked/scam selections render in the error tone; watch/risky in the
 * warning tone (tone chosen by source-autocomplete.js). */
.autocomplete-warning {
  margin-top: var(--brand-size-xs);
  padding: var(--brand-size-xs) var(--brand-size-sm);
  border-radius: var(--brand-border-radius);
  font-size: var(--brand-font-size-sm);
  border: var(--brand-line-width) solid var(--brand-color-error-border);
  background: var(--brand-color-error-bg);
  color: var(--brand-color-error-active);
}

.autocomplete-warning--caution {
  border-color: var(--brand-color-warning-border);
  background: var(--brand-color-warning-bg);
  color: var(--brand-color-warning-active);
}

/* ============ OG preview ============ */

.og-preview {
  background: var(--brand-color-bg-container);
  border: var(--brand-line-width) solid var(--brand-color-border-secondary);
  border-radius: var(--brand-border-radius-lg);
  padding: var(--brand-size-sm) var(--brand-size);
}

.og-preview__summary {
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text);
  cursor: pointer;
  font-size: var(--brand-font-size);
}

.og-preview__content {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
  margin-top: var(--brand-size-sm);
}

.og-card {
  background: var(--brand-color-bg-elevated);
  border: var(--brand-line-width) solid var(--brand-color-border-secondary);
  border-radius: var(--brand-border-radius);
  overflow: hidden;
  max-width: 360px;
  box-shadow: 0 1px 2px var(--brand-color-fill-quaternary); /* elevation kit recipe */
}

.og-card__media {
  background: var(--brand-color-fill);
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.og-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.og-card__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--brand-color-text-tertiary);
  font-size: var(--brand-font-size-sm);
}

.og-card__body {
  padding: var(--brand-size-sm);
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-xxs);
}

.og-card__title {
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text);
}

.og-card__desc {
  font-size: var(--brand-font-size-sm);
  color: var(--brand-color-text-tertiary);
}

.og-card__url {
  font-size: var(--brand-font-size-sm);
  color: var(--brand-color-success-active);
  text-transform: uppercase;
  letter-spacing: 0.04em; /* tracking — documented raw value */
}

.og-preview__meta {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--brand-size-xxs) var(--brand-size-xs);
  font-size: var(--brand-font-size-sm);
  margin: 0;
}

.og-preview__meta dt {
  color: var(--brand-color-text-tertiary);
  font-weight: var(--brand-font-weight-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em; /* tracking — documented raw value */
}

.og-preview__meta dd {
  margin: 0;
  color: var(--brand-color-text);
  word-break: break-all;
}

/* ============ suggest fields modal (PR7.3 §3.4) ============
 * Same sheet idiom as the shipping-extract modal in screens/orders.css:
 * bottom sheet on mobile, centered dialog on >=700px. */

.suggest-fields-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 38, 31, 0.55); /* scrim — no token (documented gap) */
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 700px) {
  .suggest-fields-modal__backdrop {
    align-items: center;
  }
}

.suggest-fields-modal {
  position: relative;
  background: var(--brand-color-bg-container);
  border-radius: var(--brand-border-radius-lg) var(--brand-border-radius-lg) 0 0;
  box-shadow: 0 4px 12px var(--brand-color-fill); /* elevation kit recipe */
  padding: var(--brand-size);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

@media (min-width: 700px) {
  .suggest-fields-modal {
    border-radius: var(--brand-border-radius-lg);
  }
}

.suggest-fields-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--brand-size-sm);
}

.suggest-fields-modal__header h2 {
  margin: 0;
  font-size: var(--brand-font-size-lg);
}

.suggest-fields-modal__close {
  background: transparent;
  border: none;
  font-size: var(--brand-font-size-heading-3);
  line-height: 1;
  cursor: pointer;
  color: var(--brand-color-text-secondary);
  padding: 0 var(--brand-size-xs);
}

.suggest-fields-modal__close:hover {
  color: var(--brand-color-text);
}

.suggest-fields-modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

.suggest-fields-modal__suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-xs);
  padding-top: var(--brand-size-sm);
  border-top: var(--brand-line-width) solid var(--brand-color-border-secondary);
}

.suggest-fields-modal__hint {
  margin: 0;
  font-size: var(--brand-font-size-sm);
}

/* 8 toggleable checkbox grid (per spec §3.4) */
.suggest-fields-modal__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--brand-size-xxs);
}

@media (min-width: 700px) {
  .suggest-fields-modal__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.suggest-fields-modal__checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--brand-size-xs);
  background: var(--brand-color-fill);
  border-radius: var(--brand-border-radius-sm);
  padding: var(--brand-size-xs) var(--brand-size-sm);
  cursor: pointer;
  font-size: var(--brand-font-size);
}

.suggest-fields-modal__checkbox input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
  width: var(--brand-size);
  height: var(--brand-size);
  flex: 0 0 auto;
  accent-color: var(--brand-color-primary);
}

.suggest-fields-modal__checkbox-label {
  font-weight: var(--brand-font-weight-strong);
  color: var(--brand-color-text);
  display: block;
}

.suggest-fields-modal__value {
  display: block;
  font-size: var(--brand-font-size-sm);
  color: var(--brand-color-text);
  margin-top: 2px;
  word-break: break-word;
}

.suggest-fields-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--brand-size-xs);
  padding-top: var(--brand-size-xs);
  border-top: var(--brand-line-width) solid var(--brand-color-border-secondary);
}

.suggest-fields-modal__actions .button {
  flex: 1 1 100px;
  min-height: 44px; /* tap target — documented raw value */
}

@media (max-width: 480px) {
  .suggest-fields-modal__actions {
    flex-direction: column;
  }

  .suggest-fields-modal__actions .button {
    width: 100%;
  }
}

/* ============ source quick-create modal ============
 * Inline seller creation from the product form. Same sheet idiom as the
 * suggest-fields modal: bottom sheet on mobile, centered dialog on
 * >=700px. */

.source-quick-create-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 38, 31, 0.55); /* scrim — no token (documented gap) */
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 700px) {
  .source-quick-create-modal__backdrop {
    align-items: center;
  }
}

.source-quick-create-modal {
  position: relative;
  background: var(--brand-color-bg-container);
  border-radius: var(--brand-border-radius-lg) var(--brand-border-radius-lg) 0 0;
  box-shadow: 0 4px 12px var(--brand-color-fill); /* elevation kit recipe */
  padding: var(--brand-size);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

@media (min-width: 700px) {
  .source-quick-create-modal {
    border-radius: var(--brand-border-radius-lg);
  }
}

.source-quick-create-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--brand-size-sm);
}

.source-quick-create-modal__header h2 {
  margin: 0;
  font-size: var(--brand-font-size-lg);
}

.source-quick-create-modal__close {
  background: transparent;
  border: none;
  font-size: var(--brand-font-size-heading-3);
  line-height: 1;
  cursor: pointer;
  color: var(--brand-color-text-secondary);
  padding: 0 var(--brand-size-xs);
}

.source-quick-create-modal__close:hover {
  color: var(--brand-color-text);
}

.source-quick-create-modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

.source-quick-create-modal__fields {
  display: flex;
  flex-direction: column;
  gap: var(--brand-size-sm);
}

.source-quick-create-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--brand-size-xs);
  padding-top: var(--brand-size-xs);
  border-top: var(--brand-line-width) solid var(--brand-color-border-secondary);
}

.source-quick-create-modal__actions .button {
  flex: 1 1 auto;
  min-height: 44px; /* tap target — documented raw value */
}

@media (max-width: 480px) {
  .source-quick-create-modal__actions {
    flex-direction: column;
  }

  .source-quick-create-modal__actions .button {
    width: 100%;
  }
}
