/* Apparel grid (colour × size matrix) detail page — Task 13
   Sources all colours from base.html :root tokens. Desktop-first;
   mobile fallback is a later task. */

.apparel-product {
  max-width: 1080px;
  margin: 0 auto;
  color: var(--primary);
}

.apparel-title {
  font-family: 'DM Serif Display', serif;
  font-size: 2.6rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

.apparel-step {
  margin-bottom: 2.5rem;
}

.apparel-step > h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* ---- Front / Back side tabs (pill toggle) ---- */
.apparel-side-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-warm);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.apparel-side-tabs button {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.apparel-side-tabs button:hover {
  color: var(--primary);
}

.apparel-side-tabs button.active {
  background: var(--accent);
  color: #fff;
}

/* ---- Design preview canvas placeholder (Task 14 fills this) ---- */
.apparel-preview {
  min-height: 360px;
  background: var(--bg-warm);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Pre-designed (non-customisable) apparel: fixed design display ---- */
.apparel-design-fixed {
  text-align: center;
}
.apparel-design-image {
  max-width: 100%;
  max-height: 480px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.apparel-design-desc {
  margin-top: 1rem;
  text-align: left;
  color: var(--text-secondary, #555);
}

/* ---- The matrix grid ---- */
.apparel-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.apparel-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  background: #fff;
}

.apparel-grid th,
.apparel-grid td {
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  padding: 10px 12px;
  text-align: center;
}

.apparel-grid thead th {
  background: var(--bg-warm);
  color: var(--primary);
  font-weight: 600;
}

.apparel-grid thead .grp {
  font-family: 'DM Serif Display', serif;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* Sticky first column (colour names) */
.apparel-grid .corner,
.apparel-grid .rowhdr {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-warm);
  text-align: left;
  white-space: nowrap;
}

.apparel-grid thead .corner {
  z-index: 3;
}

.apparel-grid .rowhdr {
  background: #fff;
  font-weight: 600;
  color: var(--primary);
}

.apparel-grid tbody tr:hover td {
  background: var(--bg-warm);
}

/* Colour swatch */
.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  margin-right: 8px;
  vertical-align: middle;
}

/* Per-size price modifier badge */
.mod {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

/* Quantity inputs */
.apparel-grid .cell-qty {
  width: 56px;
  padding: 6px 8px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  text-align: center;
  color: var(--primary);
}

.apparel-grid .cell-qty:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(225, 112, 85, 0.18);
}

.apparel-grid .na {
  color: var(--text-secondary);
}

/* Per-cell delivery tint set by JS (qty vs stock) */
.apparel-grid td.cell--instock {
  background: color-mix(in srgb, var(--mint) 22%, #fff);
}

.apparel-grid td.cell--mto {
  background: color-mix(in srgb, #f5a623 22%, #fff);
}

/* ---- Design tools (upload) ---- */
.apparel-design-tools {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.apparel-upload-label {
  cursor: pointer;
}

.apparel-design-name {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Colour-aware preview canvas */
.apparel-preview .apparel-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ---- Summary card ---- */
.apparel-summary {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  margin-top: 1rem;
  max-width: 420px;
}

.apparel-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'Inter', sans-serif;
  margin-bottom: 0.75rem;
}

.apparel-total-row > span:first-child {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

#apparel-total {
  font-family: 'DM Serif Display', serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--primary);
}

.apparel-nudge {
  color: var(--mint);
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
}

.apparel-delivery {
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-height: 1em;
  margin-bottom: 1rem;
}

.apparel-summary .btn-accent {
  width: 100%;
}

.apparel-summary .btn-accent:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Mobile: colour-stacked panels (≤640px) ---- */
@media (max-width: 640px) {
  /* Hide the wide header row — size labels come from data-size-label via ::before */
  .apparel-grid thead {
    display: none;
  }

  /* Unwrap the table so we can use flex on rows */
  .apparel-grid,
  .apparel-grid tbody {
    display: block;
    width: 100%;
  }

  /* Each colour row becomes a card */
  .apparel-grid tr[data-colour] {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
  }

  /* Colour header — full-width first line inside the card */
  .apparel-grid tr[data-colour] .rowhdr {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    position: static; /* cancel sticky */
    white-space: normal;
  }

  /* Size cells wrap as a row beneath the colour header */
  .apparel-grid td.cell {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 64px;
    padding: 4px;
    border: 0;
    background: transparent !important; /* cancel stock-tint on mobile */
  }

  /* Size label injected above each input via CSS */
  .apparel-grid td.cell::before {
    content: attr(data-size-label);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* Input width to fit the fixed cell width */
  .apparel-grid td.cell .cell-qty {
    width: 56px;
  }

  /* N/A cells — keep them in the flow but visually subdued */
  .apparel-grid td.cell .na {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 2.2; /* visually aligns with inputs */
  }

  /* Remove hover-row tint (no hover on touch) */
  .apparel-grid tbody tr:hover td {
    background: transparent;
  }

  /* The outer scroll wrapper no longer needs overflow-x on mobile */
  .apparel-grid-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
  }
}
