/*
 * 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 Searchbox component */
@layer components {
    .searchbox {
        position: relative;
        z-index: 100;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;

        & .searchbox__form {
            display: flex;
            align-items: center;
            background: var(--color-bg-surface-glass);
            border: 1px solid var(--color-border-glass);
            border-radius: 14px;
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            padding-inline: var(--space-md);
            transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

            &:focus-within {
                border-color: var(--color-accent-blue);
                background: var(--color-bg-surface);
                box-shadow:
                    0 0 0 1px rgba(69, 123, 157, 0.3),
                    0 20px 40px -10px rgba(0, 0, 0, 0.15);
            }
        }

        & .searchbox__icon {
            color: var(--color-accent-blue);
            opacity: 0.6;
            display: flex;
            align-items: center;
        }

        & .searchbox__input {
            flex-grow: 1;
            background: transparent;
            border: none;
            color: var(--color-text-heading);
            padding: 1.25rem var(--space-md);
            font-family: var(--font-family-body);
            font-size: 1.125rem;
            outline: none;

            &::placeholder {
                color: var(--color-text-main);
                opacity: 0.4;
            }
        }

        & .searchbox__results {
            position: absolute;
            top: calc(100% + 12px);
            left: 0;
            right: 0;
            background: var(--color-bg-surface);
            border: 1px solid var(--color-border-glass);
            border-top-color: var(--color-accent-blue);
            border-radius: 14px;
            backdrop-filter: blur(30px);
            -webkit-backdrop-filter: blur(30px);
            box-shadow: var(--shadow-premium);
            z-index: 1000;
            max-height: 600px;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: var(--color-border-glass) transparent;

            &::-webkit-scrollbar {
                width: 6px;
            }
            &::-webkit-scrollbar-thumb {
                background: var(--color-border-glass);
                border-radius: 10px;
            }

            &[hidden] {
                display: none;
            }

            &:not([hidden]) {
                animation: search-results-appear 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
            }
        }

        & .searchbox__results-inner {
            padding: var(--space-xs);
        }

        & .searchbox__results-list {
            list-style: none;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        & .searchbox__result-row {
            border-radius: var(--radius-md);
            overflow: hidden;
            transition: all 0.2s ease;

            &:hover, &.active {
                background: color-mix(in srgb, var(--color-text-heading) 5%, transparent);

                & .searchbox__result-thumb-glare {
                    opacity: 1;
                    transform: translateX(200%);
                }
            }
        }

        & .searchbox__result-link {
            display: flex;
            align-items: center;
            gap: var(--space-md);
            padding: var(--space-sm) var(--space-md);
            color: inherit;
            text-decoration: none;
        }

        & .searchbox__result-thumb {
            width: 40px;
            height: 56px;
            flex-shrink: 0;
            border-radius: 4px;
            overflow: hidden;
            background: var(--color-bg-surface);
            border: 1px solid var(--color-border-glass);
            position: relative;

            & img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
        }

        & .searchbox__result-thumb-placeholder {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--color-accent-blue);
            opacity: 0.5;
        }

        & .searchbox__result-thumb-glare {
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(
                to right,
                rgba(255, 255, 255, 0) 0%,
                rgba(255, 255, 255, 0.2) 50%,
                rgba(255, 255, 255, 0) 100%
            );
            transform: skewX(-20deg);
            opacity: 0;
            transition: transform 0.5s ease;
            pointer-events: none;
        }

        & .searchbox__result-info {
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            gap: 2px;
            min-width: 0;
        }

        & .searchbox__result-name {
            font-family: var(--font-family-heading);
            font-weight: 600;
            color: var(--color-text-heading);
            font-size: 1rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        & .searchbox__result-meta {
            display: flex;
            flex-wrap: wrap;
            gap: var(--space-xs) var(--space-sm);
            font-size: 0.75rem;
            color: var(--color-text-main);
            opacity: 0.6;
        }

        & .searchbox__result-price {
            font-family: var(--font-family-heading);
            font-weight: 700;
            color: var(--color-accent-blue);
            font-size: 1.125rem;
            flex-shrink: 0;
        }

        & .searchbox__no-results {
            padding: var(--space-2xl) var(--space-md);
            text-align: center;
            color: var(--color-text-main);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: var(--space-sm);

            & svg {
                color: var(--color-accent-red);
                margin-bottom: var(--space-xs);
                opacity: 0.5;
            }

            & p {
                font-family: var(--font-family-heading);
                font-size: 1.125rem;
                letter-spacing: 0.5px;

                & strong {
                    color: var(--color-text-heading);
                }
            }
        }
    }
}

@keyframes search-results-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
