@use 'sass:math';

.search {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;

    &__header {
        margin-bottom: 2rem;

        h2 {
            font-size: 2rem;
            font-weight: 700;
            margin: 0 0 1rem 0;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
    }

    &__form {
        display: flex;
        gap: 0.75rem;
        max-width: 500px;
    }

    &__input {
        flex: 1;
        padding: 0.875rem 1rem;
        border: 2px solid #e1e5e9;
        border-radius: 8px;
        font-size: 1rem;
        transition: all 0.2s ease;

        &:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        &::placeholder {
            color: #a0a0a0;
        }
    }

    &__btn {
        padding: 0.875rem 1.5rem;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;

        &:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
        }

        &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        &--secondary {
            background: transparent;
            border: 2px solid #667eea;
            color: #667eea;

            &:hover:not(:disabled) {
                background: #667eea;
                color: white;
            }
        }
    }

    &__results {
        margin-top: 2rem;
    }

    &__loading {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 3rem 1rem;

        p {
            margin: 1rem 0 0 0;
            color: #666;
            font-size: 1.1rem;
        }
    }

    &__load-more {
        display: flex;
        justify-content: center;
        margin: 2rem 0;
    }

    &__empty {
        text-align: center;
        padding: 3rem 1rem;
        color: #666;
        font-size: 1.1rem;
    }
}

.track-list {
    display: grid;
    gap: 1rem;
}

.track-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    cursor: pointer;

    &:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);

        .track-item__play-overlay {
            opacity: 1;
        }
    }

    &__artwork {
        position: relative;
        width: 80px;
        height: 80px;
        border-radius: 8px;
        overflow: hidden;
        flex-shrink: 0;

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

    &__play-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.2s ease;

        .play-icon {
            color: white;
            font-size: 1.5rem;
        }
    }

    &__info {
        flex: 1;
        min-width: 0;
    }

    &__title {
        font-size: 1.1rem;
        font-weight: 600;
        margin: 0 0 0.25rem 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
    }

    &__artist {
        font-size: 0.9rem;
        color: #667eea;
        margin: 0 0 0.5rem 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    &__meta {
        display: flex;
        gap: 1rem;
        font-size: 0.875rem;
        color: #666;
    }

    &__duration,
    &__plays {
        white-space: nowrap;
    }

    &__actions {
        display: flex;
        gap: 0.5rem;
    }

    &__btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        font-size: 0.875rem;

        &:hover {
            transform: scale(1.1);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }
    }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

// Responsive design
@media (max-width: 768px) {
    .search {
        padding: 1rem;

        &__form {
            flex-direction: column;
            max-width: none;
        }
    }

    .track-item {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;

        &__info {
            order: 2;
        }

        &__actions {
            order: 3;
            justify-content: center;
        }
    }
}