﻿/*
    www.ChatBot-V4.0.css
    ====================
    Shared styles for ChatBot controls.
    Includes layout, bubbles, input controls, animations, and effects.
*/

/*----------------------------------------------
    Chat Container & Layout
----------------------------------------------*/

.chat-history {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    background-color: #f8f9fa;
    padding: 0.5rem 1rem;
}

    .chat-history p {
        margin-bottom: 0; /* Removes spacing between paragraphs */
    }

.chat-scroll {
    min-height: 300px;
    max-height: 300px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-right: 0.5rem;
}

#chatbot_window.expanded .chat-history {
    min-height: 680px;
    max-height: 680px;
}
/* leave some gutter at the bottom when expanded */
#chatbot_window.expanded .chat-scroll {
    min-height: 670px;
    max-height: 670px;
}

.chat-input-wrapper {
    position: relative;
}

.chat-btn-clear {
    position: absolute;
    right: 6px;
    top: 6px;
    z-index: 10;
}


/*----------------------------------------------
    Chat Bubbles
----------------------------------------------*/

.chat-bubble {
    display: block;
    width: fit-content;
    max-width: 85%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 1.25rem;
    word-wrap: break-word;
    line-height: 1.4;
    clear: both;
}

    /* User bubble (green, aligned right) */
    .chat-bubble.user {
        margin-top: 20px;
        background-color: #d1e7dd;
        color: #0f5132;
        margin-left: auto;
        text-align: left;
        border-bottom-right-radius: 0;
        float: left;
    }

    .chat-bubble.assistant {
        background-color: #dbeeff;
        color: #000;
        display: block; /* starts on a new line */
        width: fit-content; /* allows dynamic width */
        max-width: 100%; /* don’t overflow container */
        min-width: 10%; /* OPTIONAL: ensures it doesn’t look tiny for short messages */
        margin-top: 0.75rem;
        padding: 0.75rem 1rem;
        border-radius: 1.25rem;
        border-bottom-left-radius: 0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        transition: background-color 0.3s ease;
        white-space: normal;
        clear: both;
        float: left;
    }


.chat-history, .chat-scroll {
    display: block;
}

/*----------------------------------------------
    Send Button (Fade In)
----------------------------------------------*/

.chat-btn-send {
    transition: opacity 0.5s ease;
    opacity: 0;
    display: none;
    position: absolute;
    right: 20px;
    top: 12px;
    color: #007bff;
    background: none;
    border: none;
    font-size: 1.25rem;
    z-index: 10;
}

    .chat-btn-send.show {
        display: inline;
        opacity: 1;
    }

/*----------------------------------------------
    ClearChat Button (Fade In)
----------------------------------------------*/

#btnClearChat {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none; /* disables click when invisible */
}

    #btnClearChat.visible {
        opacity: 1;
        pointer-events: auto; /* enable click when visible */
    }

/*----------------------------------------------
    Thinking Indicator (Blinking Icon)
----------------------------------------------*/

.bot-thinking {
    font-style: italic;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

    .bot-thinking .bi {
        font-size: 1.2rem;
        animation: blink 1.2s infinite steps(1);
    }

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}


/*----------------------------------------------
    Typewriter Effect
----------------------------------------------*/

.typewriter-placeholder {
    white-space: pre-wrap;
}

    .typewriter-placeholder::after {
        content: '|';
        animation: blink-caret 1s step-end infinite;
        margin-left: 2px;
        color: #999;
    }

@keyframes blink-caret {
    from, to {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}


/*----------------------------------------------
    Fade-In Animation (Applied to Last Message)
----------------------------------------------*/

@keyframes bubble-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bubble-fade-in {
    animation: bubble-fade-in 0.4s ease;
}

/* SQL snippet */
.sql-snippet {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 10px;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
    margin-bottom: 10px;
}

#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 1000;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

    #chatbot-toggle:hover {
        transform: scale(1.1);
    }

#chatbot_window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
    transition: width 0.4s ease, height 0.4s ease, transform 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

    #chatbot_window.open {
        transform: scale(1);
    }

    #chatbot_window.expanded {
        width: 90vw;
        height: 80vh;
        bottom: 10vh;
        right: 5vw;
        transition: all 0.3s ease;
    }

#chatbot-header {
    background: #0078d7;
    color: white;
    padding: 10px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chatClose {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
}

#chatbot_body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/*----------------------------------------------
    Copy to Clipboard
----------------------------------------------*/

/* icons */
.chat-icon:hover {cursor: pointer;}

.chat-tooltip-clip {
    position: relative;
    display: inline-block;
}

    .chat-tooltip-clip .tooltiptext {
        visibility: hidden;
        width: 100px;
        background-color: #555;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 5px;
        position: absolute;
        z-index: 9999;
        top: 150%; /* ⬅️ place tooltip below icon */
        left: 50%;
        margin-left: -45px;
        opacity: 0;
        font-size: var(--font-size-smallest);
        transition: opacity 0.3s;
    }

        .chat-tooltip-clip .tooltiptext::after {
            content: "";
            position: absolute;
            bottom: 100%; /* ⬅️ place arrow at top of tooltip */
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: transparent transparent #555 transparent; /* ⬅️ arrow points up */
        }


    .chat-tooltip-clip:hover .tooltiptext {
        visibility: visible;
        opacity: 1;
    }

/* Adjust positioning when displayed content a line with small text  */
.clipboard-xs {
    position: relative;
    top: 3px;
    right: -30px;
}

/* Adjust font size for custom class applied to bootstrap tooltips */
.tooltip-small-font .tooltip-inner {
    font-size: var(--font-size-smallest);
}

#chatScrollContainer {
    scroll-behavior: smooth;
}
