/* =========================================================
   BOX ELEMENT — "auto-fit" text/image boxes
   Unlike "color" (fixed width/height circular swatch), the
   box sizes to its content (width:auto + padding). Image mode
   (show_as_image) shows the box's own thumbnail inside the
   same button, keeping the tap area consistent.
========================================================= */

.personailit-box-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 2px;
}

.personailit-box-swatch {
    position: relative;
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: var(--pi-box-size, 44px);
    height: auto;
    min-height: calc(var(--pi-box-size, 44px) - 6px);
    padding: calc(var(--pi-box-size, 44px) * 0.18) calc(var(--pi-box-size, 44px) * 0.4);
    border: 2px solid var(--pi-border, #dcdcde);
    border-radius: var(--pi-radius-sm, 6px);
    background: var(--pi-surface, #fff);
    cursor: pointer;
    transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 160ms ease,
        box-shadow 160ms ease;
}

.personailit-box-swatch-text {
    font-size: calc(var(--pi-box-size, 44px) * 0.3);
    line-height: 1.2;
    color: var(--pi-ink, #23262b);
    white-space: nowrap;
}

.personailit-box-swatch:hover {
    transform: translateY(-2px);
    color: var(--pi-ink, #23262b);
    background-color: #fff;
    border-color: var(--pi-accent, #c2185b);
}

.personailit-box-swatch:focus,
.personailit-box-swatch:focus-visible {
    color: var(--pi-ink, #23262b) !important;
    background: #fff !important;
    border-color: var(--pi-accent, #c2185b);
}

.personailit-box-swatch.is-selected {
    border-color: var(--pi-accent, #c2185b);
    box-shadow: 0 0 0 1px var(--pi-accent, #c2185b);
}

.personailit-box-swatch.is-selected .personailit-box-swatch-text {
    color: var(--pi-accent, #c2185b);
    font-weight: 600;
}

/* Image mode: the box becomes mostly the thumbnail, with reduced
   padding so the image better fills the button's area. */
.personailit-box-swatch.has-image {
    padding: 4px;
    min-width: calc(var(--pi-box-size, 44px) * 1.25);
    min-height: calc(var(--pi-box-size, 44px) * 1.25);
}

.personailit-box-swatch-image {
    display: block;
    width: calc(var(--pi-box-size, 44px) * 1.05);
    height: calc(var(--pi-box-size, 44px) * 1.05);
    object-fit: cover;
    border-radius: calc(var(--pi-radius-sm, 6px) - 2px);
}

/* Checkmark over the chosen box, same spirit as "color". */
.personailit-box-swatch.is-selected::after {
    content: "";
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--pi-accent, #c2185b);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-size: 10px;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    animation: personailit-box-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes personailit-box-pop {
    from { opacity: 0; transform: scale(0.4); }
    to   { opacity: 1; transform: scale(1); }
}

/* Selected box's name, below the boxes. */
.personailit-box-selected-label {
    margin-top: 10px;
    font-size: 13px;
    color: var(--pi-ink-soft, #6b7178);
    min-height: 18px;
}

.personailit-box-selected-label strong {
    color: var(--pi-ink, #23262b);
    font-weight: 600;
}

.personailit-box-preview {
    margin-top: 12px;
}

.personailit-box-preview-image {
    max-width: 180px;
    height: auto;
    border-radius: var(--pi-radius-sm, 6px);
    display: none;
    box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.25);
}

/* =========================================================
   Box size: how many px each of Small/Medium/Large represents
   is configurable in Element Settings > Box (admin screen) —
   PersoNailit_Element_Box_Sanitizer::get_default_settings_fields().
   Which of the 3 is active is decided per product (the
   "Advanced" panel) or, with no override, by the global
   "Default Box Size" default.
   PersoNailit_Element_Box_Frontend::render_frontend() resolves
   both and prints the result as --pi-box-size inline on the
   ".personailit-box-options" wrapper — all the sizing above
   (min-width, padding, font-size, image) derives from that
   variable, so there's no fixed per-size rule here.
========================================================= */

/* Highlighted price inside the box ("Show price inside box"). */
.personailit-box-swatch-price {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pi-accent, #c2185b);
    white-space: nowrap;
}

.personailit-box-swatch-price del {
    margin-right: 4px;
    font-weight: 400;
    opacity: 0.6;
}
