/* ============================================
   ATRIBUTOS VARIABLES - BOTONES VISUALES
   Migrado desde Additional CSS del personalizador.
   Reemplaza los <select> nativos de WooCommerce con
   botones visuales personalizados en la página de producto.
   Requiere JS que inyecte .custom-variation-options en el DOM.
   ============================================ */

/* ============================================
   OCULTAR SELECTORES NATIVOS DE WOOCOMMERCE
   ============================================ */

.single-product .variations table tr td.value select,
.variations tr td.value select,
form.variations_form .variations select {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Ocultar el wrapper del select */
.variations tr td.value span:has(select) {
    display: none !important;
}

/* Ocultar botón de reset */
.variations .reset_variations {
    display: none !important;
}

/* ============================================
   CONTENEDOR DE OPCIONES PERSONALIZADAS
   ============================================ */

.custom-variation-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
    clear: both;
    align-items: flex-start;
}

/* ============================================
   BOTONES BASE
   ============================================ */

.variation-option-btn {
    background: #FFFFFF;
    border: 2px solid #EAEBED;
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    outline: none;
}

.variation-option-btn:hover {
    border-color: #034AB1;
    background: #F8F9FA;
}

.variation-option-btn.selected {
    background: #034AB1;
    border-color: #034AB1;
    color: #FFFFFF;
    animation: selectButton 0.2s ease;
}

.variation-option-btn.selected::after {
    content: '✓';
    font-weight: 700;
    font-size: 12px;
    margin-left: 4px;
}

.variation-option-btn:focus {
    outline: 2px solid #034AB1;
    outline-offset: 2px;
}

/* ============================================
   BOTONES DE COLOR - CIRCULARES
   ============================================ */

.variation-option-btn.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    border-width: 3px;
    min-height: 40px;
    margin-right: 4px;
}

.variation-option-btn.color-btn.selected {
    border-color: #FFFFFF;
    box-shadow: 0 0 0 3px #034AB1;
}

.variation-option-btn.color-btn.selected::after {
    content: '✓';
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin: 0;
}

/* Colores específicos */
.color-negro { background-color: #000000 !important; }
.color-azul  { background-color: #0066CC !important; }
.color-rojo  { background-color: #CC0000 !important; }
.color-verde { background-color: #00CC66 !important; }

/* ============================================
   BOTONES DE EDICIÓN - ESTILO RECTANGULAR
   ============================================ */

.variation-option-btn.text-btn {
    width: 165px;
    height: 80px;
    border-radius: 16px;
    border: 2px solid #EAEBED;
    background: #FFFFFF;
    color: #333333;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    opacity: 1;
    transition: all 0.3s ease;
    margin-right: 8px;
    padding: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.variation-option-btn.text-btn:hover {
    background: #F8F9FA;
    border-color: #2D3748;
}

.variation-option-btn.text-btn.selected {
    background: #FFFFFF;
    border-color: #EAEBED;
    border-top: 2px solid #2D3748;
    color: #2D3748;
}

.variation-option-btn.text-btn.selected::after {
    content: '✓';
    font-weight: 700;
    font-size: 12px;
    color: #2D3748;
    margin-left: 6px;
}

.variation-option-btn.text-btn:focus {
    outline: 2px solid #2D3748;
    outline-offset: 2px;
}

/* ============================================
   LABELS Y ESTRUCTURA
   ============================================ */

.variations .label {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #333333;
    margin-bottom: 12px;
    padding-bottom: 8px;
}

/* Stock status */
.stock.in-stock {
    color: #00C950 !important;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stock.in-stock::before {
    content: '✓';
    font-size: 12px;
}

/* Prevenir duplicación cuando el JS ya procesó las variaciones */
.custom-variation-options-processed {
    display: flex;
}

.custom-variation-options-processed ~ .custom-variation-options {
    display: none;
}

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes selectButton {
    0%   { transform: scale(1); }
    50%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .variation-option-btn.text-btn {
        width: 140px;
        height: 70px;
        font-size: 13px;
        margin-right: 6px;
    }

    .variation-option-btn.color-btn {
        width: 36px;
        height: 36px;
        margin-right: 3px;
    }
}

@media (max-width: 768px) {
    .custom-variation-options {
        gap: 6px;
    }

    .variation-option-btn.text-btn {
        width: 120px;
        height: 60px;
        font-size: 12px;
        padding: 8px;
        margin-right: 4px;
    }

    .variation-option-btn.color-btn {
        width: 32px;
        height: 32px;
        margin-right: 2px;
    }

    .variation-option-btn.text-btn.selected::after {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .custom-variation-options {
        gap: 4px;
    }

    .variation-option-btn.text-btn {
        width: 100px;
        height: 50px;
        font-size: 11px;
        margin-right: 3px;
    }

    /* NOTA: en el original el color-btn tenía height: 20px en 480px,
       lo que hacía el botón rectangular. Corregido a 40px (igual que el width). */
    .variation-option-btn.color-btn {
        width: 40px;
        height: 40px;
        margin-right: 2px;
    }
}

@media (max-width: 360px) {
    .custom-variation-options {
        flex-direction: column;
        align-items: flex-start;
    }

    .variation-option-btn.text-btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 4px;
    }

    /* Mantener fila horizontal solo para colores */
    .custom-variation-options[data-attribute*="color"] {
        flex-direction: row;
    }
}
