/**
 * WC Flag Configurator - Variable Flag Frontend Styles
 *
 * Styles for the Variable Flag product variation form.
 *
 * @package Codexyl\VariableFlag
 */

/* ==========================================================================
   Variation Form
   ========================================================================== */

.cxvf-variable-flag-form {
    margin: 1.5em 0;
}

/* ==========================================================================
   Accordion Group
   ========================================================================== */

.cxvf-accordion-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5em;
}

/* Single Accordion Item */
.cxvf-accordion {
    border: 1px solid #e0e0e0;
    border-bottom: none;
    overflow: hidden;
}

.cxvf-accordion:last-child {
    border-bottom: 1px solid #e0e0e0;
    border-radius: 0 0 6px 6px;
}

.cxvf-accordion:first-child {
    border-radius: 6px 6px 0 0;
}

.cxvf-accordion:only-child {
    border-radius: 6px;
    border-bottom: 1px solid #e0e0e0;
}

/* Accordion Header */
.cxvf-accordion__header {
    display: flex;
    align-items: center;
    padding: 0.875em 1em;
    cursor: pointer;
    user-select: none;
    background: #fafafa;
    transition: background 0.15s ease;
}

.cxvf-accordion__header:hover {
    background: #f0f0f0;
}

.cxvf-accordion__header:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
    border-radius: 2px;
}

.cxvf-accordion.is-open > .cxvf-accordion__header {
    border-bottom: 1px solid #e0e0e0;
}

/* Accordion Label */
.cxvf-accordion__label {
    font-weight: 600;
    font-size: 0.95em;
    min-width: 100px;
    color: #333;
}

/* Accordion Selected Value */
.cxvf-accordion__value {
    flex: 1;
    text-align: right;
    margin-right: 0.75em;
    font-size: 0.95em;
    color: #333;
}

.cxvf-accordion__value--empty {
    color: #999;
    font-style: italic;
}

/* Accordion Chevron Icon */
.cxvf-accordion__icon {
    width: 10px;
    height: 10px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.cxvf-accordion.is-open > .cxvf-accordion__header .cxvf-accordion__icon {
    transform: rotate(-135deg);
}

/* Accordion Panel (content area) */
.cxvf-accordion__panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    padding: 0 1em;
}

.cxvf-accordion.is-open > .cxvf-accordion__panel {
    max-height: 2000px;
    padding: 1em;
}

/* Select inside accordion panel */
.cxvf-accordion__panel select {
    width: 100%;
    max-width: 100%;
    padding: 0.75em 2.5em 0.75em 1em;
    font-size: 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1em center;
}

.cxvf-accordion__panel select:hover {
    border-color: #999;
}

.cxvf-accordion__panel select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* ==========================================================================
   Single Variation Display
   ========================================================================== */

.cxvf-variable-flag-form .single_variation {
    margin-bottom: 1em;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-price {
    margin-bottom: 0.5em;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-price .price {
    font-size: 1.5em;
    color: inherit;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-price .price del {
    opacity: 0.5;
    font-size: 0.9em;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-price .price ins {
    text-decoration: none;
    font-weight: 700;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-description {
    margin-bottom: 0.5em;
    font-style: italic;
    color: #666;
}

.cxvf-variable-flag-form .single_variation .woocommerce-variation-availability {
    margin-bottom: 0.5em;
}

/* Variation SKU */
.cxvf-variable-flag-form .single_variation .cxvf-variation-sku {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 0.5em;
}

.cxvf-variable-flag-form .single_variation .cxvf-variation-sku strong {
    font-weight: 600;
}

/* ==========================================================================
   Add to Cart Button
   ========================================================================== */

.cxvf-variable-flag-form .variations_button {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    align-items: center;
}

.cxvf-variable-flag-form .variations_button .quantity {
    margin-right: 0.5em;
}

.cxvf-variable-flag-form .variations_button .single_add_to_cart_button {
    flex: 1;
    min-width: 150px;
}

.cxvf-variable-flag-form .variations_button .single_add_to_cart_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cxvf-variable-flag-form .variations_button .single_add_to_cart_button.wc-variation-is-unavailable {
    background-color: #ccc;
    border-color: #ccc;
    color: #666;
}

/* ==========================================================================
   Disabled Swatches — must remain clickable
   ========================================================================== */

.cxvf-variable-flag-form .variable-item.disabled {
    pointer-events: auto !important;
    cursor: pointer;
}

/* ==========================================================================
   Hidden Swatches (dimension filtering by proportion)
   ========================================================================== */

.cxvf-variable-flag-form .variable-item.cxvf-hidden {
    display: none !important;
}

/* ==========================================================================
   Reset Variations Link
   ========================================================================== */

.cxvf-variable-flag-form .reset_variations {
    display: none;
    margin-top: 0.5em;
    font-size: 0.9em;
    color: #0073aa;
    text-decoration: none;
}

.cxvf-variable-flag-form .reset_variations:hover {
    text-decoration: underline;
}

.cxvf-variable-flag-form .reset_variations.visible {
    display: inline-block;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.cxvf-variable-flag-form.processing {
    opacity: 0.7;
    pointer-events: none;
}

.cxvf-variable-flag-form .single_variation.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 0.5em;
    border: 2px solid #e5e5e5;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: cxvf-variation-spin 0.8s linear infinite;
    vertical-align: middle;
}

/* Lazy loading variations spinner */
.cxvf-loading-variations {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 1em;
    background-color: #f8f9fa;
    border-radius: 4px;
    color: #666;
}

.cxvf-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e5e5;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: cxvf-variation-spin 0.8s linear infinite;
}

@keyframes cxvf-variation-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Out of Stock Message
   ========================================================================== */

.cxvf-variable-flag-form .stock.out-of-stock {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1em;
    border-radius: 4px;
    margin-bottom: 1em;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (min-width: 768px) {
    .cxvf-accordion__panel select {
        max-width: 300px;
    }

    .cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion__panel select {
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .cxvf-variable-flag-form .variations_button {
        flex-direction: column;
    }

    .cxvf-variable-flag-form .variations_button .quantity {
        margin-right: 0;
        width: 100%;
    }

    .cxvf-variable-flag-form .variations_button .single_add_to_cart_button {
        width: 100%;
    }
}

/* ==========================================================================
   Theme Compatibility
   ========================================================================== */

@media (prefers-contrast: high) {
    .cxvf-accordion {
        border-width: 2px;
    }

    .cxvf-accordion__panel select {
        border-width: 2px;
    }

    .cxvf-accordion__panel select:focus {
        outline: 2px solid;
        outline-offset: 2px;
    }

    .cxvf-accordion__header:focus-visible {
        outline-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cxvf-variable-flag-form .single_variation.loading::after {
        animation: none;
    }
}

/* ==========================================================================
   Shortcode Mode
   ========================================================================== */

.ct-shortcode:has(.cxvf-variable-flag-form) {
    align-self: stretch !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode,
.cxvf-variable-flag-form.cxvf-shortcode-mode .variations,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion-group,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-promotional-configurator,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion__header,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion__panel,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion__panel select,
.cxvf-variable-flag-form.cxvf-shortcode-mode .variable-items-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode {
    margin: 0 !important;
    gap: 0 !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .reset_variations {
    display: none !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .variable-item {
    box-sizing: border-box;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .woocommerce-variation-add-to-cart {
    display: none !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .single_variation_wrap {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .single_variation {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-promo-price-display {
    display: none !important;
}

.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-accordion-group,
.cxvf-variable-flag-form.cxvf-shortcode-mode .cxvf-promotional-configurator {
    margin-bottom: 0 !important;
}

/* ==========================================================================
   Satellite Price Shortcode — Style B (Minimal / Modern)

   Layout:
     [del €45,00]  [ins €36,00]  [-20%]     ← price line
     (€43,92 IVA inclusa)                    ← suffix line

   CSS custom properties used (set by theme / Oxygen):
     --text-m      suffix, badge, decimals
     --text-2xl    sale / main price
     --text-l      range price, regular price
     --text-body   suffix & regular price (grey)
     --text-title  main price (no sale) + decimals + sale price
   ========================================================================== */

/* Reset WooCommerce global .price styles so the theme has full control. */
.cxvf-price-shortcode .price {
    all: unset;
    display: block;
    line-height: 1.3;
}

.cxvf-price-shortcode .price * {
    all: unset;
}

/* Re-hide WooCommerce screen-reader text (all:unset above strips it). */
.cxvf-price-shortcode .price .screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px) !important;
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

/* --- Regular (non-sale) price ------------------------------------------- */
.cxvf-price-shortcode .price > .woocommerce-Price-amount,
.cxvf-price-shortcode .price > span > .woocommerce-Price-amount {
    font-size: var(--text-2xl, 1.8em) !important;
    font-weight: 700 !important;
    color: var(--text-title, #1a1a1a) !important;
}

/* --- Sale: strikethrough original price --------------------------------- */
.cxvf-price-shortcode .price del {
    text-decoration: line-through !important;
    font-size: var(--text-m, 0.8em) !important;
    font-weight: 600 !important;
    color: var(--text-body, #888) !important;
    margin-right: 0.35em;
}

.cxvf-price-shortcode .price del .woocommerce-Price-amount,
.cxvf-price-shortcode .price del .woocommerce-Price-amount bdi,
.cxvf-price-shortcode .price del .woocommerce-Price-currencySymbol {
    font-size: inherit !important;
    color: inherit !important;
    font-weight: inherit !important;
    vertical-align: baseline !important;
}

/* --- Sale: discounted price (ins) --------------------------------------- */
.cxvf-price-shortcode .price ins {
    text-decoration: none !important;
    font-size: var(--text-2xl, 1.8em) !important;
    font-weight: 700 !important;
    color: var(--text-title, #1a1a1a) !important;
}

.cxvf-price-shortcode .price ins .woocommerce-Price-amount {
    font-size: inherit !important;
    color: inherit !important;
    font-weight: inherit !important;
}

/* --- Decimals (smaller, superscript) ------------------------------------ */
.cxvf-price-shortcode .price .cxvf-decimals {
    font-size: var(--text-m, 0.55em);
    vertical-align: super;
    font-weight: 600;
}

/* --- Discount badge ----------------------------------------------------- */
.cxvf-price-shortcode .price .cxvf-discount-badge {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    font-size: var(--text-m, 0.7em);
    font-weight: 700;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.4em;
    line-height: 1.4;
}

/* --- Currency symbol ---------------------------------------------------- */
/* Default: same size & alignment as decimals (superscript) for main price. */
.cxvf-price-shortcode .price .woocommerce-Price-currencySymbol {
    font-size: var(--text-m, 0.55em);
    vertical-align: super;
    font-weight: 600;
}

/* --- Proposal A: Stacked Hierarchy layout ------------------------------ */

/* Savings row: original price + discount badge on one line */
.cxvf-price-shortcode .price .cxvf-savings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

/* Original (struck-through) price inside savings row */
.cxvf-price-shortcode .price .cxvf-savings-row del {
    font-size: 0.95rem;
    color: #888;
    opacity: 1;
}

/* Override discount badge when inside savings row: rotated -15deg */
.cxvf-price-shortcode .price .cxvf-savings-row .cxvf-discount-badge {
    margin-left: 0;
    transform: rotate(-15deg);
    transform-origin: center center;
    background: #c0392b;
}

/* Invisible placeholder to keep consistent price block height when no sale.
   Mimics .cxvf-savings-row flex layout; ::after replicates the discount badge
   box-model so the row height matches even when the badge is absent. */
.cxvf-price-shortcode .price .cxvf-savings-placeholder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.3;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.cxvf-price-shortcode .price .cxvf-savings-placeholder::after {
    content: '\00a0';
    display: inline-block;
    font-size: var(--text-m, 0.7em);
    font-weight: 700;
    padding: 0.15em 0.5em;
    line-height: 1.4;
    visibility: hidden;
}

/* Sale price (ins) on its own line, no underline */
.cxvf-price-shortcode .price ins {
    text-decoration: none !important;
    display: block;
    margin-top: 0.15rem;
}

/* VAT suffix as quiet third line */
.cxvf-price-shortcode .price .woocommerce-price-suffix {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.35rem;
}

/* ===== Stepper B — Quantity Selector =================================== */

.cxvf-qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    height: 46px;
    width: 135px;
}

.cxvf-qty-stepper button {
    all: unset;
    flex: 0 0 42px;
    width: 42px;
    height: 100%;
    background: #f5f5f5;
    font-size: 1.3rem;
    cursor: pointer;
    color: #333;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.cxvf-qty-stepper button:hover {
    background: #e0e0e0;
}

.cxvf-qty-stepper button:active {
    background: #d0d0d0;
}

.cxvf-qty-stepper input {
    all: unset;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: 100%;
    text-align: center !important;
    font-size: 1.05rem;
    font-weight: 600;
    -webkit-appearance: none;
    appearance: none;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    line-height: 46px !important;
    box-sizing: border-box !important;
    color: #333;
    border: none !important;
    outline: none !important;
}

/* Hide default WC quantity wrapper when stepper is present */
.cxvf-qty-stepper + .quantity {
    display: none;
}

/* --- Price range (before variation selection) ---------------------------- */
.cxvf-price-shortcode .price .woocommerce-Price-amount {
    font-size: var(--text-l, 1.2em);
    font-weight: 600;
    color: var(--text-title, #333);
}

/* When inside del or ins, inherit their specific sizes (rules above win). */

/* --- Tax suffix (below price) ------------------------------------------- */
.cxvf-price-shortcode .price .woocommerce-price-suffix {
    display: block;
    font-size: var(--text-m, 0.8em);
    color: var(--text-body, #888);
    font-weight: 400;
    margin-top: 0.15em;
}

.cxvf-price-shortcode .price .woocommerce-price-suffix .woocommerce-Price-amount,
.cxvf-price-shortcode .price .woocommerce-price-suffix .woocommerce-Price-amount bdi,
.cxvf-price-shortcode .price .woocommerce-price-suffix .woocommerce-Price-currencySymbol {
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
    vertical-align: baseline !important;
}

/* Satellite Add to Cart Shortcode */
.cxvf-add-to-cart-shortcode__inner {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5em;
    align-items: center;
}

.cxvf-add-to-cart-shortcode__inner .quantity {
    margin-right: 0.5em;
}

.cxvf-add-to-cart-shortcode__inner .cxvf-shortcode-add-to-cart {
    flex: 1;
    min-width: 0;
    height: 46px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 1em !important;
}

.cxvf-add-to-cart-shortcode__inner .cxvf-shortcode-add-to-cart.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cxvf-add-to-cart-shortcode__inner .cxvf-shortcode-add-to-cart.wc-variation-is-unavailable {
    background-color: #ccc;
    border-color: #ccc;
    color: #666;
}

/* ==========================================================================
   Promotional Mode — Swatch Configurator
   ========================================================================== */

.cxvf-promotional-configurator {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5em;
}

.cxvf-promotional-configurator .cxvf-accordion--last-visible {
    border-bottom: 1px solid #e0e0e0;
    border-radius: 0 0 6px 6px;
}

.cxvf-promotional-configurator .cxvf-accordion--last-visible:first-child {
    border-radius: 6px;
}

.cxvf-promo-swatches {
    display: flex;
    flex-wrap: wrap;
}

.cxvf-promo-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    margin: 4px;
    border: 1px solid #e8e8e8;
    border-radius: 2px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    background: #fff;
    text-align: center;
    box-shadow: 0 0 0 1px #000;
    font-size: 16px;
    font-weight: 500;
    min-width: 30px;
    height: 30px;
    box-sizing: border-box;
}

.cxvf-promo-swatch--has-image {
    flex: 0 0 calc(25% - 8px);
    min-width: 120px;
    height: auto;
    min-height: 30px;
}

@media (hover: hover) and (pointer: fine) {
    .cxvf-promo-swatch:hover {
        border-color: grey;
        box-shadow: 0 0 0 3px #000;
    }
}

.cxvf-promo-swatch:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.cxvf-promo-swatch:focus:not(:focus-visible) {
    box-shadow: 0 0 0 1px #000;
    border-color: #e8e8e8;
}

.cxvf-promo-swatch.is-selected:focus:not(:focus-visible) {
    box-shadow: 0 0 0 2px #000;
    border-color: grey;
}

.cxvf-promo-swatch.is-selected {
    border-color: grey;
    box-shadow: 0 0 0 2px #000;
}

.cxvf-promo-swatch.is-disabled {
    opacity: 0.3;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .cxvf-promo-swatch.is-disabled:hover {
        border-color: #e8e8e8;
        box-shadow: 0 0 0 1px #000;
    }
}

.cxvf-promo-swatch__image {
    width: 120px;
    height: 120px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cxvf-promo-swatch__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cxvf-promo-swatch__placeholder {
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 4px;
    display: block;
}

.cxvf-promo-swatch__label {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    line-height: 1.2;
    padding: 0 5px;
}

.cxvf-promo-swatch__price {
    font-size: 0.75em;
    color: #666;
    font-weight: 500;
    padding: 0 5px;
}

.cxvf-promo-swatch.is-selected .cxvf-promo-swatch__price {
    color: #333;
}

.cxvf-promo-swatch.is-disabled .cxvf-promo-swatch__label,
.cxvf-promo-swatch.is-disabled .cxvf-promo-swatch__price {
    color: inherit;
}

.cxvf-promo-empty {
    color: #999;
    font-style: italic;
    font-size: 0.9em;
    margin: 0;
}

.cxvf-promo-file {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cxvf-promo-file-download-link {
    display: inline-block;
}

.cxvf-promo-file-upload label {
    display: block;
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 4px;
    color: #333;
}

.cxvf-promo-file-upload input[type="file"] {
    font-size: 0.9em;
}

.cxvf-promo-price-display {
    margin: 1em 0;
    font-size: 1.25em;
    font-weight: bold;
    color: #333;
}

.cxvf-promo-total-price {
    font-size: 1.2em;
}

@media (max-width: 480px) {
    .cxvf-promo-swatch--has-image {
        flex: 0 0 calc(50% - 8px);
        min-width: 90px;
    }

    .cxvf-promo-swatch__image {
        width: 90px;
        height: 90px;
    }

    .cxvf-promo-swatch__label {
        font-size: 14px;
    }
}
