/* ==========================================================================
   Odonata Custom Swatch System
   ========================================================================== */

/* --------------------------------------------------------------------------
   Base swatch element — shared by color, image, and label types
   -------------------------------------------------------------------------- */

.odonata-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  user-select: none;
  position: relative;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Label (text pill) — full mode
   -------------------------------------------------------------------------- */

.odonata-swatch--label {
  padding: 0.375rem 1rem;
  border-radius: 0.5rem;
  border-color: hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  min-width: 2.5rem;
  text-align: center;
}

.odonata-swatch--label:hover:not(.odonata-swatch--disabled) {
  border-color: hsl(var(--primary) / 0.5);
}

.odonata-swatch--label.is-selected {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
}

/* --------------------------------------------------------------------------
   Color swatch — full mode
   -------------------------------------------------------------------------- */

.odonata-swatch--color {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border-color: transparent;
  box-shadow: 0 0 0 1px hsl(var(--border));
}

.odonata-swatch--color:hover:not(.odonata-swatch--disabled) {
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.4);
}

.odonata-swatch--color.is-selected {
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--primary));
}

/* --------------------------------------------------------------------------
   Image swatch — full mode
   -------------------------------------------------------------------------- */

.odonata-swatch--image {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.375rem;
  overflow: hidden;
  border-color: hsl(var(--border));
  padding: 0;
}

.odonata-swatch--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.odonata-swatch--image:hover:not(.odonata-swatch--disabled) {
  border-color: hsl(var(--primary) / 0.6);
}

.odonata-swatch--image.is-selected {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.25);
}

/* --------------------------------------------------------------------------
   Disabled state (out of stock)
   -------------------------------------------------------------------------- */

.odonata-swatch--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Diagonal strikethrough for color/image disabled */
.odonata-swatch--color.odonata-swatch--disabled::after,
.odonata-swatch--image.odonata-swatch--disabled::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent calc(50% - 1.5px),
    rgba(0,0,0,0.65) calc(50% - 1.5px),
    rgba(0,0,0,0.65) calc(50% + 1.5px),
    transparent calc(50% + 1.5px)
  );
  border-radius: inherit;
}

/* 'Изчерпан' label badge on disabled label swatches */
.odonata-swatch--label.odonata-swatch--disabled {
  text-decoration: line-through;
  text-decoration-color: hsl(var(--muted-foreground));
}

/* Out-of-stock tooltip badge shown below color/image swatches (full mode only) */
.odonata-swatches--full .odonata-swatch--color.odonata-swatch--disabled,
.odonata-swatches--full .odonata-swatch--image.odonata-swatch--disabled {
  --oos-label: 'Изч.';
}

.odonata-swatches--full .odonata-swatch--color.odonata-swatch--disabled::before,
.odonata-swatches--full .odonata-swatch--image.odonata-swatch--disabled::before {
  content: 'Изч.';
  position: absolute;
  bottom: -1.125rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   Full mode layout
   -------------------------------------------------------------------------- */

.odonata-attribute-row {
  margin-bottom: 1.5rem; /* extra space for out-of-stock badge below color swatches */
}

.odonata-attribute-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

.odonata-selected-value {
  font-weight: 400;
  color: hsl(var(--muted-foreground));
}

.odonata-swatches--full {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Compact mode (product cards)
   -------------------------------------------------------------------------- */

.odonata-swatches--compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.odonata-swatches--compact .odonata-swatch--color {
  width: 1.125rem;
  height: 1.125rem;
  box-shadow: 0 0 0 1px hsl(var(--border));
}

.odonata-swatches--compact .odonata-swatch--image {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 0.25rem;
}

/* Overflow indicator */
.odonata-swatch--overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.625rem;
  font-weight: 600;
  cursor: default;
}

/* --------------------------------------------------------------------------
   Tooltip (title attr handled natively, custom tooltip on full mode)
   -------------------------------------------------------------------------- */

.odonata-swatches--visual .odonata-swatch:focus-visible {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}
