/*
 * This file is part of the UX SDC Bundle
 *
 * (c) Jozef Môstka <https://github.com/tito10047/ux-sdc>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/* Styles for Chart component */
@layer components {
	.chart{
        position: relative;

        & .cart-btn {
            background: transparent;
            border: 1px solid var(--color-border-glass);
            color: var(--color-text-main);
            font-family: var(--font-family-heading);
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: var(--space-xs) var(--space-md);
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: all var(--transition-physical);

            &:hover {
                background: rgba(255, 255, 255, 0.05);
                color: var(--color-text-heading);
                border-color: var(--color-accent-blue);
                transform: translateY(-1px);
            }

            &.is-active {
                animation: cartBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                border-color: var(--color-accent-red);
                background: rgba(230, 57, 70, 0.1);
            }
        }

        & .chart__dropdown {
            position: absolute;
            top: calc(100% + var(--space-xs));
            right: 0;
            width: 340px;
            background: transparent;
            border: 1px solid var(--color-border-glass);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-premium);
            z-index: 1000;
            padding: var(--space-md);
            animation: chartFadeIn 0.2s ease-out;

            &::before {
                content: '';
                position: absolute;
                inset: 0;
                background: rgba(15, 23, 42, 0.9);
                backdrop-filter: blur(calc(var(--glass-blur) * 1.2));
                -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.2));
                border-radius: inherit;
                z-index: -1;
            }
        }

        & .chart__items {
            display: flex;
            flex-direction: column;
            gap: var(--space-sm);
            max-height: 350px;
            overflow-y: auto;
            padding-right: var(--space-xs);

            /* Scrollbar styling */
            &::-webkit-scrollbar {
                width: 4px;
            }
            &::-webkit-scrollbar-track {
                background: transparent;
            }
            &::-webkit-scrollbar-thumb {
                background: rgba(255, 255, 255, 0.1);
                border-radius: 2px;
            }
        }

        & .chart__item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: var(--space-md);
            padding-bottom: var(--space-sm);
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            animation: chartItemIn 0.4s cubic-bezier(0.23, 1, 0.32, 1) both;

            &:last-child {
                border-bottom: none;
                padding-bottom: 0;
            }
        }

        & .chart__item-name {
            font-size: var(--size-step--1);
            font-weight: 400;
            color: var(--color-text-main);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        & .chart__item-right {
            display: flex;
            align-items: center;
            gap: var(--space-sm);
            flex-shrink: 0;
        }

        & .chart__item-price {
            font-family: var(--font-family-heading);
            font-weight: 600;
            color: var(--color-text-heading);
            font-size: var(--size-step-0);
        }

        & .chart__item-remove {
            background: transparent;
            border: none;
            color: var(--color-text-muted, #64748b);
            cursor: pointer;
            font-size: 1.25rem;
            line-height: 1;
            padding: var(--space-2xs);
            transition: color var(--transition-physical);

            &:hover {
                color: var(--color-accent-red);
            }
        }

        & .chart__empty {
            text-align: center;
            padding: var(--space-lg) var(--space-md);
            color: var(--color-text-main);
            opacity: 0.6;
            font-style: italic;
        }

        & .chart__footer {
            margin-top: var(--space-md);
            padding-top: var(--space-md);
            border-top: 1px solid var(--color-border-glass);
        }

        & .chart__total {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: var(--space-md);

            & span:first-child {
                text-transform: uppercase;
                font-size: var(--size-step--1);
                letter-spacing: 1px;
                color: var(--color-text-main);
            }

            & span:last-child {
                font-family: var(--font-family-heading);
                font-size: var(--size-step-1);
                font-weight: 700;
                color: var(--color-text-heading);
            }
        }

        & .chart__checkout-btn {
            display: block;
            width: 100%;
            background: var(--color-accent-red);
            color: white;
            text-align: center;
            padding: var(--space-sm);
            border-radius: var(--radius-sm);
            font-family: var(--font-family-heading);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
            transition: all var(--transition-physical);

            &:hover {
                filter: brightness(1.15);
                transform: translateY(-2px);
                box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
            }

            &:active {
                transform: translateY(0);
            }
        }
	}
}

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

@keyframes cartBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

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