/**
 * 2025 VentaClick - VC Carrito Rápido Pro
 * Estilos CSS para el módulo
 */

/* ========================================
   SELECTOR DE CANTIDAD PARA LISTADOS
   ======================================== */

.crp-product-actions {
    background: #f0f8ff;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #007bff;
    border-radius: 5px;
}

.crp-quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.crp-qty-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.crp-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.crp-qty-btn:hover {
    background: #e9ecef;
}

.crp-qty-btn:active {
    background: #d0d0d0;
    transform: scale(0.95);
}

.crp-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crp-qty-input {
    width: 50px !important;
    height: 32px;
    border: none !important;
    border-left: 1px solid #ddd !important;
    border-right: 1px solid #ddd !important;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
    outline: none;
    padding: 0 !important;
    margin: 0 !important;
}

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

.crp-add-to-cart-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px !important;
    height: 36px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 3px;
    transition: all 0.2s;
}

.crp-add-to-cart-btn .crp-btn-icon {
    font-size: 18px;
}

.crp-info-wrapper {
    display: flex;
    /* 1.2.3: alineación stock izquierda + UXB derecha incluso si stock está oculto */
    justify-content: flex-start;
    align-items: center;
    margin-top: 8px;
    /* 1.2.5: asegura ancho completo y separa el contenido del borde derecho */
    width: 100%;
    box-sizing: border-box;
    padding-right: 14px;
}

.crp-stock-info {
    /* 1.3.1: forzar mismo tamaño visual aunque el tema redefina <small> */
    font-size: 11px !important;
    line-height: 1.2;
    font-weight: 400;
    color: #666;
}


.crp-uxb-info {
    /* 1.3.1: forzar mismo tamaño visual aunque el tema redefina <small> */
    font-size: 11px !important;
    line-height: 1.2;
    font-weight: 400;
    color: #666;
    margin-left: auto;
    text-align: right;
    /* 1.2.5: el espaciado lo controla el padding-right del wrapper */
    margin-right: 0;
}
.crp-precio-total {
    font-size: 15px;
    font-weight: 700;
    color: #232323;
    margin-left: auto;
    text-align: right;
    line-height: 1.4;
}

/* ========================================
   MENSAJE SIN STOCK
   ======================================== */

.crp-no-stock {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 5px;
    padding: 12px;
    margin: 10px 0;
    text-align: center;
}

.crp-no-stock-label {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #856404;
}

.crp-no-stock-icon {
    font-size: 18px;
}

.crp-no-stock-text {
    font-size: 14px;
}

/* ========================================
   EFECTO DE CARGA EN BOTÓN
   ======================================== */

.crp-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.crp-loading .fa-spinner {
    animation: crp-spin 1s linear infinite;
}

@keyframes crp-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

@media (max-width: 768px) {
    .crp-quantity-wrapper {
        flex-wrap: wrap;
    }
    
    .crp-add-to-cart-btn {
        width: 100%;
        flex: none;
    }
    
    .crp-info-wrapper {
        /* 1.3.2: en mobile stock + uxb deben quedar en el mismo renglón */
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .crp-stock-info,
    .crp-uxb-info {
        white-space: nowrap;
        min-width: 0;
    }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

.crp-btn:focus,
.crp-qty-btn:focus,
.crp-add-to-cart-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .crp-qty-btn,
    .crp-add-to-cart-btn {
        transition: none;
        animation: none;
    }
}

/* ========================================
   SELECTOR DE CANTIDAD PERSONALIZADO (LEGACY)
   ======================================== */

.crp-quantity-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.crp-qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.crp-qty-btn:hover {
    background: #e0e0e0;
    color: #000;
}

.crp-qty-btn:active {
    background: #d0d0d0;
    transform: scale(0.95);
}

.crp-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crp-quantity-selector input[type="number"] {
    width: 60px;
    height: 36px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
    outline: none;
}

.crp-quantity-selector input[type="number"]::-webkit-inner-spin-button,
.crp-quantity-selector input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ========================================
   EFECTO DE CARGA EN BOTÓN
   ======================================== */

.crp-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.crp-loading .fa-spinner {
    animation: crp-spin 1s linear infinite;
}

@keyframes crp-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   NOTIFICACIONES TIPO TOAST
   ======================================== */

.crp-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    max-width: 400px;
}

.crp-toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.crp-toast-show {
    opacity: 1;
    transform: translateX(0);
}

.crp-toast-success {
    border-left: 4px solid #28a745;
}

.crp-toast-error {
    border-left: 4px solid #dc3545;
}

.crp-toast-content {
    padding: 16px;
}

.crp-toast-info {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
}

.crp-toast-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
}

.crp-toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #28a745;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.crp-toast-icon-error {
    background: #dc3545;
}

.crp-toast-text {
    flex: 1;
}

.crp-toast-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #333;
}

.crp-toast-text p {
    margin: 4px 0;
    font-size: 14px;
    color: #666;
}

.crp-toast-price {
    font-weight: 600;
    color: #333;
    font-size: 15px !important;
}

.crp-toast-cart-info {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 12px;
}

.crp-toast-cart-info p {
    margin: 0;
    font-size: 14px;
    color: #666;
    text-align: center;
}

.crp-toast-cart-info strong {
    color: #333;
}

.crp-toast-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crp-toast-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.crp-toast-close-btn:hover {
    color: #333;
}

/* ========================================
   NOTIFICACIONES TIPO MODAL
   ======================================== */

.crp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.crp-modal-show {
    opacity: 1;
    visibility: visible;
}

.crp-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.crp-modal-show .crp-modal {
    transform: scale(1);
}

.crp-modal-content {
    padding: 32px;
    text-align: center;
    position: relative;
}

.crp-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.crp-modal-close:hover {
    color: #333;
}

.crp-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #28a745;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    margin: 0 auto 16px;
}

.crp-modal-icon-error {
    background: #dc3545;
}

.crp-modal h3 {
    font-size: 24px;
    margin: 0 0 16px;
    color: #333;
}

.crp-modal-image {
    max-width: 200px;
    height: auto;
    margin: 16px 0;
    border-radius: 8px;
}

.crp-modal-content p {
    font-size: 16px;
    color: #666;
    margin: 8px 0;
}

.crp-modal-price {
    font-size: 20px !important;
    font-weight: 600;
    color: #333 !important;
    margin: 12px 0 !important;
}

.crp-modal-cart-info {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 16px 0;
}

.crp-modal-cart-info p {
    margin: 0;
    font-size: 16px;
}

.crp-modal-cart-info strong {
    color: #333;
}

.crp-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

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

.crp-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    text-align: center;
}

.crp-btn-primary {
    background: #007bff;
    color: #fff;
}

.crp-btn-primary:hover {
    background: #0056b3;
    color: #fff;
}

.crp-btn-secondary {
    background: #6c757d;
    color: #fff;
}

.crp-btn-secondary:hover {
    background: #545b62;
    color: #fff;
}

.crp-btn-link {
    background: transparent;
    color: #007bff;
    padding: 10px 16px;
}

.crp-btn-link:hover {
    background: rgba(0, 123, 255, 0.1);
    color: #0056b3;
}

/* ========================================
   ANIMACIÓN DE PRODUCTO AL CARRITO
   ======================================== */

.crp-flying-image {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   ANIMACIÓN DE CONTADOR
   ======================================== */

.crp-bounce {
    animation: crp-bounce-animation 0.6s ease;
}

@keyframes crp-bounce-animation {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

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

@media (max-width: 768px) {
    .crp-toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .crp-toast {
        transform: translateY(-100px);
    }

    .crp-toast-show {
        transform: translateY(0);
    }

    .crp-toast-actions {
        flex-direction: column;
    }

    .crp-toast-actions .crp-btn {
        width: 100%;
    }

    .crp-modal {
        width: 95%;
        max-width: none;
    }

    .crp-modal-content {
        padding: 24px 16px;
    }

    .crp-modal-actions {
        flex-direction: column;
    }

    .crp-modal-actions .crp-btn {
        width: 100%;
    }

    .crp-quantity-selector input[type="number"] {
        width: 50px;
    }

    .crp-qty-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* ========================================
   COMPATIBILIDAD CON TEMAS
   ======================================== */

/* Ajustes para tema Classic */
.product-add-to-cart .crp-quantity-selector {
    margin-right: 10px;
}

/* Asegurar que el selector no rompa el layout */
.product-actions .crp-quantity-selector,
.product-add-to-cart .crp-quantity-selector {
    display: inline-flex;
    vertical-align: middle;
}

/* En listados de productos */
.product-miniature .crp-quantity-selector {
    margin-bottom: 8px;
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

.crp-btn:focus,
.crp-qty-btn:focus,
.crp-toast-close:focus,
.crp-modal-close:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Reducir movimiento para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
    .crp-toast,
    .crp-modal,
    .crp-flying-image,
    .crp-btn {
        transition: none;
        animation: none;
    }
}

/* ========================================
   MODO OSCURO
   ======================================== */

@media (prefers-color-scheme: dark) {
    .crp-toast {
        background: #2d2d2d;
    }

    .crp-toast-text strong {
        color: #fff;
    }

    .crp-toast-text p {
        color: #ccc;
    }

    .crp-toast-cart-info {
        background: #3a3a3a;
    }

    .crp-modal {
        background: #2d2d2d;
    }

    .crp-modal h3 {
        color: #fff;
    }

    .crp-modal-content p {
        color: #ccc;
    }

    .crp-modal-cart-info {
        background: #3a3a3a;
    }

    .crp-quantity-selector {
        background: #2d2d2d;
        border-color: #444;
    }

    .crp-quantity-selector input[type="number"] {
        background: #2d2d2d;
        color: #fff;
        border-color: #444;
    }

    .crp-qty-btn {
        background: #3a3a3a;
        color: #fff;
    }

    .crp-qty-btn:hover {
        background: #4a4a4a;
    }
}

