/*
 * Criamor — reusable components (docs/design/canvas/Main.dc.html, section 04).
 * Uses only tokens.css variables (--cm-*). The base .cm-swatch colour swatch lives in tokens.css.
 */

/* ---------- Buttons ---------- */
.cm-btn {
  --btn-h: var(--cm-hit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cm-space-2);
  height: var(--btn-h);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--cm-radius-btn);
  background: transparent;
  color: var(--cm-text);
  font-family: var(--cm-font-body);
  font-size: var(--cm-fs-small);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--cm-dur-fast) var(--cm-ease),
              color var(--cm-dur-fast) var(--cm-ease),
              border-color var(--cm-dur-fast) var(--cm-ease);
}
.cm-btn--md { --btn-h: 48px; padding: 0 var(--cm-space-6); font-size: 15px; }
.cm-btn--lg { --btn-h: 52px; padding: 0 28px; font-size: 15px; }
.cm-btn--sm { --btn-h: 36px; padding: 0 14px; font-size: 13px; } /* backoffice / dense desktop only */
.cm-btn--block { display: flex; width: 100%; }

/* Primary — coral, white on top (4.9:1) */
.cm-btn--primary { background: var(--cm-primary); color: var(--cm-surface); }
.cm-btn--primary:hover { background: var(--cm-primary-hover); color: var(--cm-surface); }

/* Secondary — plum outline; fills on hover */
.cm-btn--secondary { border-color: var(--cm-text); color: var(--cm-text); }
.cm-btn--secondary:hover { background: var(--cm-text); color: var(--cm-bg); }

/* Dark — backoffice actions ("Novo produto") */
.cm-btn--dark { background: var(--cm-text); color: var(--cm-bg); }
.cm-btn--dark:hover { background: var(--cm-admin-sidebar-active); color: var(--cm-bg); }

/* Soft outline — "Escolher cor", secondary card actions */
.cm-btn--outline { border-color: var(--cm-line-field); color: var(--cm-text); }
.cm-btn--outline:hover { border-color: var(--cm-text); color: var(--cm-text); }

/* Ghost — link styled as a button ("Continuar a comprar") */
.cm-btn--ghost {
  padding: 0 var(--cm-space-3);
  color: var(--cm-link);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.cm-btn--ghost:hover { color: var(--cm-link-hover); }

.cm-btn:disabled,
.cm-btn[aria-disabled="true"] {
  border-color: transparent;
  background: var(--cm-line);
  color: var(--cm-text-disabled);
  cursor: not-allowed;
}

/* Quantity selector */
.cm-qty {
  display: inline-flex;
  align-items: center;
  height: var(--cm-hit);
  border: 1px solid var(--cm-line-field);
  border-radius: var(--cm-radius-btn);
  background: var(--cm-surface);
}
.cm-qty__btn {
  width: var(--cm-hit);
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--cm-text);
}
.cm-qty__value {
  width: 32px;
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 600;
  -moz-appearance: textfield;
  appearance: textfield;
}
.cm-qty__value::-webkit-inner-spin-button,
.cm-qty__value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Form fields ---------- */
.cm-field { display: flex; flex-direction: column; gap: 6px; }
.cm-label { font-size: var(--cm-fs-small); font-weight: 500; }
.cm-hint { font-size: 13px; color: var(--cm-text-2); }
.cm-error { font-size: 13px; color: var(--cm-danger); }

.cm-input,
.cm-select,
.cm-textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--cm-line-field);
  border-radius: var(--cm-radius-field);
  background: var(--cm-surface);
  color: var(--cm-text);
  font-size: 15px;
  transition: border-color var(--cm-dur-fast) var(--cm-ease);
}
.cm-textarea { min-height: 120px; padding-block: var(--cm-space-3); line-height: 1.5; resize: vertical; }
.cm-input::placeholder,
.cm-textarea::placeholder { color: var(--cm-text-2); opacity: 1; }
.cm-input:hover,
.cm-select:hover,
.cm-textarea:hover { border-color: var(--cm-text-2); }
.cm-input:focus-visible,
.cm-select:focus-visible,
.cm-textarea:focus-visible { border-color: var(--cm-text); outline-offset: 1px; }

.cm-input[aria-invalid="true"],
.cm-select[aria-invalid="true"],
.cm-textarea[aria-invalid="true"],
.cm-input.input-validation-error,
.cm-select.input-validation-error,
.cm-textarea.input-validation-error { border: 1.5px solid var(--cm-danger); }
.field-validation-error { font-size: 13px; color: var(--cm-danger); }

.cm-select {
  height: var(--cm-hit);
  min-height: 0;
  padding-right: 40px;
  border-radius: var(--cm-radius-btn);
  font-size: var(--cm-fs-small);
  font-weight: 500;
  appearance: none;
  /* SVG chevron; colour is fixed because background-image does not inherit currentColor */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232D2240' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

/* Native checkbox and radio (coral accent) */
.cm-check {
  display: inline-flex;
  align-items: center;
  gap: var(--cm-space-2);
  min-height: var(--cm-hit);
  font-size: var(--cm-fs-small);
  cursor: pointer;
}
.cm-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--cm-primary);
  cursor: pointer;
}

/* ---------- Tags (badges) ---------- */
.cm-tag {
  height: 26px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--cm-line);
  border-radius: var(--cm-radius-field);
  background: var(--cm-bg);
  color: var(--cm-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cm-tag--dark { border-color: transparent; background: var(--cm-text); color: var(--cm-bg); }
.cm-tag--sale { border-color: transparent; background: var(--cm-primary); color: var(--cm-surface); }

/* Order statuses (PLANEAMENTO §7.1) */
.cm-status {
  --status-bg: var(--cm-bg-2);
  --status-fg: var(--cm-text);
  height: 28px;
  padding: 0 var(--cm-space-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--cm-radius-pill);
  background: var(--status-bg);
  color: var(--status-fg);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.cm-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.cm-status--pending   { --status-bg: var(--cm-status-pending-bg);   --status-fg: var(--cm-status-pending); }
.cm-status--paid      { --status-bg: var(--cm-status-paid-bg);      --status-fg: var(--cm-status-paid); }
.cm-status--preparing { --status-bg: var(--cm-status-preparing-bg); --status-fg: var(--cm-status-preparing); }
.cm-status--shipped   { --status-bg: var(--cm-status-shipped-bg);   --status-fg: var(--cm-status-shipped); }
.cm-status--delivered { --status-bg: var(--cm-status-delivered-bg); --status-fg: var(--cm-status-delivered); }
.cm-status--cancelled { --status-bg: var(--cm-status-cancelled-bg); --status-fg: var(--cm-status-cancelled); }
.cm-status--refunded  { --status-bg: var(--cm-status-refunded-bg);  --status-fg: var(--cm-status-refunded); }

/* ---------- Product card (CartaoProduto.dc.html) ---------- */
.cm-card {
  display: flex;
  flex-direction: column;
  gap: var(--cm-space-2);
  color: var(--cm-text);
}
.cm-card__media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  border-radius: 10px;
  overflow: hidden;
  background: var(--cm-bg-2);
  transition: box-shadow .4s ease;
}
.cm-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 450ms ease, transform var(--cm-dur-img) var(--cm-ease);
}
.cm-card__media img + img { opacity: 0; }   /* 2nd image (in use), shown on hover/focus */
/* Triggers: hovering the image, or keyboard focus on the name link (the image link is out of the tab order). */
.cm-card__media:hover,
.cm-card__media:focus-visible,
.cm-card:has(.cm-card__name:focus-visible) .cm-card__media { box-shadow: var(--cm-shadow-md); }
.cm-card__media:hover img,
.cm-card__media:focus-visible img,
.cm-card:has(.cm-card__name:focus-visible) .cm-card__media img { transform: scale(1.04); }
.cm-card__media:hover img:first-child:not(:only-of-type),
.cm-card__media:focus-visible img:first-child:not(:only-of-type),
.cm-card:has(.cm-card__name:focus-visible) .cm-card__media img:first-child:not(:only-of-type) { opacity: 0; }
.cm-card__media:hover img + img,
.cm-card__media:focus-visible img + img,
.cm-card:has(.cm-card__name:focus-visible) .cm-card__media img + img { opacity: 1; }
.cm-card__tags {
  position: absolute;
  top: var(--cm-space-3);
  left: var(--cm-space-3);
  right: var(--cm-space-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cm-card__tags .cm-tag { border-color: transparent; }

.cm-card__body {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}
.cm-card__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cm-card__name {
  font-family: var(--cm-font-display);
  font-size: var(--cm-fs-body);
  line-height: 1.25;
  color: var(--cm-text);
  text-decoration: none;
}
.cm-card__name:hover { color: var(--cm-text); text-decoration: underline; }
.cm-card__meta { font-size: 13px; color: var(--cm-text-2); }
.cm-card__title { font: inherit; line-height: inherit; text-wrap: pretty; }
.cm-card__prices {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  text-align: right;
}
.cm-card__price { font-family: var(--cm-font-display); font-size: 15px; white-space: nowrap; }
.cm-card__from { font-family: var(--cm-font-body); font-size: var(--cm-fs-label); color: var(--cm-text-2); }
.cm-card__compare { font-size: 13px; color: var(--cm-text-2); white-space: nowrap; }
.cm-card__form { display: contents; }

/* Narrow cards (2-column mobile grid): price below the name, as in M-Inicio.dc.html */
@media (max-width: 47.99em) {
  .cm-card__body { flex-direction: column; gap: 4px; }
  .cm-card__prices { flex-direction: row; align-items: baseline; gap: 6px; text-align: left; }
}

/* Colour dots (up to 5 + "+N") */
.cm-dots { display: flex; align-items: center; gap: 5px; margin-top: var(--cm-space-1); }
.cm-dot {
  width: var(--cm-swatch-dot);
  height: var(--cm-swatch-dot);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(45, 34, 64, .15);
}
.cm-dots__more { margin-left: 2px; font-size: var(--cm-fs-label); color: var(--cm-text-2); }

.cm-card__action { width: 100%; }
.cm-card__action.is-added { border-color: var(--cm-primary); background: var(--cm-primary); color: var(--cm-surface); }

@media (min-width: 48em) {
  .cm-card { gap: 14px; }
  .cm-card__media { border-radius: var(--cm-radius-card); }
  .cm-card__body { gap: var(--cm-space-3); }
  .cm-card__info { gap: var(--cm-space-1); }
  .cm-card__name { font-size: 19px; line-height: 1.3; }
  .cm-card__meta { font-size: var(--cm-fs-small); }
  .cm-card__price { font-size: 18px; }
}

/* ---------- Colour swatch: additions to tokens.css ---------- */
.cm-swatch { position: relative; flex-shrink: 0; }
.cm-swatch:hover:not([aria-checked="true"]):not([aria-disabled="true"]) { border-color: var(--cm-line-field); }
.cm-swatch[aria-disabled="true"] { cursor: not-allowed; }
.cm-swatch[aria-disabled="true"]::after {      /* diagonal strike on an out-of-stock colour */
  content: "";
  position: absolute;
  width: 44px;
  height: 2px;
  background: var(--cm-text);
  transform: rotate(-45deg);
}
.cm-swatch-group { display: flex; flex-wrap: wrap; gap: var(--cm-space-2); }

/* ---------- Chips (active filters) ---------- */
.cm-chips { display: flex; flex-wrap: wrap; gap: var(--cm-space-2); list-style: none; padding: 0; }
.cm-chip {
  height: 32px;
  padding: 0 6px 0 var(--cm-space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--cm-space-1);
  border-radius: var(--cm-radius-pill);
  background: var(--cm-bg-2);
  color: var(--cm-text);
  font-size: 13px;
  font-weight: 500;
}
.cm-chip__remove {
  position: relative;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cm-text);
}
.cm-chip__remove::after {                       /* touch target enlarged to 44 px */
  content: "";
  position: absolute;
  inset: -8px;
}
.cm-chip__remove:hover { background: var(--cm-line); }
.cm-chip--toggle { padding: 0 14px; border: 1px solid var(--cm-line-field); background: var(--cm-surface); height: var(--cm-hit); cursor: pointer; }
.cm-chip--toggle[aria-pressed="true"] { border-color: var(--cm-text); background: var(--cm-text); color: var(--cm-bg); }

/* ---------- Breadcrumbs ---------- */
.cm-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cm-space-2);
  list-style: none;
  padding: 0;
  font-size: var(--cm-fs-small);
  color: var(--cm-text-2);
}
.cm-breadcrumbs li { display: inline-flex; align-items: center; gap: var(--cm-space-2); }
.cm-breadcrumbs li + li::before { content: "/"; color: var(--cm-text-2); }
.cm-breadcrumbs a { color: var(--cm-text-2); }
.cm-breadcrumbs a:hover { color: var(--cm-text); }
.cm-breadcrumbs [aria-current="page"] { color: var(--cm-text); }

/* ---------- Pagination ---------- */
.cm-pagination ul { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; list-style: none; padding: 0; }
.cm-pagination a,
.cm-pagination span[aria-disabled="true"] {
  min-width: var(--cm-hit);
  height: var(--cm-hit);
  padding: 0 var(--cm-space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--cm-radius-btn);
  color: var(--cm-text);
  text-decoration: none;
}
.cm-pagination a:hover { background: var(--cm-bg-2); color: var(--cm-text); }
.cm-pagination a[aria-current="page"] { background: var(--cm-text); color: var(--cm-bg); font-weight: 600; }
.cm-pagination span[aria-disabled="true"] { color: var(--cm-text-disabled); }

/* ---------- Toasts ---------- */
.cm-toast-region {
  position: fixed;
  right: var(--cm-space-4);
  bottom: var(--cm-space-4);
  left: var(--cm-space-4);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--cm-space-2);
  pointer-events: none;
}
.cm-toast {
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: var(--cm-space-3);
  padding: 14px var(--cm-space-4);
  border-radius: 10px;
  background: var(--cm-text);
  color: var(--cm-bg);
  box-shadow: var(--cm-shadow-md);
  font-size: var(--cm-fs-small);
  pointer-events: auto;
  animation: cm-toast-in 350ms var(--cm-ease);
}
.cm-toast__icon { color: var(--cm-accent); }
.cm-toast__text { flex: 1; }
.cm-toast a { color: var(--cm-accent); font-weight: 600; }
.cm-toast a:hover { color: var(--cm-bg); }
.cm-toast--error { background: var(--cm-status-cancelled-bg); color: var(--cm-status-cancelled); box-shadow: none; }
.cm-toast--error .cm-toast__icon { color: currentColor; }

/* Inline alert (same look as the error toast, not fixed) */
.cm-alert {
  display: flex;
  align-items: center;
  gap: var(--cm-space-3);
  padding: 14px var(--cm-space-4);
  border-radius: 10px;
  background: var(--cm-status-cancelled-bg);
  color: var(--cm-status-cancelled);
  font-size: var(--cm-fs-small);
}

@keyframes cm-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Accordion (native <details>/<summary>) ---------- */
.cm-accordion { border-top: 1px solid var(--cm-line); }
.cm-accordion details { border-bottom: 1px solid var(--cm-line); }
.cm-accordion summary {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cm-space-4);
  font-size: var(--cm-fs-body);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.cm-accordion summary::-webkit-details-marker { display: none; }
.cm-accordion summary .cm-icon { transition: transform var(--cm-dur-fast) var(--cm-ease); }
.cm-accordion details[open] > summary .cm-icon { transform: rotate(180deg); }
.cm-accordion__body {
  padding-bottom: 18px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--cm-text-3);
}

/* ---------- Modal and side drawer (<dialog>) ---------- */
.cm-modal,
.cm-drawer {
  padding: 0;
  border: 0;
  background: var(--cm-bg);
  color: var(--cm-text);
  box-shadow: var(--cm-shadow-lg);
}
.cm-modal::backdrop,
.cm-drawer::backdrop { background: color-mix(in srgb, var(--cm-text) 55%, transparent); }

.cm-modal {
  width: calc(100% - 2 * var(--cm-space-4));
  max-width: 420px;
  border-radius: var(--cm-radius-panel);
}
.cm-modal__inner { display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.cm-modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--cm-space-3); }
.cm-modal__title { font-size: var(--cm-fs-h3); line-height: 1.3; }
.cm-modal__head .cm-icon-btn { margin: -10px -10px 0 0; }
.cm-modal__text { font-size: 15px; line-height: 1.6; color: var(--cm-text-3); }
.cm-modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* Side drawer (mini-cart; mobile filter bottom sheet) */
.cm-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
}
.cm-drawer[open] { display: flex; flex-direction: column; animation: cm-drawer-in 350ms var(--cm-ease); }
.cm-drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--cm-space-3);
  padding: 20px 20px var(--cm-space-4) 28px;
  border-bottom: 1px solid var(--cm-line);
}
.cm-drawer__title { font-size: var(--cm-fs-h3); }
.cm-drawer__body { flex: 1; overflow-y: auto; padding: 20px 28px; }
.cm-drawer__foot { padding: 20px 28px; border-top: 1px solid var(--cm-line); background: var(--cm-surface); }

.cm-drawer--bottom {
  inset: auto 0 0 0;
  width: 100%;
  height: auto;
  max-height: 85vh;
  border-radius: var(--cm-radius-panel) var(--cm-radius-panel) 0 0;
}
.cm-drawer--bottom[open] { animation-name: cm-sheet-in; }

@keyframes cm-drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes cm-sheet-in  { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Catalog additions (pagination gap, toast thumbnail) ---------- */
.cm-pagination__gap {
  min-width: 24px;
  height: var(--cm-hit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cm-text-2);
}
.cm-toast__thumb { width: 52px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--cm-bg-2); }
.cm-toast__thumb:not([src]) { display: none; }
.cm-toast__text { display: flex; flex-direction: column; gap: 2px; }
.cm-toast__detail { color: color-mix(in srgb, var(--cm-bg) 85%, var(--cm-lilac)); }
