/**
 * Style the WooCommmerce variations table.
 */

.variations_form table {
   width: 100%;
   margin-top: 8px;
   font-size: 14px;
   text-align: left;

   & tr {
      display: block;
      margin-block: 12px;

      & th {
         display: block;
         font-size: 14.5px;
         font-weight: 600;
      }

      & td {
         display: block;

         & select {
            cursor: pointer;
            width: 100%;
            height: 48px;
            margin-block: 8px;
            padding: 8px;
            border: 1px solid #888;
            border-radius: 0.375rem;
         }
      }
   }
}

.variations_form .reset_variations {
   text-decoration: underline;
}

/**
 * Style our plugin swatches.
 */

span.selected-option-label {
   font-weight: 400;
}

/* Base swatch container */
.wcas-swatch-container {
   display: flex;
   flex-wrap: wrap;
   padding-block: 8px;

   &.color,
   &.image,
   &.text {
      gap: 4.5px;
   }
}

/* Base swatch wrapper */
.wcas-swatch-wrapper {
   position: relative;
   cursor: pointer;
   border: 1px solid #ddd;
   transition: border-color 0.2s ease-in-out;

   &:hover,
   &.selected {
      border-color: #000;
   }

   & > * {
      width: 100%;
      height: 100%;
   }

   /* SVG selection indicator */
   & svg {
      display: none;
   }

   &.selected svg {
      display: block !important;
      position: absolute;
      top: 0;
      right: 0;
      transform: translate(25%, -30%);
      width: 16px;
      height: 16px;
      padding: 3px;
      border-radius: 100%;
      background-color: green;
   }
}

/* Circular swatches (color & image) */
.wcas-swatch-wrapper.color,
.wcas-swatch-wrapper.image {
   width: 40px;
   height: 40px;
   padding: 1.25px;
   border-radius: 100%;

   & > * {
      border-radius: 100%;
   }
}

/* Text and radio shared styles */
.wcas-swatch-wrapper.text,
.wcas-swatch-wrapper.radio {
   line-height: 1.2;

   &.selected {
      background-color: #f6f6f6;
   }
}

/* Text swatch specific */
.wcas-swatch-wrapper.text {
   padding: 8px 12px;
   border-radius: 4px;
}

/* Radio swatch specific */
.wcas-swatch-wrapper.radio {
   width: 100%;

   &:first-child {
      border-radius: 4px 4px 0 0;
   }

   &:last-child {
      border-radius: 0 0 4px 4px;
   }

   & label {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
      min-height: 40px;
      padding: 6px 12px;
   }

   & input {
      appearance: none;
      cursor: pointer;
      width: 16px;
      height: 16px;
      border: 1px solid #ddd;
      border-radius: 100%;
      background-color: #fff;

      .selected & {
         border-color: #000;
         box-shadow:
            inset 0 0 0 4px #000,
            inset 0 0 0 16px #fff;
      }
   }
}

/**
 * Style groups
 */

.wcas-swatch-group {
   width: 100%;
   margin-top: 8px;
}

.wcas-swatch-group-label {
   font-weight: 300;
   line-height: 2;
}

.wcas-swatch-group-items {
   display: flex;
   flex-wrap: wrap;
   gap: 4.5px;
}

/**
 * Tooltip styles
 */

.wcas-tooltip {
   position: fixed;
   z-index: 9999;
   width: 320px;
   border-radius: 6px;
   background-color: #fff;
   box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
   pointer-events: none;
   opacity: 0;
   visibility: hidden;
   transition: opacity 0.2s ease-in-out;
}

.wcas-tooltip-visible {
   opacity: 1;
   visibility: visible;
}

.wcas-tooltip-content {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 6px;
   padding: 10px 10px 6px 10px;
}

.wcas-tooltip-thumbnail {
   width: 100%;
   aspect-ratio: 1 / 1;
   border-radius: 4px;
   overflow: clip;

   & > * {
      width: 100%;
      height: 100%;
   }
}

.wcas-tooltip-label {
   font-size: 14px;
   color: #333;
   font-weight: 500;
   text-align: center;
   word-break: break-word;
}

.wcas-tooltip-arrow {
   position: absolute;
   top: 100%;
   left: 50%;
   transform: translateX(-50%);
   border: 7px solid transparent;
   border-top-color: #fff;
   border-bottom: 0;
}
