/**
 * WooCommerce Popup Carrito - Estilos
 */

/* Mensaje de error en la página del producto */
.wpc-page-error-msg {
    display: block;
    margin: 8px 0 0 0;
    font-size: 0.85em;
    color: #d63638;
    text-align: left;
}

/* Variables CSS */
:root {
    --wpc-overlay-bg: rgba(0, 0, 0, 0.5);
    --wpc-popup-bg: #ffffff;
    --wpc-popup-radius: 0;
    --wpc-popup-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --wpc-added-bg: #f6f6f6;
    --wpc-check-bg: #78b350;
    --wpc-title-color: #333333;
    --wpc-text-color: #666666;
    --wpc-price-color: #333333;
    --wpc-price-sale: #333333;
    --wpc-price-regular: #999999;
    --wpc-border-color: #e5e5e5;
    /* Colores de botones (configurables desde los ajustes del plugin) */
    --wpc-btn-checkout-bg: #000000;
    --wpc-btn-checkout-color: #ffffff;
    --wpc-btn-continue-bg: #d6ad8c;
    --wpc-btn-continue-color: #000000;
    --wpc-btn-upsell-bg: #000000;
    --wpc-btn-upsell-color: #ffffff;
    --wpc-connector-color: #e0e0e0;
    --wpc-transition: 0.3s ease;
    --wpc-qty-border: var(--wpc-border-color);
    --wpc-qty-bg: #ffffff;
    --wpc-qty-height: 30px;
    --wpc-qty-btn-w: 28px;
    --wpc-qty-input-w: 38px;
    --wpc-qty-error: #c0392b;
}

/* Overlay */
.wpc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--wpc-overlay-bg);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--wpc-transition), visibility var(--wpc-transition);
}

.wpc-overlay.wpc-active {
    opacity: 1;
    visibility: visible;
}

/* Popup */
.wpc-popup {
    position: relative;
    background: var(--wpc-popup-bg);
    border-radius: var(--wpc-popup-radius);
    box-shadow: var(--wpc-popup-shadow);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(30px);
    transition: transform var(--wpc-transition);
}

.wpc-overlay.wpc-active .wpc-popup {
    transform: translateY(0);
}

/* Header */
.wpc-header {
    position: relative;
    padding: 20px 50px 20px 20px;
    border-bottom: 1px solid var(--wpc-border-color);
}

.wpc-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 400;
    color: var(--wpc-title-color);
    text-align: center;
    line-height: 1.4;
}

.wpc-close {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--wpc-text-color);
    transition: color var(--wpc-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.wpc-close:hover {
    color: var(--wpc-title-color);
}

/* Content */
.wpc-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Producto añadido */
.wpc-added-product {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: var(--wpc-added-bg);
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

.wpc-product-image-wrapper {
    position: relative;
    flex-shrink: 0;
}

.wpc-product-image {
    width: 70px;
    height: 70px;
    object-fit: cover;
}

.wpc-check-icon {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 22px;
    height: 22px;
    background: var(--wpc-check-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpc-check-icon svg {
    width: 12px;
    height: 10px;
}

.wpc-product-info {
    flex: 1;
    min-width: 0;
}

.wpc-product-name {
    margin: 0 0 4px 0;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--wpc-title-color);
    line-height: 1.3;
}

.wpc-product-variation {
    margin: 0 0 4px 0;
    font-size: 0.85em;
    color: var(--wpc-text-color);
}

.wpc-product-variation:empty {
    display: none;
}

.wpc-product-price {
    font-size: 0.9em;
    color: var(--wpc-price-color);
}

/* Precio en oferta: original tachado + precio actual */
.wpc-product-price del {
    color: var(--wpc-price-regular);
    font-weight: 400;
}

.wpc-product-price ins {
    text-decoration: none;
    color: var(--wpc-price-sale);
}

/* WooCommerce añade una etiqueta solo para lectores de pantalla junto al
   precio de oferta; el tema puede no definir la clase que la oculta. */
.wpc-product-price .screen-reader-text,
.wpc-upsell-price .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Selector de cantidad */
.wpc-qty {
    display: none;
    align-items: center;
    width: max-content;
    height: var(--wpc-qty-height);
    margin-top: 8px;
    border: 1px solid var(--wpc-qty-border);
    background: var(--wpc-qty-bg);
    box-sizing: border-box;
}

.wpc-qty.wpc-qty--visible {
    display: inline-flex;
}

.wpc-qty.wpc-qty--loading {
    opacity: 0.6;
}

.wpc-qty-btn {
    width: var(--wpc-qty-btn-w);
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--wpc-title-color);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: opacity var(--wpc-transition);
}

.wpc-qty-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.wpc-qty-input {
    width: var(--wpc-qty-input-w);
    height: 100%;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--wpc-qty-border);
    border-right: 1px solid var(--wpc-qty-border);
    border-radius: 0;
    background: transparent;
    color: var(--wpc-title-color);
    font-size: 0.85em;
    text-align: center;
    box-sizing: border-box;
    -moz-appearance: textfield;
    appearance: textfield;
}

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

.wpc-qty-input:focus,
.wpc-qty-btn:focus-visible {
    outline: 2px solid var(--wpc-title-color);
    outline-offset: -2px;
}

.wpc-qty-spinner {
    display: none;
    width: 12px;
    height: 12px;
    margin: 0 8px;
    border: 2px solid var(--wpc-qty-border);
    border-top-color: var(--wpc-title-color);
    border-radius: 50%;
    animation: wpc-qty-spin 0.7s linear infinite;
}

.wpc-qty--loading .wpc-qty-spinner {
    display: inline-block;
}

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

.wpc-qty-msg {
    display: none;
    margin: 5px 0 0;
    font-size: 0.78em;
    color: var(--wpc-qty-error);
}

.wpc-qty-msg.wpc-qty-msg--visible {
    display: block;
}

.wpc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Línea conectora - oculta por defecto */
.wpc-connector {
    display: none;
}

/* Sección Upsells */
.wpc-upsells {
    display: none;
}

.wpc-upsells.wpc-has-items {
    display: block;
    position: relative;
    margin-left: 35px;
}

/* Línea conectora vertical en el lateral izquierdo */
.wpc-upsells.wpc-has-items::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    height: calc(100% - 60px);
    width: 2px;
    background: var(--wpc-connector-color);
}

/* Punto final de la línea */
.wpc-upsells.wpc-has-items::after {
    content: '';
    position: absolute;
    left: -24px;
    bottom: 60px;
    width: 10px;
    height: 10px;
    background: var(--wpc-connector-color);
    border-radius: 50%;
}

.wpc-upsells-list {
    display: flex;
    flex-direction: column;
}

/* Item Upsell */
.wpc-upsell-item {
    display: flex;
    flex-direction: column;
    padding: 15px 20px 15px 0;
    border-bottom: 1px solid var(--wpc-border-color);
}

.wpc-upsell-item:last-child {
    border-bottom: none;
}

.wpc-upsell-main {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.wpc-upsell-image {
    width: 80px;
    height: 100px;
    object-fit: cover;
    flex-shrink: 0;
}

.wpc-upsell-info {
    flex: 1;
    min-width: 0;
}

.wpc-upsell-name {
    margin: 0 0 5px 0;
    font-size: 0.95em;
    font-weight: 500;
    color: var(--wpc-title-color);
    line-height: 1.3;
}

.wpc-upsell-price {
    font-size: 0.9em;
    color: var(--wpc-price-color);
}

.wpc-upsell-price del {
    color: var(--wpc-price-regular);
    font-weight: 400;
}

.wpc-upsell-price ins {
    text-decoration: none;
    color: var(--wpc-price-sale);
}

/* Selector de variación */
.wpc-upsell-variation-wrapper {
    margin-top: 8px;
}

.wpc-upsell-variation-select {
    width: 100%;
    padding: 0;
    padding-left: 10px;
    padding-right: 24px;
    border: 1px solid var(--wpc-border-color);
    background: #fff;
    font-size: 0.85em;
    color: var(--wpc-title-color);
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.wpc-upsell-variation-select:focus {
    outline: none;
    border-color: var(--wpc-title-color);
}

/* Botón Ver Detalle */
.wpc-upsell-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px 20px;
    background: var(--wpc-btn-upsell-bg);
    color: var(--wpc-btn-upsell-color);
    border: none;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: filter var(--wpc-transition);
}

.wpc-upsell-btn:hover {
    background: var(--wpc-btn-upsell-bg);
    color: var(--wpc-btn-upsell-color);
    filter: brightness(0.85);
}

/* Footer */
.wpc-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--wpc-border-color);
}

.wpc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    min-width: 200px;
    height: 44px;
    border-radius: 20px;
    transition: filter var(--wpc-transition);
}

.wpc-btn a,
.wpc-btn button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
}

.wpc-btn a:hover,
.wpc-btn button:hover {
    color: inherit;
}

.wpc-btn-checkout {
    background: var(--wpc-btn-checkout-bg);
    color: var(--wpc-btn-checkout-color);
}

.wpc-btn-checkout:hover {
    background: var(--wpc-btn-checkout-bg);
    color: var(--wpc-btn-checkout-color);
    filter: brightness(0.85);
}

.wpc-btn-continue {
    background: var(--wpc-btn-continue-bg);
    color: var(--wpc-btn-continue-color);
}

.wpc-btn-continue:hover {
    background: var(--wpc-btn-continue-bg);
    color: var(--wpc-btn-continue-color);
    filter: brightness(0.85);
}

/* Loading state */
.wpc-loading .wpc-content {
    opacity: 0.5;
    pointer-events: none;
}

/* ==================== DESKTOP (>= 768px) ==================== */

@media (min-width: 768px) {
    .wpc-popup {
        max-width: 600px;
    }

    /* Upsell items en fila */
    .wpc-upsell-item {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .wpc-upsell-main {
        flex: 1;
        min-width: 0;
    }

    .wpc-upsell-image {
        width: 70px;
        height: 90px;
    }

    .wpc-upsell-btn {
        width: auto;
        margin-top: 0;
        margin-left: 15px;
        flex-shrink: 0;
        padding: 10px 20px;
    }
}

/* ==================== MOBILE (< 768px) ==================== */

@media (max-width: 767px) {
    .wpc-overlay {
        align-items: flex-end;
    }

    .wpc-popup {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
    }


    .wpc-overlay.wpc-active .wpc-popup {
        transform: translateY(0);
    }

    .wpc-header {
        padding: 15px 45px 15px 15px;
    }

    .wpc-title {
        font-size: 1em;
    }

    .wpc-added-product {
        padding: 12px 15px;
    }

    .wpc-product-image {
        width: 50px;
        height: 50px;
    }

    /* Área táctil mínima aunque la imagen se achique */
    .wpc-qty {
        --wpc-qty-height: 34px;
        --wpc-qty-btn-w: 34px;
        --wpc-qty-input-w: 42px;
        margin-top: 6px;
    }

    .wpc-check-icon {
        width: 18px;
        height: 18px;
        top: -4px;
        left: -4px;
    }

    .wpc-check-icon svg {
        width: 10px;
        height: 8px;
    }

    .wpc-upsell-item {
        padding: 12px 15px;
    }

    .wpc-upsell-image {
        width: 70px;
        height: 90px;
    }
    .wpc-upsell-btn {
        width: auto;
        margin-top: 0;
        margin-left: 15px;
        flex-shrink: 0;
        padding: 10px 20px;
        align-self: center;
    }

    .wpc-footer {
        padding: 12px 15px 20px;
        justify-content: center;
    }

    .wpc-btn {
        min-width: 160px;
        height: 38px;
        padding: 0 10px;
    }

    .wpc-btn a,
    .wpc-btn button {
        font-size: 0.78em;
    }

    /* Ocultar línea conectora en móvil */
    .wpc-upsells.wpc-has-items {
        margin-left: 0;
    }

    .wpc-upsells.wpc-has-items::before,
    .wpc-upsells.wpc-has-items::after,
    .wpc-added-product::after {
        display: none !important;
    }
}

/* Accesibilidad - Reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    .wpc-overlay,
    .wpc-popup,
    .wpc-close,
    .wpc-btn,
    .wpc-upsell-btn,
    .wpc-qty-btn {
        transition: none;
    }

    .wpc-qty-spinner {
        animation: none;
    }
}
