/* ============================================================
   CF Widget — Product Actions
   ============================================================ */

.cw-product-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* ── Fila cantidad + ATC ────────────────────────────────── */

.cw-actions__add-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* ── Selector de cantidad ───────────────────────────────── */

.cw-quantity-selector {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
    border: 1.5px solid #E8E0D5;
    border-radius: 999px;
    overflow: hidden;
    height: 48px;
    background: #FFFFFF;
}

.cw-qty-btn {
    width: 44px;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 20px;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 200ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.cw-qty-btn:hover {
    background: #F5F0EA;
}

/* Reset del estado :focus para evitar que el botón se quede con un color
   "pegado" (típicamente rosa) heredado de Elementor Pro tras hacer click
   y mover el mouse fuera. Cuando NO se está haciendo hover, forzamos
   fondo transparente; al volver a hacer hover, el control de Elementor
   (qty_btn_hover_bg) sí pinta el botón. */
.cw-product-actions .cw-quantity-selector .cw-qty-btn:focus:not(:hover),
.cw-product-actions .cw-quantity-selector .cw-qty-btn:focus-visible:not(:hover),
.cw-product-actions .cw-quantity-selector .cw-qty-btn:active:not(:hover) {
    background: transparent !important;
    outline: none;
    box-shadow: none !important;
}

.cw-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cw-qty-input {
    width: 50px;
    text-align: center;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    background: transparent;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    border-radius: 0;
}

.cw-qty-input:focus,
.cw-qty-input:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.cw-qty-input::-webkit-inner-spin-button,
.cw-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Ocultar cualquier elemento inyectado por WooCommerce dentro del selector */
.cw-quantity-selector .screen-reader-text,
.cw-quantity-selector label {
    display: none !important;
}

/* ── Botón Agregar al Carrito ───────────────────────────── */

.cw-btn-atc {
    flex: 1;
    height: 48px;
    background: #1a1a1a;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 200ms ease, transform 100ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Padding horizontal explícito para que el contenido (icono + label
       + spinner) nunca quede pegado a los bordes en pantallas pequeñas
       cuando flex:1 lo encoge mucho por culpa del qty selector vecino. */
    padding: 0 16px;
    min-width: 0;
    position: relative;
}

/* WooCommerce inyecta un link `<a class="added_to_cart wc-forward">Ver
   carrito</a>` junto al formulario de Add-to-Cart cuando el AJAX nativo
   está activo. No queremos ese botón duplicado dentro de nuestra UI:
   el cliente ya tiene su propio botón "Comprar ahora" + mini-cart. */
.cw-product-actions .added_to_cart,
.cw-product-actions a.wc-forward,
.cw-actions__add-row .added_to_cart,
.cw-actions__add-row a.wc-forward {
    display: none !important;
}

.cw-btn-atc:not(:disabled):hover {
    background: #333333;
}

.cw-btn-atc:not(:disabled):active {
    transform: scale(0.98);
}

.cw-btn-atc:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.cw-btn-icon {
    flex-shrink: 0;
}

/* ── Spinner ────────────────────────────────────────────── */

.cw-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: cw-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.cw-btn-atc.cw-loading .cw-btn-spinner,
.cw-btn-buy-now.cw-loading .cw-btn-spinner {
    display: inline-block;
}

.cw-btn-atc.cw-loading .cw-btn-icon,
.cw-btn-atc.cw-loading .cw-btn-label,
.cw-btn-buy-now.cw-loading .cw-btn-label {
    display: none;
}

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

/* ── Botón Comprar Ahora ────────────────────────────────── */

.cw-btn-buy-now {
    width: 100%;
    height: 48px;
    background: transparent;
    color: #1a1a1a;
    border: 1.5px solid #1a1a1a;
    border-style: solid;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.cw-btn-buy-now:not(:disabled):hover {
    background: #1a1a1a;
    color: #FFFFFF;
}

.cw-btn-buy-now:not(:disabled):active {
    transform: scale(0.98);
}

.cw-btn-buy-now:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ── Bloque "Sin existencias" + Notificarme ─────────────── */

.cw-oos-block {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.cw-oos-message {
    margin: 0;
    padding: 12px 14px;
    background: #FFF6E5;
    color: #8A5A00;
    border: 1px solid #F0D9A8;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

/* Botón Notificarme — diseño WhatsApp (fondo verde + texto blanco + logo WA). */
.cw-product-actions .cw-notify-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    background: #25D366;
    color: #FFFFFF;
    border: 0 solid transparent;
    border-radius: 8px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    letter-spacing: 0;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
}

.cw-product-actions .cw-notify-btn:hover {
    background: #1DA851;
    color: #FFFFFF;
}

.cw-product-actions .cw-notify-btn:not(:disabled):active {
    transform: scale(0.98);
}

.cw-notify-icon {
    display: flex;
    align-items: center;
    color: inherit;
    flex-shrink: 0;
    pointer-events: none;
}

/* Toggle entre estado normal y "sin existencias":
   - Estado normal (.cw-product-actions sin .is-out-of-stock):
     ATC + Buy Now visibles, bloque OOS oculto.
   - Estado OOS (.cw-product-actions.is-out-of-stock):
     ATC + Buy Now ocultos, bloque OOS visible.

   En el editor de Elementor nunca queremos ocultar el bloque OOS para
   que el cliente pueda diseñarlo: forzamos su visibilidad cuando estamos
   dentro de `.elementor-editor-active`. */
.cw-product-actions .cw-oos-block {
    display: none;
}
.cw-product-actions.is-out-of-stock .cw-actions__add-row,
.cw-product-actions.is-out-of-stock .cw-btn-buy-now {
    display: none;
}
.cw-product-actions.is-out-of-stock .cw-oos-block {
    display: flex;
}
.elementor-editor-active .cw-product-actions .cw-oos-block {
    display: flex !important;
}

/* ── Trust Badges ───────────────────────────────────────── */

.cw-trust-badges {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cw-trust-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cw-badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    color: #666666;
    width: 1em;
    height: 1em;
}

.cw-badge-icon svg,
.cw-badge-icon i {
    width: 1em;
    height: 1em;
}

.cw-badge-text {
    font-size: 13px;
    color: #666666;
    line-height: 1.4;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .cw-actions__add-row {
        gap: 8px;
    }

    .cw-qty-btn {
        width: 38px;
    }

    .cw-qty-input {
        width: 44px;
        font-size: 14px;
    }
}

/* En teléfonos chicos (< 380px) el qty selector + ATC no caben holgados.
   Reducimos el qty selector y bajamos el padding/font del ATC para que
   el label "Agregar al Carrito" se vea sin compresión visual. */
@media (max-width: 380px) {
    .cw-actions__add-row {
        gap: 6px;
    }
    .cw-quantity-selector {
        height: 44px;
    }
    .cw-qty-btn {
        width: 32px;
        font-size: 18px;
    }
    .cw-qty-input {
        width: 34px;
        font-size: 13px;
    }
    .cw-btn-atc {
        height: 44px;
        padding: 0 10px;
        font-size: 13px;
        gap: 6px;
        letter-spacing: 0;
    }
    /* En pantallas tan estrechas, ocultamos el icono del carrito para
       darle más aire al label del botón. */
    .cw-btn-atc .cw-btn-icon {
        display: none;
    }
}
