/**
 * Floating Comparison Bar Styles
 * Bottom-right fixed bar for quick product comparison access
 * Uses CSS custom properties from theme-vars.css
 * Mobile-first responsive design
 */

/* ============================================================================
   FLOATING BAR CONTAINER
   ============================================================================ */

.compare-floating-bar {
    position: fixed;
    bottom: clamp(1rem, 3vw, 1.5rem);
    right: clamp(1rem, 3vw, 1.5rem);
    z-index: 1000;
    max-width: min(340px, calc(100vw - 2rem));
    font-family: inherit;
    font-size: 0.9375rem;
}

/* Hide when no items in store */
.compare-floating-bar[x-cloak] {
    display: none !important;
}

/* ============================================================================
   COLLAPSED STATE - Compact button
   ============================================================================ */

.compare-bar__collapsed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.compare-bar__collapsed:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent);
}

.compare-bar__collapsed-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.compare-bar__icon {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.compare-bar__count {
    font-size: clamp(0.875rem, 1.5vw + 0.25rem, 0.9375rem);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.compare-bar__chevron {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.compare-bar__collapsed:hover .compare-bar__chevron {
    color: var(--accent);
    transform: translateY(-2px);
}

/* ============================================================================
   EXPANDED STATE - Full product list
   ============================================================================ */

.compare-bar__expanded {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: compareBarSlideUp 0.2s ease;
}

@keyframes compareBarSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   HEADER - Title and collapse button
   ============================================================================ */

.compare-bar__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.compare-bar__title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    font-size: clamp(0.875rem, 1.5vw + 0.25rem, 0.9375rem);
    font-weight: 600;
    color: var(--text-primary);
}

.compare-bar__title svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.compare-bar__collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.compare-bar__collapse-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.compare-bar__collapse-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.compare-bar__collapse-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================================================
   PRODUCTS LIST - Items and empty slots
   ============================================================================ */

.compare-bar__products {
    display: flex;
    flex-direction: column;
    max-height: clamp(150px, 35vh, 300px);
    overflow-y: auto;
}

/* Product item styling */
.compare-bar__product {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.15s ease;
}

.compare-bar__product:last-child {
    border-bottom: none;
}

.compare-bar__product:hover {
    background-color: var(--bg-tertiary);
}

/* Product image wrapper */
.compare-bar__product-image-wrapper {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-light);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-bar__product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

/* Product info - name and price */
.compare-bar__product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compare-bar__product-name {
    font-size: clamp(0.8125rem, 1.3vw + 0.2rem, 0.875rem);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.compare-bar__product-price {
    font-size: clamp(0.75rem, 1.1vw + 0.2rem, 0.8125rem);
    font-weight: 600;
    color: var(--success);
}

/* Remove button */
.compare-bar__remove-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.compare-bar__remove-btn:hover {
    background-color: rgba(var(--error-rgb), 0.1);
    color: var(--error);
}

.compare-bar__remove-btn:focus-visible {
    outline: 2px solid var(--error);
    outline-offset: 2px;
}

.compare-bar__remove-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================================================
   EMPTY SLOTS - Placeholder for remaining slots
   ============================================================================ */

.compare-bar__product--empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background-color: var(--bg-tertiary);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    min-height: 80px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.compare-bar__product--empty:hover {
    border-color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.05);
}

.compare-bar__product--empty:hover .compare-bar__product-empty-icon {
    color: var(--accent);
}

.compare-bar__product--empty:hover .compare-bar__product-empty-text {
    color: var(--accent);
}

.compare-bar__product-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

.compare-bar__product-empty-icon svg {
    width: 24px;
    height: 24px;
}

.compare-bar__product-empty-text {
    flex: 1;
    font-size: clamp(0.8125rem, 1.3vw + 0.2rem, 0.875rem);
    color: var(--text-muted);
}

/* ============================================================================
   FOOTER - Action buttons
   ============================================================================ */

.compare-bar__footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Clear all button */
.compare-bar__clear-btn {
    padding: 0.5rem 0.75rem;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: clamp(0.75rem, 1.1vw + 0.2rem, 0.8125rem);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.compare-bar__clear-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.compare-bar__clear-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Compare button - primary action */
.compare-bar__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-md);
    font-size: clamp(0.875rem, 1.5vw + 0.2rem, 0.9375rem);
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.compare-bar__btn svg {
    width: 18px;
    height: 18px;
}

.compare-bar__btn:hover:not(.is-disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.compare-bar__btn:focus-visible:not(.is-disabled) {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

/* Disabled state */
.compare-bar__btn.is-disabled,
.compare-bar__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

.compare-bar__products::-webkit-scrollbar {
    width: 6px;
}

.compare-bar__products::-webkit-scrollbar-track {
    background: transparent;
}

.compare-bar__products::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

.compare-bar__products::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-light);
}

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

@media (max-height: 500px) {
    .compare-bar__products {
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .compare-floating-bar {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .compare-bar__collapsed {
        padding: 0.75rem 0.875rem;
    }

    .compare-bar__product {
        padding: 0.625rem 0.875rem;
    }

    .compare-bar__header {
        padding: 0.75rem 0.875rem;
    }

    .compare-bar__footer {
        padding: 0.75rem 0.875rem;
    }

    /* On product pages, position above sticky footer */
    body.single-flavor_product .compare-floating-bar {
        bottom: 70px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .compare-floating-bar,
    .compare-bar__collapsed,
    .compare-bar__expanded,
    .compare-bar__remove-btn,
    .compare-bar__collapse-btn,
    .compare-bar__clear-btn,
    .compare-bar__btn {
        transition: none;
        animation: none;
    }
}
