/* Chat Interface Styles
=========================================================
This file contains styles specific to the chat interface of 
MagicPrompt, including message bubbles, input area, and 
chat-specific animations.

TABLE OF CONTENTS:
1. Chat Section Layout
2. Messages Area
3. Input Area
4. Message Bubbles
5. Message Actions
6. Loading States
=========================================================== */

/* 1. CHAT SECTION LAYOUT 
   Main container and structure for chat interface */

.magicprompt #chat_section {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden;
}

/* Section content wrapper - Contains messages and input area */
.magicprompt .section-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
}

/* 2. MESSAGES AREA 
   Scrollable container for chat messages */

.magicprompt #chat_messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    position: absolute;
    top: 40px; /* Below header */
    bottom: 160px; /* Above input area */
    left: 0;
    right: 0;
    background: var(--background);
    min-height: 0; /* Firefox fix */
}

/* Individual chat message container */
.magicprompt .chat-message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
    padding: 0 1rem;
}

/* User message alignment (right side) */
.magicprompt .user-message {
    flex-direction: row-reverse;
    margin-right: 18%;
}

/* 3. INPUT AREA 
   Bottom section with text input and controls */

/* Input container - Fixed at bottom */
.magicprompt .chat-input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background);
    padding: 1rem;
}

/* Input wrapper - Contains textarea and submit button */
.magicprompt .chat-input-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 1rem;
    background: var(--background);
}

/* Chat textarea styling */
.magicprompt #chat_llm_textarea {
    flex: 1;
    height: 60px;
    resize: none;
    background: var(--background-gray);
    color: var(--text);
    border: 1px solid var(--shadow);
    border-radius: 4px;
    padding: 8px;
    margin: 0;
}

/* Submit button */
.magicprompt #submit_button {
    height: 60px;
    width: 60px;
    border-radius: 4px;
    background: var(--emphasis);
    color: var(--text);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 8px;
}

    .magicprompt #submit_button:hover {
        opacity: 0.9;
        transform: scale(1.02);
    }

    .magicprompt #submit_button:active {
        transform: scale(0.98);
    }

/* 4. MESSAGE BUBBLES 
   Individual message styling and content */

/* Message content bubble */
.magicprompt .message-content {
    background-color: var(--background-gray);
    padding: 16px;
    border-radius: 4px;
    max-width: calc(100% - 80px);
    min-width: 50px;
    width: fit-content;
    flex-grow: 0;
    word-wrap: break-word;
    color: var(--text);
}

/* User message specific styling */
.magicprompt .user-message .message-content {
    background-color: var(--background-soft);
}

/* Avatar styling */
.magicprompt .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--emphasis);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 12px;
    flex-shrink: 0;
    font-weight: 500;
    color: var(--button-foreground-hover);
}

/* 5. MESSAGE ACTIONS 
   Buttons and controls for individual messages */

.magicprompt .message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
    opacity: 0.7;
}

    .magicprompt .message-actions:hover {
        opacity: 1;
    }

/* Action buttons */
.magicprompt .action-button {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text);
    position: relative;
}

    .magicprompt .action-button:hover {
        background: var(--button-background-hover);
    }

    /* Action button tooltips */
    .magicprompt .action-button[data-tooltip]:hover::before {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        padding: 4px 8px;
        background: var(--background-gray);
        color: var(--text);
        border-radius: 4px;
        font-size: 12px;
        white-space: nowrap;
        margin-bottom: 4px;
        border: 1px solid var(--shadow);
    }

/* 6. LOADING STATES 
   Loading indicators and animations */

/* Loading indicator container */
.magicprompt #loading_indicator {
    display: none;
    position: absolute;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: var(--background);
    border-radius: 4px;
    z-index: 10;
}

    .magicprompt #loading_indicator.active {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }

    /* Loading animation dots */
    .magicprompt #loading_indicator .dot {
        width: 8px;
        height: 8px;
        background: var(--emphasis);
        border-radius: 50%;
        animation: pulse 1.4s infinite ease-in-out;
        display: inline-block;
    }

        /* Dot animation delays for wave effect */
        .magicprompt #loading_indicator .dot:nth-child(1) {
            animation-delay: 0s;
        }

        .magicprompt #loading_indicator .dot:nth-child(2) {
            animation-delay: 0.2s;
        }

        .magicprompt #loading_indicator .dot:nth-child(3) {
            animation-delay: 0.4s;
        }

/* Loading animation keyframes */
@keyframes pulse {
    0% {
        transform: scale(0.3);
        opacity: 0.3;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.3);
        opacity: 0.3;
    }
}
