/**
 * Copyright (c) Enalean, 2014-Present. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

@use "services";
@use "basepath";
@use "sass:color";

$accordion-width: 200px;

/* stylelint-disable selector-no-qualifying-type */
body.search-page .content {
    padding: 0;
}

.search-bar {
    padding: 20px;
    border-bottom: 1px solid #dddddd;
    text-align: center;

    form {
        margin: 0;

        .input-append {
            margin: 0;

            input {
                padding: 10px;
                font-size: 18px;
            }

            .btn {
                padding: 10px 30px;
                font-size: 18px;
            }
        }
    }
}

.additional-search-tabs {
    width: 100%;
    margin: 0;

    li {
        box-sizing: border-box;
        width: 50%;
        float: left;
        list-style-type: none;
        font-size: 1.2em;
        letter-spacing: 0.1em;
        text-align: center;

        > a {
            display: block;
            padding: 15px 0;
            transition: all 0.1s linear;
            border-left: 1px solid #dddddd;
            background: #ffffff;
            box-shadow: inset 0 -1px 0 #dddddd;
            color: #777777;

            &:hover {
                transition: all 0.1s linear;
                box-shadow: inset 0 -2px 0 #444444;
                color: #444444;
                text-decoration: none;
            }
        }

        &:first-child {
            > a {
                border-left: 0;
            }
        }

        &.active {
            > a {
                transition: all 0.1s linear;
                box-shadow: inset 0 -2px 0 #444444;
                color: #444444;
                text-decoration: none;
            }
        }
    }
}

.search-panes {
    width: 250px;
    max-width: 250px;
    height: 100%;
    margin: 0 30px 50px 0;
    padding: 15px;
    float: left;

    .search-pane {
        margin: 0 0 20px;
        border: 1px solid #e9e9e9;
        border-radius: var(--tlp-large-radius);
        background-color: #ffffff;

        .search-pane-header {
            padding: 8px 12px 10px;
            border-bottom: 2px solid #444444;
            color: #444444;
        }

        .search-pane-body {
            padding: 10px;

            > .search-pane-body-no-types {
                padding: 8px;
                color: #888888;
                font-size: 0.8em;
                text-align: center;
            }

            /* stylelint-disable max-nesting-depth, selector-max-compound-selectors */
            ul {
                margin: 0;
                padding: 0;

                li {
                    padding: 0 0 10px;
                    list-style-type: none;

                    &:last-child {
                        padding: 0;
                    }

                    a,
                    span {
                        color: #0088cc;

                        &.active {
                            color: color.adjust(#0088cc, $lightness: - 10%);
                            text-decoration: underline;
                        }

                        &:hover {
                            color: #005580;
                            text-decoration: none;
                            cursor: pointer;
                        }
                    }

                    p {
                        margin: 0 0 3px;
                    }

                    select {
                        width: 100%;
                    }

                    .select2-container {
                        display: inline-block;
                        box-sizing: border-box;
                        width: 100%;
                        max-width: 100%;

                        > ul {
                            margin: 0;
                            padding: 0;
                            border: 1px solid #dadada;
                            border-radius: var(--tlp-medium-radius);

                            > li {
                                padding: 3px 5px 3px 18px;

                                &.select2-search-field {
                                    padding: 0;
                                }
                            }
                        }

                        &.select2-container-active {
                            ul {
                                border: 1px solid #aaaaaa;
                                box-shadow: none;
                            }
                        }
                    }

                    .sub-facets {
                        color: #838383;
                        font-size: 0.85em;
                        font-style: italic;

                        &:hover {
                            color: #aaaaaa;
                            text-decoration: none;
                            cursor: pointer;
                        }
                    }

                    ul.sub-facets-list {
                        padding: 0;

                        li {
                            padding: 0;
                            font-size: 0.85em;

                            .checkbox {
                                font-size: 1em;
                            }
                        }
                    }
                }
            }

            &.full-text-search {
                > ul > li {
                    padding: 0 0 15px;

                    &:last-child {
                        padding: 0;
                    }

                    label {
                        margin: 0;
                    }
                }
            }
            /* stylelint-enable max-nesting-depth, selector-max-compound-selectors */
        }
    }
}

body > .select2-drop {
    border: 1px solid #cccccc;

    > ul.select2-results {
        max-height: 500px;

        li {
            font-size: 0.95em;
        }
    }
}

#search-results {
    min-width: 32px;
    min-height: 32px;
    padding: 15px 0;
    float: left;

    &.loading {
        background: url("#{basepath.$tuleap-common-theme-basepath}images/tuleap-spinner.gif")
            no-repeat center center;
    }

    &.no-search-panes {
        padding-left: 20px;
    }

    p.results-count {
        margin: 0 0 20px;
        color: #aaaaaa;
        font-size: 0.9em;
        font-style: italic;
    }

    p.no-result {
        padding: 10px 0 0;
        font-size: 1.2em;

        span {
            font-weight: bold;
        }
    }

    ul {
        margin: 0;
        list-style: none;

        li.result {
            position: relative;
            max-width: 750px;
            margin: 0 0 20px;
            padding: 0 0 0 20px;

            &.wiki::before {
                content: services.$services-wiki;
                position: absolute;
                top: 6px;
                right: 2px;
                left: 0;
                font-family: tuleap-services, "Font Awesome 6 Free";
            }

            &::before {
                content: "\f105"; // fa-angle-right
                position: absolute;
                top: 6px;
                left: 0;
                font-family: "Font Awesome 6 Free";
                font-weight: 900;
            }

            .title {
                display: block;
                font-size: 1.6em;
                line-height: 1.4em;

                &:hover {
                    text-decoration: none;
                }
            }

            .subtitle {
                color: #888888;
                font-style: italic;
            }

            .description {
                margin: 0 0 5px;
                color: #444444;
                font-size: 0.9em;
            }
        }

        @media screen and (max-width: 1150px) {
            li.result {
                max-width: 550px;
            }
        }

        @media screen and (max-width: 850px) {
            li.result {
                max-width: 350px;
            }
        }

        li.user {
            margin: 0 0 30px;

            .avatar {
                position: relative;
                top: 1px;
                width: 50px;
                height: 50px;
                margin: 0 10px 0 0;
                float: left;
                border-radius: 50%;
            }

            .realname {
                min-width: 500px;
                font-size: 1.6em;
                line-height: 1.4em;

                &:hover {
                    text-decoration: none;
                }

                &.only {
                    position: relative;
                    top: 8px;
                }
            }

            .username {
                min-width: 500px;
                margin: 0 0 5px;
                color: #444444;
                font-size: 0.9em;

                &.only {
                    position: relative;
                    top: 8px;
                }
            }
        }
    }
}
/* stylelint-enable */
