/**
 * Compare drawer — Almazen Online (aligned with cart sidebar)
 */

#compareSidebarOverlay {
    transition: opacity 0.3s ease;
}

#compareSidebarOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#compareSidebarOverlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

#compareSidebar {
    --compare-accent: #dc2626;
    --compare-accent-dark: #b91c1c;
    --compare-surface: #fafafa;
    --compare-border: #e5e7eb;
    height: 100dvh;
    max-height: 100dvh;
}

.dark #compareSidebar {
    --compare-surface: #2a2a2a;
    --compare-border: #555555;
}

#compareSidebarItems {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Progress pills (1–4) */
.compare-progress {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.compare-progress__dot {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    transition: background 0.2s ease, transform 0.2s ease;
}

.dark .compare-progress__dot {
    background: #4b5563;
}

.compare-progress__dot.is-filled {
    background: var(--compare-accent);
}

.compare-progress__dot.is-next {
    background: rgba(220, 38, 38, 0.25);
    outline: 1px dashed rgba(220, 38, 38, 0.45);
}

.compare-progress__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    margin-top: 0.5rem;
}

.dark .compare-progress__label {
    color: #a0a0a0;
}

/* Item row */
.compare-drawer-item {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) 40px;
    align-items: start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--compare-surface);
    border: 1px solid var(--compare-border);
    border-radius: 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compare-drawer-item:hover {
    border-color: rgba(220, 38, 38, 0.35);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.dark .compare-drawer-item:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.compare-drawer-item__media {
    width: 72px;
    height: 72px;
    border-radius: 0.5rem;
    background: #fff;
    border: 1px solid var(--compare-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.dark .compare-drawer-item__media {
    background: #1e1e1e;
}

.compare-drawer-item__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.25rem;
}

.compare-drawer-item__brand {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--compare-accent);
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compare-drawer-item__title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    color: #111827;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.dark .compare-drawer-item__title {
    color: #f3f4f6;
}

.compare-drawer-item__meta {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.dark .compare-drawer-item__meta {
    color: #a0a0a0;
}

.compare-drawer-item__price {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--compare-accent);
}

.compare-drawer-item__upgrade {
    margin-top: 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    color: #b45309;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dark .compare-drawer-item__upgrade {
    color: #fbbf24;
}

.compare-drawer-item__remove {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    color: #dc2626;
    background: rgba(220, 38, 38, 0.08);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.compare-drawer-item__remove:hover {
    background: rgba(220, 38, 38, 0.16);
    border-color: rgba(220, 38, 38, 0.25);
}

/* Empty slot */
.compare-drawer-slot {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px dashed #d1d5db;
    border-radius: 0.75rem;
    color: #9ca3af;
    font-size: 0.8125rem;
    background: transparent;
}

.dark .compare-drawer-slot {
    border-color: #555;
    color: #888;
}

.compare-drawer-slot__icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dark .compare-drawer-slot__icon {
    background: #333;
}

/* Empty state (no items) */
.compare-drawer-empty {
    text-align: center;
    padding: 2.5rem 1rem;
}

.compare-drawer-empty i {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.dark .compare-drawer-empty i {
    color: #555;
}

/* Hint chip */
.compare-hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}

.dark .compare-hint-chip {
    background: rgba(180, 83, 9, 0.15);
    border-color: rgba(251, 191, 36, 0.25);
    color: #fcd34d;
}

.compare-hint-chip__swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: #fde68a;
    border: 1px solid #fbbf24;
}

/* Footer CTAs */
#compareSidebarBtn {
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

#compareSidebarBtn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.28);
}

#compareSidebarBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#compareSidebarBtnHint {
    font-size: 0.7rem;
    color: #6b7280;
    text-align: center;
    margin-top: 0.35rem;
}

.dark #compareSidebarBtnHint {
    color: #a0a0a0;
}

@keyframes compareItemIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.compare-drawer-item.is-new {
    animation: compareItemIn 0.25s ease;
}

@media (max-width: 640px) {
    #compareSidebarItems {
        gap: 0.625rem;
    }

    .compare-sidebar__header {
        flex-shrink: 0;
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }

    .compare-sidebar__body {
        overscroll-behavior: contain;
        padding: 0.875rem;
    }

    .compare-drawer-item {
        grid-template-columns: 56px minmax(0, 1fr) 36px;
        align-items: center;
        gap: 0.625rem;
        padding: 0.625rem;
        border-radius: 0.875rem;
    }

    .compare-drawer-item__media {
        width: 56px;
        height: 56px;
        border-radius: 0.625rem;
    }

    .compare-drawer-item__title {
        font-size: 0.8rem;
        line-height: 1.4;
        -webkit-line-clamp: 2;
    }

    .compare-drawer-item__remove {
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }

    .compare-hint-chip {
        display: flex;
        width: fit-content;
        max-width: 100%;
        line-height: 1.4;
        white-space: normal;
    }

    .compare-sidebar__footer {
        flex-shrink: 0;
        padding: 0.75rem 1rem max(0.75rem, env(safe-area-inset-bottom));
        box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.06);
    }

    #compareSidebarBtn {
        min-height: 3.25rem;
    }

    #compareClearAllBtn {
        min-height: 2.875rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #compareSidebarOverlay,
    #compareSidebarBtn,
    .compare-drawer-item,
    .compare-progress__dot {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Compare page table */
.compare-table {
    min-width: 720px;
}

.compare-table__spec-head,
.compare-table__spec-label {
    position: sticky;
    inset-inline-start: 0;
    z-index: 12;
    background: #f9fafb;
    border-inline-end: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    min-width: 180px;
}

.dark .compare-table__spec-head,
.dark .compare-table__spec-label {
    background: #2a2a2a;
    border-color: #555;
    color: #f3f4f6;
}

.compare-table__product-head {
    vertical-align: top;
    padding: 1rem;
    min-width: 220px;
    border-inline-end: 1px solid #e5e7eb;
    background: #fff;
}

.dark .compare-table__product-head {
    background: #3a3a3a;
    border-color: #555;
}

.compare-table__remove {
    position: absolute;
    top: 0.5rem;
    inset-inline-end: 0.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid #fecaca;
    background: #fff;
    color: #dc2626;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dark .compare-table__remove {
    background: #333;
    border-color: #7f1d1d;
}

.compare-table__thumb-link {
    display: block;
    margin-bottom: 0.75rem;
}

.compare-table__thumb {
    width: 7rem;
    height: 7rem;
    margin-inline: auto;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dark .compare-table__thumb {
    background: #1e1e1e;
    border-color: #555;
}

.compare-table__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.35rem;
}

.compare-table__brand {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #dc2626;
    margin-bottom: 0.15rem;
}

.compare-table__title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    color: #111827;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.dark .compare-table__title {
    color: #f3f4f6;
}

.compare-table__upgrade {
    font-size: 0.65rem;
    color: #b45309;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 0.5rem;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
}

.dark .compare-table__upgrade {
    color: #fbbf24;
    background: rgba(180, 83, 9, 0.15);
    border-color: rgba(251, 191, 36, 0.25);
}

.compare-table__price {
    font-size: 1rem;
    font-weight: 800;
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.compare-table__view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.5rem;
    background: #dc2626;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.compare-table__view-btn:hover {
    background: #b91c1c;
}

.compare-table__cell {
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    border-inline-end: 1px solid #e5e7eb;
    vertical-align: top;
}

.dark .compare-table__cell {
    border-color: #555;
    color: #e5e7eb;
}

.compare-table__cell--description {
    max-width: 280px;
}

.compare-table__description {
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.8125rem;
    color: #4b5563;
}

.dark .compare-table__description {
    color: #d1d5db;
}

.compare-table__cell--notes {
    min-width: 220px;
    max-width: 320px;
}

.compare-product-note {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.compare-product-note:last-child {
    margin-bottom: 0;
}

.compare-note-type {
    color: #b91c1c;
    font-size: 0.7rem;
    font-weight: 700;
}

.compare-cell--diff {
    background: #fef9c3 !important;
    font-weight: 600;
}

.dark .compare-cell--diff {
    background: rgba(161, 98, 7, 0.25) !important;
}

.compare-price-cell {
    font-weight: 800;
    color: #dc2626;
}

/* Keep the specification column readable on phones; product columns swipe horizontally. */
@media (max-width: 640px) {
    #compareTableContainer > .overflow-x-auto {
        border: 1px solid #e5e7eb;
        border-radius: 1rem;
        background: #fff;
        scrollbar-width: thin;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .dark #compareTableContainer > .overflow-x-auto {
        border-color: #555;
        background: #3a3a3a;
    }

    .compare-table {
        width: max-content;
        min-width: 100%;
        table-layout: fixed;
    }

    .compare-table__spec-head,
    .compare-table__spec-label {
        box-sizing: border-box;
        width: 50vw;
        min-width: 50vw;
        max-width: 50vw;
        padding: 0.875rem 0.75rem;
        font-size: 0.8rem;
        line-height: 1.45;
        overflow-wrap: anywhere;
        box-shadow: -5px 0 10px rgba(15, 23, 42, 0.04);
    }

    .compare-table__spec-label {
        vertical-align: middle;
    }

    .compare-table__product-head {
        box-sizing: border-box;
        width: 50vw;
        min-width: 50vw;
        max-width: 50vw;
        padding: 1rem 0.75rem;
        position: relative;
    }

    .compare-table__thumb-link {
        margin-bottom: 0.625rem;
    }

    .compare-table__thumb {
        width: min(7rem, 34vw);
        height: min(7rem, 34vw);
    }

    .compare-table__title {
        font-size: 0.78rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .compare-table__cell {
        box-sizing: border-box;
        width: 50vw;
        min-width: 50vw;
        max-width: 50vw;
        padding: 0.875rem 0.75rem;
        font-size: 0.8rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
        vertical-align: middle;
    }

    .compare-table__view-btn {
        min-height: 2.5rem;
        justify-content: center;
    }

    .compare-table__description {
        overflow-wrap: anywhere;
    }
}
