@use '../variables' as *;

.proddisp-product-selector {
    .proddisp-specific-products {
        .proddisp-product-filters {
            display: flex;
            gap: $spacing-md;
            margin-bottom: $spacing-lg;
            padding: $spacing-md;
            background: $background-lighter;
            border-radius: $border-radius;
            border: 1px solid $border-color;

            .proddisp-search-input {
                flex: 1;
                max-width: 300px;
                padding: $spacing-sm $spacing-md;
                border: 1px solid $border-color;
                border-radius: $border-radius-full;
                background: $white;
                transition: $transition;

                &:focus {
                    border-color: $primary-color;
                    box-shadow: $focus-shadow;
                }

                &::placeholder {
                    color: $text-light;
                }
            }

            select {
                max-width: 200px;
                padding: $spacing-sm $spacing-md;
                border: 1px solid $border-color;
                border-radius: $border-radius;
                background: $white;
                transition: $transition;

                &:focus {
                    border-color: $primary-color;
                    box-shadow: $focus-shadow;
                }
            }
        }

        .proddisp-bulk-actions {
            display: flex;
            align-items: center;
            gap: $spacing-md;
            margin-bottom: $spacing-lg;
            padding: $spacing-md $spacing-lg;
            background: linear-gradient(135deg, $background-lighter 0%, $background-light 100%);
            border-radius: $border-radius;
            border: 1px solid $border-color;

            .selected-count {
                margin-left: auto;
                font-size: 14px;
                font-weight: 500;
                color: $text-color;
                padding: $spacing-xs $spacing-sm;
                background: $white;
                border-radius: $border-radius-sm;
                border: 1px solid $border-color;
            }
        }

        .prodisp-selected-product {
            display: flex ;
            align-items: center;
            gap: 16px;
            margin-bottom: 24px;
            padding: 8px 21px;
        }

        .proddisp-loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: $spacing-2xl;
            background: $white;
            border: 1px solid $border-color;
            border-radius: $border-radius;

            .spinner {
                width: 32px;
                height: 32px;
                border: 3px solid $light-gray;
                border-top: 3px solid $primary-color;
                border-radius: 50%;
                animation: spin 1s linear infinite;
                margin-bottom: $spacing-md;
            }

            p {
                color: $text-light;
                margin: 0;
            }
        }

        .proddisp-product-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: $spacing-sm;
            max-height: 500px;
            overflow-y: auto;
            border: 1px solid $border-color;
            border-radius: $border-radius;
            padding: $spacing-md;
            background: $white;

            .proddisp-product-item {
                border: 1px solid $border-color;
                border-radius: $border-radius;
                padding: $spacing-md;
                transition: $transition;
                background: $white;

                &.selected {
                    border-color: $primary-color;
                    background: rgba($primary-color, 0.05);
                    box-shadow: 0 0 0 1px rgba($primary-color, 0.1);
                }

                &:hover {
                    border-color: $primary-color;
                    transform: translateY(-1px);
                    box-shadow: $shadow-md;
                }

                label {
                    display: flex;
                    align-items: center;
                    gap: $spacing-md;
                    cursor: pointer;
                    margin: 0;

                    input[type="checkbox"] {
                        width: auto;
                        margin: 0;
                        accent-color: $primary-color;
                        transform: scale(1.1);
                    }
                }

                .product-info {
                    display: flex;
                    align-items: center;
                    gap: $spacing-md;
                    flex: 1;

                    .product-thumbnail {
                        width: 50px;
                        height: 50px;
                        object-fit: cover;
                        border-radius: $border-radius;
                        border: 1px solid $border-color;
                        background: $background-light;
                    }

                    .product-details {
                        flex: 1;

                        .product-name {
                            margin: 0 0 $spacing-xs 0;
                            font-size: 14px;
                            font-weight: 600;
                            color: $text-dark;
                            line-height: 1.3;
                        }

                        .product-price {
                            font-size: 13px;
                            color: $text-light;
                            font-weight: 500;
                        }
                    }
                }
            }

            .no-products {
                text-align: center;
                padding: $spacing-2xl;
                color: $text-light;

                p {
                    margin: 0;
                    font-size: 14px;
                }
            }
        }

        .selected-products-summary {
            margin-bottom: $spacing-lg;
            padding: $spacing-md $spacing-lg;
            background: linear-gradient(135deg, rgba($primary-color, 0.05) 0%, rgba($primary-color, 0.02) 100%);
            border: 1px solid rgba($primary-color, 0.2);
            border-radius: $border-radius;

            h4 {
                margin: 0 0 $spacing-sm 0;
                font-size: 14px;
                font-weight: 600;
                color: $primary-color;
            }

            p {
                margin: 0;
                font-size: 13px;
                color: $text-color;
                line-height: 1.4;

                &.other-pages-notice {
                    margin-top: $spacing-xs;
                    color: $text-light;
                    font-style: italic;
                }

                strong {
                    color: $primary-color;
                    font-weight: 600;
                }
            }
        }

        .proddisp-bulk-actions {
            .selected-count {
                .page-selection-info {
                    font-size: 12px;
                    color: $text-light;
                    font-weight: 400;
                }
            }
        }

        .selected-products-view {
            margin-bottom: $spacing-lg;
            padding: $spacing-lg;
            background: $white;
            border: 2px solid $primary-color;
            border-radius: $border-radius;

            h4 {
                margin: 0 0 $spacing-md 0;
                font-size: 16px;
                font-weight: 600;
                color: $primary-color;
                display: flex;
                align-items: center;
                gap: $spacing-sm;

            }

            .selected-products-grid {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
                gap: $spacing-sm;
                max-height: 300px;
                overflow-y: auto;
                padding: $spacing-sm;
                background: $background-lighter;
                border-radius: $border-radius;

                .selected-product-item {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    padding: $spacing-sm;
                    background: $white;
                    border: 1px solid $border-color;
                    border-radius: $border-radius;
                    transition: $transition;

                    &:hover {
                        border-color: $primary-color;
                        box-shadow: $shadow-sm;
                    }

                    .product-info {
                        display: flex;
                        align-items: center;
                        gap: $spacing-sm;
                        flex: 1;

                        .product-thumbnail {
                            width: 40px;
                            height: 40px;
                            object-fit: cover;
                            border-radius: $border-radius-sm;
                            border: 1px solid $border-color;
                        }

                        .product-details {
                            flex: 1;

                            .product-name {
                                margin: 0 0 $spacing-xs 0;
                                font-size: 13px;
                                font-weight: 500;
                                color: $text-dark;
                                line-height: 1.2;
                            }

                            .product-price {
                                font-size: 12px;
                                color: $text-light;
                            }
                        }
                    }

                    .remove-product {
                        background: $danger-color;
                        color: white;
                        border: none;
                        width: 24px;
                        height: 24px;
                        border-radius: 50%;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        cursor: pointer;
                        font-size: 16px;
                        font-weight: bold;
                        transition: $transition;
                        flex-shrink: 0;

                        &:hover {
                            background: $danger-color;
                            transform: scale(1.1);
                        }
                    }
                }

                .loading-selected {
                    grid-column: 1 / -1;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    padding: $spacing-lg;

                    .spinner {
                        width: 24px;
                        height: 24px;
                        border: 2px solid $light-gray;
                        border-top: 2px solid $primary-color;
                        border-radius: 50%;
                        animation: spin 1s linear infinite;
                        margin-bottom: $spacing-sm;
                    }

                    p {
                        margin: 0;
                        font-size: 13px;
                        color: $text-light;
                    }
                }
            }
        }

        .proddisp-pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: $spacing-md;
            margin-top: $spacing-lg;
            padding: $spacing-md;
            background: $background-light;
            border-radius: $border-radius;

            .page-info {
                color: $text-light;
                font-size: 14px;
                margin: 0 $spacing-md;
            }
        }
    }

    // Category, Tag, Brand, Attribute Selection
    .proddisp-category-selection,
    .proddisp-tag-selection,
    .proddisp-brand-selection,
    .proddisp-attribute-selection {

        .proddisp-category-grid,
        .proddisp-tag-grid,
        .proddisp-brand-grid,
        .proddisp-term-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: $spacing-sm;
            margin-top: $spacing-md;
            max-height: 400px;
            overflow-y: auto;
            padding: $spacing-md;
            border: 1px solid $border-color;
            border-radius: $border-radius;
            background: $white;

            .category-item,
            .tag-item,
            .brand-item,
            .term-item {
                border: 1px solid $border-color;
                border-radius: $border-radius;
                padding: $spacing-sm $spacing-md;
                transition: $transition;
                background: $white;

                &:hover {
                    border-color: $primary-color;
                    background: rgba($primary-color, 0.02);
                }

                label {
                    display: flex;
                    align-items: center;
                    gap: $spacing-sm;
                    cursor: pointer;
                    margin: 0;
                    font-size: 14px;

                    input[type="checkbox"] {
                        width: auto;
                        margin: 0;
                        accent-color: $primary-color;
                    }

                    .category-name,
                    .tag-name,
                    .brand-name,
                    .term-name {
                        font-weight: 500;
                        color: $text-dark;
                    }

                    .category-count,
                    .tag-count,
                    .brand-count,
                    .term-count {
                        font-size: 12px;
                        color: $text-light;
                        margin-left: auto;
                    }
                }
            }
        }

        .selected-summary {
            margin-top: $spacing-md;
            padding: $spacing-sm $spacing-md;
            background: rgba($success-color, 0.1);
            border: 1px solid rgba($success-color, 0.3);
            border-radius: $border-radius;
            color: $success-color;
            font-size: 14px;
            text-align: center;
        }
    }

    .proddisp-all-products {
        .all-products-info {
            display: flex;
            flex-direction: column;
            gap: $spacing-md;
            padding: $spacing-lg;
            background: $background-lighter;
            border: 1px solid $border-color;
            border-radius: $border-radius;

            .info-item {
                display: flex;
                align-items: center;
                gap: $spacing-md;
                font-size: 14px;
                color: $text-color;

                .dashicons {
                    color: $primary-color;
                    font-size: 18px;
                }
            }
        }
    }

    // Pro feature notices
    .pro-feature-notice {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(248, 250, 252, 0.2) 100%);
        -webkit-backdrop-filter: blur(12px) saturate(200%);
        backdrop-filter: blur(0px) saturate(60%);
        border-radius: var(--editor-radius-lg);
        border: 1px solid $warning-color;
        border-radius: $border-radius;
        padding: $spacing-lg;
        text-align: center;
        margin: $spacing-md 0;

        h4 {
            margin: 0 0 $spacing-sm 0;
            color: #92400e;
            font-size: 16px;
        }

        p {
            margin: 0 0 $spacing-md 0;
            color: #92400e;
        }

        .button-primary {
            background: $warning-color;
            border-color: $warning-color;

            &:hover {
                background: $warning-color;
                border-color: $warning-color;
            }
        }
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }
}