/* ============================================
   COMPARADOR DE PRODUCTOS — toggle, barra sticky, tabla
   ============================================ */

/* Toggle en tarjetas (stack derecho: wishlist, compartir, comparar) */
.product-compare-toggle {
    position: absolute;
    top: 10px;
    right: 118px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.product-compare-toggle i {
    color: #ccc;
    font-size: 16px;
    transition: color 0.3s ease;
}

.product-compare-toggle:hover {
    transform: scale(1.1);
    background: #fff;
}

.product-compare-toggle.active {
    background: #ffd814;
    border-color: #ff9900;
}

.product-compare-toggle.active i {
    color: #0f1111;
}

/* Barra sticky inferior */
.compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border-top: 2px solid #ff9900;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(110%);
    transition: transform 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.compare-bar.visible {
    transform: translateY(0);
}

.compare-bar.pulse {
    animation: comparePulse 0.6s ease;
}

@keyframes comparePulse {
    0%, 100% {
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 -4px 20px rgba(255, 153, 0, 0.7);
    }
}

.compare-bar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.compare-bar-items {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow-x: auto;
    min-width: 0;
    touch-action: pan-y;
}

.compare-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 4px 8px 4px 4px;
    max-width: 220px;
    flex-shrink: 0;
}

.compare-chip img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 6px;
}

.compare-chip-fallback {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    border-radius: 6px;
    color: #999;
}

.compare-chip-name {
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-chip-remove {
    border: none;
    background: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.compare-chip-remove:hover {
    color: #B12704;
}

.compare-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.compare-bar-hint {
    font-size: 12px;
    color: #666;
}

.compare-bar-clear {
    background: none;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    color: #555;
    font-size: 13px;
    transition: all 0.2s ease;
}

.compare-bar-clear:hover {
    border-color: #B12704;
    color: #B12704;
}

.compare-bar-cta {
    background: linear-gradient(135deg, #ff9900 0%, #ff6600 100%);
    color: #fff;
    padding: 9px 22px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 3px 10px rgba(255, 102, 0, 0.35);
    transition: all 0.2s ease;
}

.compare-bar-cta:hover {
    color: #fff;
    transform: translateY(-1px);
}

.compare-bar-cta.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   PÁGINA /comparar/ — tabla
   ============================================ */
.compare-page {
    padding: 30px 0 90px;
}

.compare-page-title {
    text-align: center;
    margin-bottom: 25px;
    color: #0f1111;
}

.compare-table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.compare-table th,
.compare-table td {
    padding: 14px;
    border-bottom: 1px solid #eee;
    text-align: center;
    vertical-align: top;
}

.compare-table th {
    background: #f8f8f8;
    font-weight: 600;
    color: #0f1111;
    width: 150px;
    text-align: left;
}

.compare-table tr:last-child th,
.compare-table tr:last-child td {
    border-bottom: none;
}

.compare-table img.compare-img {
    width: 100%;
    max-width: 160px;
    border-radius: 8px;
    margin: 0 auto;
    display: block;
}

.compare-table .compare-title {
    font-weight: 600;
    color: #0f1111;
    font-size: 14px;
}

.compare-table .compare-price {
    color: #B12704;
    font-weight: 700;
    font-size: 18px;
}

.compare-table .compare-stock-in {
    color: #067d62;
    font-weight: 600;
}

.compare-table .compare-stock-out {
    color: #B12704;
    font-weight: 600;
}

.compare-table .compare-add-cart {
    display: inline-block;
    background: linear-gradient(135deg, #ff9900 0%, #ff6600 100%);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
}

.compare-empty {
    text-align: center;
    padding: 50px 20px;
    color: #666;
}

.compare-empty a {
    color: #ff9900;
    font-weight: 700;
}

.compare-clear-selection {
    text-align: center;
    margin-top: 20px;
}

.compare-clear-selection button {
    background: none;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 8px 20px;
    cursor: pointer;
    color: #555;
}

/* Dark mode */
body.dark-mode .compare-bar {
    background: #1e1e1e;
    border-top-color: #ff9900;
}

body.dark-mode .compare-chip {
    background: #2a2a2a;
    border-color: #333;
}

body.dark-mode .compare-chip-name {
    color: #ddd;
}

body.dark-mode .compare-bar-hint {
    color: #aaa;
}

body.dark-mode .compare-bar-clear {
    border-color: #444;
    color: #aaa;
}

body.dark-mode .compare-table-wrap {
    background: #1e1e1e;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

body.dark-mode .compare-table th {
    background: #2a2a2a;
    color: #fff;
}

body.dark-mode .compare-table th,
body.dark-mode .compare-table td {
    border-bottom-color: #333;
}

body.dark-mode .compare-table .compare-title {
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .compare-bar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }

    .compare-bar-items {
        justify-content: flex-start;
    }

    .compare-bar-actions {
        justify-content: space-between;
        gap: 8px;
    }

    .compare-bar-hint {
        display: none;
    }

    .compare-table th {
        width: 100px;
    }
}

/* ============================================
   SUGERENCIA INTELIGENTE — banner + highlight
   ============================================ */
.compare-suggest-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #ff9900;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    padding: 12px 14px;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s ease;
}

.compare-suggest-banner.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.compare-suggest-banner.above-bar {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

.compare-suggest-text {
    flex: 1;
    font-size: 13px;
    color: #333;
    line-height: 1.4;
}

.compare-suggest-text strong {
    color: #0f1111;
}

.compare-suggest-cta {
    flex-shrink: 0;
    background: linear-gradient(135deg, #ff9900 0%, #ff6600 100%);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s ease;
}

.compare-suggest-cta:hover {
    transform: translateY(-1px);
}

.compare-suggest-close {
    flex-shrink: 0;
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
}

.compare-suggest-close:hover {
    color: #B12704;
}

/* Efecto sutil en el toggle de comparar del producto sugerido */
.product-compare-toggle.highlight,
.product-compare-toggle-single.highlight {
    animation: compareHighlight 1.6s ease;
}

@keyframes compareHighlight {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 153, 0, 0);
    }
    40% {
        box-shadow: 0 0 0 6px rgba(255, 153, 0, 0.55);
    }
}

/* Botón Comparar en la ficha de producto */
.product-compare-toggle-single {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    transition: all 0.2s ease;
}

.product-compare-toggle-single:hover {
    border-color: #ff9900;
    color: #0f1111;
}

.product-compare-toggle-single.active {
    background: #ffd814;
    border-color: #ff9900;
    color: #0f1111;
}

body.dark-mode .product-compare-toggle-single {
    background: #2a2a2a;
    border-color: #444;
    color: #ccc;
}

body.dark-mode .product-compare-toggle-single:hover {
    border-color: #ff9900;
    color: #fff;
}

/* Dark mode */
body.dark-mode .compare-suggest-banner {
    background: #1e1e1e;
    border-color: #ff9900;
}

body.dark-mode .compare-suggest-text {
    color: #ddd;
}

body.dark-mode .compare-suggest-text strong {
    color: #fff;
}

/* Móvil: no bloquear acciones táctiles */
@media (max-width: 576px) {
    .compare-suggest-banner {
        flex-wrap: wrap;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .compare-suggest-text {
        flex-basis: 100%;
    }
}

@media (max-width: 768px) {
    .product-compare-toggle-single {
        width: 100%;
        justify-content: center;
    }
}
