/**
 * PlusOptions for WooCommerce — options block of the product page.
 * Checkboxes and radio buttons are shown as pills, or as cards when the field has thumbnails.
 * Colours come from the variables below: a theme can change them on .pxpo-options.
 *
 * @package PlusOptionsForWooCommerce
 */
.pxpo-options {
  --pxpo-accent: #2271b1;
  --pxpo-accent-text: #fff;
  --pxpo-accent-soft: rgba(34, 113, 177, 0.1);
  --pxpo-line: rgba(0, 0, 0, 0.15);
  --pxpo-soft: rgba(0, 0, 0, 0.04);
  --pxpo-error: #c0392b;
  --pxpo-done: #0a8f4e;
  margin: 1rem 0;
  transition: opacity 0.2s;
}

.pxpo-field select,
.pxpo-field .input-text {
  width: 100%;
}

.pxpo-field {
  margin-bottom: 1rem;
}

.pxpo-field__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.45rem;
}

.pxpo-field__label {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-weight: 600;
}

.pxpo-field__label label {
  margin: 0;
  font-weight: inherit;
}

.pxpo-field__required {
  color: var(--pxpo-error);
  margin-left: 0.15rem;
}

/* "2/3": choices made and allowed. */
.pxpo-field__count {
  flex: none;
  padding: 0.2em 0.55em;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  background: var(--pxpo-soft);
  opacity: 0.85;
}

.pxpo-field__count--full {
  color: var(--pxpo-done);
  background: rgba(10, 143, 78, 0.12);
  opacity: 1;
}

.pxpo-field__description,
.pxpo-field__hint {
  margin: 0 0 0.45rem;
  font-size: 0.875em;
  opacity: 0.8;
}

/* Visible to screen readers only. */
.pxpo-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Choices: shared ---- */

.pxpo-field__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pxpo-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: normal;
  line-height: 1.3;
  cursor: pointer;
  border: 1.5px solid var(--pxpo-line);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

/* The real box stays in the form and keeps the keyboard focus; only its look is hidden. */
.pxpo-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.pxpo-choice:hover {
  border-color: var(--pxpo-accent);
}

.pxpo-choice:focus-within {
  outline: 2px solid var(--pxpo-accent);
  outline-offset: 2px;
}

.pxpo-choice--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pxpo-choice--disabled:hover {
  border-color: var(--pxpo-line);
}

.pxpo-price {
  font-size: 0.8em;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.75;
}

.pxpo-price:empty {
  display: none;
}

/* ---- Pills (no thumbnail in the field) ---- */

/* Same size checked or not: the check mark sits in the left padding, it never widens the pill
   nor moves the pills around it. */
.pxpo-field--pills .pxpo-choice {
  padding: 0.35em 1.4em;
  border-radius: 999px;
}

.pxpo-field--pills .pxpo-choice--checked,
.pxpo-field--pills .pxpo-choice:has(input:checked) {
  color: var(--pxpo-accent-text);
  background: var(--pxpo-accent);
  border-color: var(--pxpo-accent);
}

.pxpo-field--pills .pxpo-choice--checked::before,
.pxpo-field--pills .pxpo-choice:has(input:checked)::before {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 0.5em;
  font-weight: 700;
  font-size: 0.8em;
  line-height: 1;
  transform: translateY(-50%);
}

.pxpo-field--pills .pxpo-choice--checked .pxpo-price {
  opacity: 0.9;
}

.pxpo-field--pills .pxpo-choice__icon {
  display: none;
}

/* ---- Cards (one thumbnail at least in the field) ---- */

.pxpo-field--cards .pxpo-field__choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.5rem;
}

.pxpo-field--cards .pxpo-choice {
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.3rem;
  padding: 0.6rem 0.4rem 0.5rem;
  text-align: center;
  border-radius: 10px;
}

.pxpo-choice__icon {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.pxpo-choice__icon--empty {
  display: block;
  background: var(--pxpo-soft);
}

.pxpo-field--cards .pxpo-choice--checked,
.pxpo-field--cards .pxpo-choice:has(input:checked) {
  background: var(--pxpo-accent-soft);
  border-color: var(--pxpo-accent);
}

.pxpo-field--cards .pxpo-choice--checked::after,
.pxpo-field--cards .pxpo-choice:has(input:checked)::after {
  content: "✓";
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
  color: var(--pxpo-accent-text);
  background: var(--pxpo-accent);
  border-radius: 50%;
}

/* ---- Errors and total ---- */

.pxpo-field--invalid select,
.pxpo-field--invalid .input-text {
  border-color: var(--pxpo-error);
}

.pxpo-field__error,
.pxpo-message {
  margin: 0.45rem 0 0;
  color: var(--pxpo-error);
  font-size: 0.875em;
}

.pxpo-summary {
  padding: 0.75rem 1rem;
  border: 1px solid var(--pxpo-line);
  border-radius: 6px;
}

.pxpo-summary__line {
  display: flex;
  justify-content: space-between;
  margin: 0;
}

.pxpo-summary__line--total {
  margin-top: 0.25rem;
  font-size: 1.1em;
}

/* ---- Accordion (WooCommerce > Product options setting) ---- */

.pxpo-options--accordion .pxpo-field {
  margin: 0;
  border: 1px solid var(--pxpo-line);
}

.pxpo-options--accordion .pxpo-field + .pxpo-field {
  margin-top: -1px;
}

.pxpo-options--accordion .pxpo-field:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* The last field is the one followed by the total. */
.pxpo-options--accordion .pxpo-field:has(+ .pxpo-summary) {
  margin-bottom: 1rem;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.pxpo-options--accordion .pxpo-field__head {
  margin: 0;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  user-select: none;
}

.pxpo-options--accordion .pxpo-field__label {
  flex: 0 1 auto;
}

/* Counter and arrow stay on the right, with or without the summary. */
.pxpo-options--accordion .pxpo-field__count {
  margin-left: auto;
}

.pxpo-options--accordion .pxpo-field__head::after {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.15rem;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.6;
  transition: transform 0.2s;
}

.pxpo-options--accordion .pxpo-field--open .pxpo-field__head {
  background: var(--pxpo-soft);
}

.pxpo-options--accordion .pxpo-field--open .pxpo-field__head::after {
  transform: rotate(-135deg) translateY(-2px);
}

.pxpo-options--accordion .pxpo-field__head:focus-visible {
  outline: 2px solid var(--pxpo-accent);
  outline-offset: -2px;
}

.pxpo-field__summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 0.875em;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.75;
}

.pxpo-field__summary--todo {
  color: var(--pxpo-error);
  font-weight: 600;
  opacity: 1;
}

.pxpo-options--accordion .pxpo-field__body {
  padding: 0.25rem 0.85rem 0.85rem;
}

.pxpo-options--accordion .pxpo-field--invalid {
  border-color: var(--pxpo-error);
}

/* ---- Notification when options are missing, above the theme (sticky headers, cookie banners) ---- */

.pxpo-toast {
  position: fixed;
  z-index: 100000;
  right: 1rem;
  bottom: 1rem;
  left: auto;
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 0.85rem 1.1rem;
  color: #fff;
  background: #c0392b;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.pxpo-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.pxpo-options [hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .pxpo-choice,
  .pxpo-toast,
  .pxpo-options--accordion .pxpo-field__head::after {
    transition: none;
  }
}
