@use "sass:color";

$accent-color: #685fff;
$background-color: #1a181a;
$card-background: rgba(255, 255, 255, 0.05);
$border-color: #2a2a2a;
$text-color: #ebebeb;
$muted-text-color: #999999;
$purple-accent: rgba(104, 95, 255, 0.5);

.settings-section {
    color: $text-color;
    padding-inline: 3rem;
    padding-top: 1rem;
    padding-bottom: 1.7rem;

    .settings-group {
        background: rgba(255, 255, 255, 0.03);
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.08);

        .group-header {
            padding: 1rem 1.5rem;
            background: rgba(255, 255, 255, 0.05);
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);

            h3 {
                margin: 0;
                font-size: 1rem;
                font-weight: 500;
                color: $accent-color;
            }

            p {
                margin: 0.5rem 0 0;
                font-size: 0.85rem;
                color: $muted-text-color;
                line-height: 1.4;
            }
        }

        &.hierarchical-group,
        &.memory-group {
            margin-top: 2rem;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);

            .group-header {
                background: rgba(255, 255, 255, 0.05);
                border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            }
        }
    }

    .settings-grid {
        display: flex;
        flex-direction: column;

        .setting-item {
            display: flex;
            align-items: center;
            padding: 1rem 1.5rem;
            transition: background 0.2s ease;
            position: relative;

            .section-header {
                display: flex;
                align-items: center;
                gap: 0.5rem;
                margin-bottom: 8px;
            }

            h3 {
                margin: 0;
                font-size: 14px;
                color: rgba(255, 255, 255, 0.7);
                font-weight: 400;
            }

            &:not(:last-child)::after {
                content: "";
                position: absolute;
                bottom: 0;
                left: 1.5rem;
                right: 1.5rem;
                height: 1px;
                background: rgba(255, 255, 255, 0.06);
            }

            &:hover {
                background: rgba(255, 255, 255, 0.02);
            }

            .setting-label {
                width: 280px;
                padding-right: 1.5rem;

                .setting-title {
                    color: $text-color;
                    font-weight: 500;
                    font-size: 0.95rem;
                    display: flex;
                    align-items: center;
                    gap: 0.5rem;
                }

                .setting-description {
                    font-size: 0.8rem;
                    color: $muted-text-color;
                    margin-top: 0.25rem;
                    line-height: 1.4;
                }
            }

            .setting-value {
                flex: 1;
                display: flex;
                align-items: center;
                gap: 10px;

                app-llm-model-selector,
                app-embedding-model-selector {
                    width: 100%;
                }

                .warning-icon {
                    color: var(--color-warning);
                    font-size: 1.25rem;
                }

                .toggle-wrapper {
                    display: inline-flex;
                    background: rgba(20, 20, 20, 0.4);
                    border: 1px solid rgba(255, 255, 255, 0.1);
                    border-radius: 8px;
                    overflow: hidden;
                    cursor: pointer;
                    transition: all 0.2s ease;

                    &:hover {
                        border-color: rgba($accent-color, 0.3);
                    }

                    &.disabled {
                        cursor: default;

                        &:hover {
                            border-color: rgba(255, 255, 255, 0.1);
                        }
                    }

                    .toggle-option {
                        padding: 0.5rem 1rem;
                        font-size: 0.85rem;
                        color: $muted-text-color;
                        transition: all 0.2s ease;
                        min-width: 80px;
                        text-align: center;
                        position: relative;

                        &:hover:not(.active):not(.disabled-option) {
                            background: rgba(255, 255, 255, 0.05);
                        }

                        &.active {
                            background: rgba($accent-color, 0.2);
                            color: $text-color;
                        }

                        &.disabled-option {
                            cursor: default;
                            color: #666666;
                            background: rgba(255, 255, 255, 0.02);
                            display: flex;
                            flex-direction: row;
                            align-items: center;
                            justify-content: center;
                            gap: 8px;

                            .coming-soon-label {
                                font-size: 0.7rem;
                                color: #888888;
                                font-style: italic;
                                font-weight: 300;
                            }
                        }
                    }
                }

                .slider-container {
                    width: 350px;
                    display: flex;
                    flex-direction: column;

                    .slider-value {
                        margin-bottom: 0.5rem;
                    }

                    input[type="range"].gradient-slider {
                        -webkit-appearance: none;
                        appearance: none;
                        width: 100%;
                        height: 6px;
                        border-radius: 3px;
                        background: var(--gray-700);
                        outline: none;
                        cursor: pointer;
                        transition: background 0.2s ease;

                        /* WebKit track */
                        &::-webkit-slider-runnable-track {
                            height: 6px;
                            border-radius: 3px;
                            background: var(--gray-700);
                        }

                        /* WebKit thumb */
                        &::-webkit-slider-thumb {
                            -webkit-appearance: none;
                            appearance: none;
                            width: 16px;
                            height: 16px;
                            margin-top: -6px; /* center the thumb on the track */
                            background: $accent-color;
                            border-radius: 50%;
                            transition: transform 0.2s ease,
                                box-shadow 0.2s ease;

                            &:hover {
                                transform: scale(1.1);
                                box-shadow: 0 0 0 4px rgba($accent-color, 0.2);
                            }
                        }

                        /* Firefox track */
                        &::-moz-range-track {
                            height: 6px;
                            border-radius: 3px;
                            background: grey;
                        }

                        /* Firefox thumb */
                        &::-moz-range-thumb {
                            width: 18px;
                            height: 18px;
                            background: $text-color;
                            border: 2px solid $accent-color;
                            border-radius: 50%;
                            transition: transform 0.2s ease,
                                box-shadow 0.2s ease;

                            &:hover {
                                transform: scale(1.1);
                                box-shadow: 0 0 0 4px rgba($accent-color, 0.2);
                            }
                        }
                    }

                    .slider-labels {
                        display: flex;
                        justify-content: space-between;
                        margin-top: 0.5rem;

                        span {
                            font-size: 0.8rem;
                            color: $muted-text-color;
                        }
                    }
                }

                .selector {
                    position: relative;
                    width: 220px;
                    margin-left: 1rem;

                    select {
                        width: 100%;
                        padding: 0.6rem 1rem;
                        padding-right: 2rem;
                        background: rgba(20, 20, 20, 0.4);
                        border: 1px solid rgba(255, 255, 255, 0.1);
                        border-radius: 8px;
                        color: $text-color;
                        font-size: 0.9rem;
                        appearance: none;
                        cursor: pointer;
                        transition: all 0.2s ease;

                        &.not-specified {
                            border-color: rgba(
                                255,
                                165,
                                0,
                                0.3
                            ); // Orange-ish border
                            color: $muted-text-color;
                            font-style: italic;
                        }

                        &:hover {
                            background: rgba(30, 30, 30, 0.4);
                            border-color: rgba($accent-color, 0.3);
                        }

                        &:focus {
                            outline: none;
                            border-color: $accent-color;
                            box-shadow: 0 0 0 2px rgba($accent-color, 0.1);
                        }

                        option[value="null"] {
                            color: $muted-text-color;
                            font-style: italic;
                        }
                    }

                    i.ti-chevron-down {
                        position: absolute;
                        right: 0.6rem;
                        top: 50%;
                        transform: translateY(-50%);
                        color: $muted-text-color;
                        pointer-events: none;
                        transition: color 0.2s ease;
                        font-size: 1.2rem;
                    }

                    &:hover i.ti-chevron-down {
                        color: $accent-color;
                    }
                }

                input[type="number"] {
                    width: 120px;
                    padding: 0.6rem 1rem;
                    background: rgba(20, 20, 20, 0.4);
                    border: 1px solid rgba(255, 255, 255, 0.1);
                    border-radius: 8px;
                    color: $text-color;
                    font-size: 0.9rem;
                    transition: all 0.2s ease;

                    &:hover {
                        background: rgba(30, 30, 30, 0.4);
                        border-color: rgba($accent-color, 0.3);
                    }

                    &:focus {
                        outline: none;
                        border-color: $accent-color;
                        box-shadow: 0 0 0 2px rgba($accent-color, 0.1);
                    }

                    &::-webkit-inner-spin-button {
                        opacity: 0;
                    }
                }
            }
        }
    }
}

/* Shake animation (not related to the slider, left as-is) */
@keyframes shake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(4px);
    }
    75% {
        transform: translateX(-4px);
    }
    100% {
        transform: translateX(0);
    }
}
