/**
 * Comparison Responsive & Animation Styles
 * Mobile media queries, animations, toast notifications, and reduced motion support
 */

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

@media (max-width: 767px) {
    /* Horizontal scrolling product cards */
    .comparison-products-header {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        position: sticky;
        top: 52px;
        padding: 0.75rem;
        gap: 0.75rem;
        background-color: var(--bg-primary);
        border-bottom: 1px solid var(--border);
    }

    .comparison-products-header::-webkit-scrollbar {
        display: none;
    }

    .comparison-products-header__label {
        display: none;
    }

    /* Compact horizontal cards on mobile */
    .comparison-product-card {
        flex: 0 0 auto;
        width: calc(50% - 0.375rem);
        min-width: 140px;
        max-width: 180px;
        scroll-snap-align: start;
        padding: 0.625rem;
        gap: 0.5rem;
    }

    .comparison-product-card__image-link {
        min-height: 80px;
    }

    .comparison-product-card__image {
        max-height: 70px;
    }

    .comparison-product-card__name {
        font-size: 0.8125rem;
        line-height: 1.25;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .comparison-product-card__brand {
        font-size: 0.6875rem;
    }

    .comparison-product-card__price {
        font-size: 1rem;
    }

    .comparison-product-card__stock,
    .comparison-product-card__view-btn {
        display: none;
    }

    .comparison-product-card__remove-btn {
        width: 24px;
        height: 24px;
        top: 0.375rem;
        right: 0.375rem;
    }

    .comparison-product-card__remove-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Add product card on mobile */
    .comparison-product-card--add {
        min-height: 120px;
        gap: 0.5rem;
    }

    .comparison-product-card__add-icon {
        width: 40px;
        height: 40px;
    }

    .comparison-product-card__add-icon svg {
        width: 20px;
        height: 20px;
    }

    .comparison-product-card__add-text {
        font-size: 0.75rem;
        text-align: center;
    }

    /* Spec rows with product names visible */
    .comparison-spec-row {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
        border: 1px solid var(--border);
        margin: 0 0 0.75rem 0;
        border-radius: var(--radius-md);
        background-color: var(--bg-secondary);
        overflow: hidden;
    }

    .comparison-spec-row:last-child {
        margin-bottom: 0;
    }

    .comparison-spec-row:hover {
        background-color: var(--bg-secondary);
    }

    /* Spec label becomes header */
    .comparison-spec-row__label {
        padding: 0.75rem 1rem;
        background-color: var(--bg-tertiary);
        border-bottom: 1px solid var(--border);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        font-size: 0.75rem;
        color: var(--text-primary);
        margin: 0;
    }

    /* Each product value with product identifier */
    .comparison-spec-row__value {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.625rem 1rem;
        border-bottom: 1px solid var(--border-light);
    }

    .comparison-spec-row__value:last-child {
        border-bottom: none;
    }

    /* Product name label in mobile spec value - added via JS */
    .comparison-spec-row__value::before {
        content: attr(data-product-name);
        font-size: 0.6875rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    /* Spec groups */
    .comparison-specs-group {
        border: none;
        gap: 0.75rem;
    }

    .comparison-specs-group__header {
        border-bottom: none;
        padding: 0.75rem 0;
        margin-bottom: 0;
    }

    .comparison-specs-group__title {
        font-size: 0.8125rem;
    }

    /* Mobile adjustments for toolbar and summary */
    .comparison-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .comparison-toolbar__search {
        max-width: none;
    }

    .comparison-summary__grid {
        grid-template-columns: 1fr;
    }

    .comparison-summary__values {
        flex-direction: column;
    }

    .comparison-summary__value {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.comparison-toast {
    position: fixed;
    bottom: clamp(1rem, 3vw, 1.5rem);
    left: clamp(1rem, 2vw, 1.5rem);
    right: auto;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: clamp(1rem, 2vw, 1.25rem);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: clamp(0.9375rem, 1.5vw + 0.25rem, 1rem);
    color: var(--text-primary);
}

.comparison-toast--error {
    border-color: var(--error);
    background-color: rgba(var(--error-rgb), 0.05);
}

.comparison-toast--error .comparison-toast__icon {
    color: var(--error);
}

.comparison-toast__icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comparison-toast__close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.comparison-toast__close:hover {
    color: var(--text-primary);
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-leave {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .comparison-product-card,
    .comparison-product-card__image-link,
    .comparison-spec-row,
    .comparison-toast {
        transition: none;
        animation: none;
    }

    .comparison-product-card__image-link:hover {
        transform: none;
    }
}
