/* -------------------------------------------------------------------------- */
/* Couleurs                                                                    */
/* -------------------------------------------------------------------------- */

:root {
    --background: #171717;
    --background-secondary: #212121;
    --background-tertiary: #2a2a2a;

    --text-primary: #ececec;
    --text-secondary: #a6a6a6;

    --border: #343434;
    --border-hover: #4a4a4a;

    --user-message: #2f2f2f;

    --button: #ececec;
    --button-hover: #ffffff;
    --button-text: #171717;
    --button-disabled: #424242;

    --error-background: #3a2020;
    --error-text: #ffb4b4;

    --max-width: 800px;
}


/* -------------------------------------------------------------------------- */
/* Reset                                                                       */
/* -------------------------------------------------------------------------- */

* {
    box-sizing: border-box;
}


html,
body {
    height: 100%;
    margin: 0;
}


body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    background-color: var(--background);
    color: var(--text-primary);
}


/* -------------------------------------------------------------------------- */
/* Application                                                                 */
/* -------------------------------------------------------------------------- */

.app {
    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100dvh;

    overflow: hidden;

    background-color: var(--background);
}


/* -------------------------------------------------------------------------- */
/* Header                                                                      */
/* -------------------------------------------------------------------------- */

.header {
    flex-shrink: 0;

    height: 58px;

    border-bottom: 1px solid var(--border);

    background-color: rgba(23, 23, 23, 0.95);

    backdrop-filter: blur(12px);
}


.header-content {
    display: flex;
    align-items: center;

    width: min(
        var(--max-width),
        calc(100% - 32px)
    );

    height: 100%;

    margin: 0 auto;
}


.header-title {
    color: var(--text-primary);

    font-size: 16px;
    font-weight: 600;
}


/* -------------------------------------------------------------------------- */
/* Zone de conversation                                                        */
/* -------------------------------------------------------------------------- */

.chat-container {
    flex: 1;

    width: 100%;

    overflow-y: auto;

    scroll-behavior: smooth;
}


/* -------------------------------------------------------------------------- */
/* Scrollbar                                                                   */
/* -------------------------------------------------------------------------- */

.chat-container::-webkit-scrollbar {
    width: 8px;
}


.chat-container::-webkit-scrollbar-track {
    background: transparent;
}


.chat-container::-webkit-scrollbar-thumb {
    background-color: #3d3d3d;

    border-radius: 10px;
}


.chat-container::-webkit-scrollbar-thumb:hover {
    background-color: #505050;
}


/* -------------------------------------------------------------------------- */
/* Écran d'accueil                                                             */
/* -------------------------------------------------------------------------- */

.welcome {
    display: flex;
    flex-direction: column;
    justify-content: center;

    width: min(
        var(--max-width),
        calc(100% - 32px)
    );

    min-height: 100%;

    margin: 0 auto;

    padding: 50px 0;
}


.welcome.hidden {
    display: none;
}


.welcome h1 {
    margin: 0;

    text-align: center;

    color: var(--text-primary);

    font-size: clamp(
        28px,
        5vw,
        38px
    );

    font-weight: 600;

    line-height: 1.2;

    letter-spacing: -0.5px;
}


.welcome-description {
    max-width: 550px;

    margin:
        16px
        auto
        36px;

    text-align: center;

    color: var(--text-secondary);

    font-size: 16px;

    line-height: 1.5;
}


/* -------------------------------------------------------------------------- */
/* Suggestions                                                                 */
/* -------------------------------------------------------------------------- */

.suggestions {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 12px;

    width: 100%;
}


.suggestion {
    display: flex;
    flex-direction: column;

    gap: 6px;

    min-height: 90px;

    padding: 16px;

    text-align: left;

    background-color:
        var(--background-secondary);

    color:
        var(--text-primary);

    border:
        1px solid
        var(--border);

    border-radius: 16px;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}


.suggestion:hover {
    background-color:
        var(--background-tertiary);

    border-color:
        var(--border-hover);

    transform:
        translateY(-1px);
}


.suggestion:active {
    transform:
        translateY(0);
}


.suggestion-title {
    color:
        var(--text-primary);

    font-size: 14px;

    font-weight: 600;
}


.suggestion-description {
    color:
        var(--text-secondary);

    font-size: 13px;

    line-height: 1.4;
}


/* -------------------------------------------------------------------------- */
/* Messages                                                                    */
/* -------------------------------------------------------------------------- */

.messages {
    display: flex;
    flex-direction: column;

    width: min(
        var(--max-width),
        calc(100% - 32px)
    );

    margin: 0 auto;

    padding:
        32px
        0
        50px;
}


.message-row {
    display: flex;

    width: 100%;

    margin-bottom: 26px;
}


.message-row.user {
    justify-content: flex-end;
}


.message-row.assistant {
    justify-content: flex-start;
}


.message-row.error {
    justify-content: flex-start;
}


/* -------------------------------------------------------------------------- */
/* Bulles                                                                      */
/* -------------------------------------------------------------------------- */

.message {
    max-width: 78%;

    color:
        var(--text-primary);

    font-size: 15px;

    line-height: 1.65;

    white-space: pre-wrap;

    overflow-wrap: anywhere;
}


/* -------------------------------------------------------------------------- */
/* Message utilisateur                                                        */
/* -------------------------------------------------------------------------- */

.user .message {
    padding:
        11px
        16px;

    background-color:
        var(--user-message);

    border:
        1px solid
        #383838;

    border-radius: 20px;
}


/* -------------------------------------------------------------------------- */
/* Réponse du CV                                                               */
/* -------------------------------------------------------------------------- */

.assistant .message {
    width: 100%;

    max-width: 100%;

    padding:
        4px
        2px;

    background-color: transparent;
}


/* -------------------------------------------------------------------------- */
/* Texte en gras                                                               */
/* -------------------------------------------------------------------------- */

.assistant .message strong {
    color: #ffffff;

    font-weight: 650;
}


/* -------------------------------------------------------------------------- */
/* Liens                                                                       */
/* -------------------------------------------------------------------------- */

.message-link {
    color: #b8c7ff;

    text-decoration: underline;

    text-decoration-color:
        rgba(184, 199, 255, 0.45);

    text-underline-offset: 3px;

    overflow-wrap: anywhere;

    transition:
        color 0.15s ease,
        text-decoration-color 0.15s ease;
}


.message-link:hover {
    color: #d4ddff;

    text-decoration-color:
        #d4ddff;
}


/* -------------------------------------------------------------------------- */
/* Erreurs                                                                     */
/* -------------------------------------------------------------------------- */

.error .message {
    padding:
        12px
        16px;

    background-color:
        var(--error-background);

    color:
        var(--error-text);

    border:
        1px solid
        #613333;

    border-radius: 12px;
}


/* -------------------------------------------------------------------------- */
/* Indicateur de recherche                                                     */
/* -------------------------------------------------------------------------- */

.search-indicator {
    display: flex;
    align-items: center;

    gap: 9px;

    min-height: 32px;

    color:
        var(--text-secondary);

    font-size: 14px;

    line-height: 1.5;
}


.search-spinner {
    flex-shrink: 0;

    width: 15px;
    height: 15px;

    border:
        2px solid
        #484848;

    border-top-color:
        #d8d8d8;

    border-radius: 50%;

    animation:
        search-spin
        0.8s
        linear
        infinite;
}


.search-timer {
    flex-shrink: 0;

    color: #777777;

    font-variant-numeric:
        tabular-nums;
}


@keyframes search-spin {

    from {
        transform:
            rotate(0deg);
    }

    to {
        transform:
            rotate(360deg);
    }

}


/* -------------------------------------------------------------------------- */
/* Zone de saisie                                                              */
/* -------------------------------------------------------------------------- */

.input-area {
    flex-shrink: 0;

    width: 100%;

    padding:
        12px
        16px
        10px;

    background:
        linear-gradient(
            to top,
            var(--background) 75%,
            rgba(23, 23, 23, 0)
        );
}


.input-wrapper {
    width: min(
        var(--max-width),
        100%
    );

    margin: 0 auto;
}


/* -------------------------------------------------------------------------- */
/* Formulaire                                                                  */
/* -------------------------------------------------------------------------- */

#chat-form {
    display: flex;
    align-items: flex-end;

    gap: 10px;

    width: 100%;

    padding:
        8px
        8px
        8px
        16px;

    background-color: #262626;

    border:
        1px solid
        #3a3a3a;

    border-radius: 24px;

    box-shadow:
        0 2px 8px
        rgba(0, 0, 0, 0.25),

        0 8px 30px
        rgba(0, 0, 0, 0.18);

    transition:
        border-color 0.15s ease,
        background-color 0.15s ease;
}


#chat-form:hover {
    border-color: #444444;
}


#chat-form:focus-within {
    background-color: #292929;

    border-color: #555555;
}


/* -------------------------------------------------------------------------- */
/* Textarea                                                                    */
/* -------------------------------------------------------------------------- */

#question {
    flex: 1;

    max-height: 160px;

    padding: 8px 0;

    resize: none;

    overflow-y: auto;

    border: none;

    outline: none;

    background-color: transparent;

    color:
        var(--text-primary);

    caret-color:
        var(--text-primary);

    font: inherit;

    font-size: 16px;

    line-height: 1.5;
}


#question::placeholder {
    color: #888888;
}


#question::-webkit-scrollbar {
    width: 5px;
}


#question::-webkit-scrollbar-thumb {
    background-color: #505050;

    border-radius: 10px;
}


/* -------------------------------------------------------------------------- */
/* Bouton envoyer                                                              */
/* -------------------------------------------------------------------------- */

.send-button {
    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    width: 38px;
    height: 38px;

    padding: 0;

    background-color:
        var(--button);

    color:
        var(--button-text);

    border: none;

    border-radius: 50%;

    font-size: 22px;

    font-weight: 600;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        transform 0.15s ease,
        opacity 0.15s ease;
}


.send-button:hover:not(:disabled) {
    background-color:
        var(--button-hover);

    transform:
        scale(1.04);
}


.send-button:active:not(:disabled) {
    transform:
        scale(0.96);
}


.send-button:disabled {
    background-color:
        var(--button-disabled);

    color: #777777;

    cursor: default;

    transform: none;
}


/* -------------------------------------------------------------------------- */
/* Texte sous l'input                                                          */
/* -------------------------------------------------------------------------- */

.input-information {
    margin:
        7px
        0
        0;

    text-align: center;

    color: #777777;

    font-size: 11px;

    line-height: 1.4;
}


/* -------------------------------------------------------------------------- */
/* Sélection de texte                                                          */
/* -------------------------------------------------------------------------- */

::selection {
    background-color: #505050;

    color: #ffffff;
}


/* -------------------------------------------------------------------------- */
/* Mobile                                                                      */
/* -------------------------------------------------------------------------- */

@media (max-width: 650px) {

    .header {
        height: 52px;
    }


    .header-content {
        width:
            calc(100% - 24px);
    }


    .welcome {
        width:
            calc(100% - 24px);

        padding:
            30px
            0;
    }


    .welcome h1 {
        font-size: 27px;
    }


    .welcome-description {
        margin-bottom: 26px;

        font-size: 14px;
    }


    .suggestions {
        grid-template-columns:
            1fr;

        gap: 9px;
    }


    .suggestion {
        min-height: 72px;

        padding:
            13px
            14px;

        border-radius: 14px;
    }


    .messages {
        width:
            calc(100% - 24px);

        padding-top: 22px;
    }


    .message {
        max-width: 88%;
    }


    .assistant .message {
        max-width: 100%;
    }


    .input-area {
        padding:
            8px
            10px
            max(
                8px,
                env(safe-area-inset-bottom)
            );
    }


    #chat-form {
        padding-left: 14px;
    }


    .input-information {
        display: none;
    }


    .search-indicator {
        gap: 7px;

        font-size: 13px;
    }

}


/* -------------------------------------------------------------------------- */
/* Très petits écrans                                                          */
/* -------------------------------------------------------------------------- */

@media (max-width: 380px) {

    .welcome h1 {
        font-size: 24px;
    }


    .message {
        max-width: 92%;
    }


    .search-indicator {
        font-size: 12px;
    }

}