/* Chat Layout - Native SVJ Light Glassmorphism */
/* Fully replaces previous styles to ensure no dark artifacts remain */

.qa-grid {
    display: flex;
    flex-direction: column;
    height: 75vh;
    width: 100%;
    /* Light/Transparent background */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

/* Main Chat Area - Verified Flexbox Fix */
.qa-chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Fill parent */
    background: transparent;
    position: relative;
    min-width: 0;
}

#chat-messages-embed {
    flex: 1;
    /* Take all available space minus controls */
    overflow-y: auto;
    /* Scroll ONLY this area */
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    /* Critical for nested flex scrolling */
}

/* Controls - Natural Flow */
.chat-controls {
    flex-shrink: 0;
    /* Don't shrink */
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    justify-content: center;
    position: relative;
    /* No more absolute */
}

/* Scrollbar styling for light theme */
#chat-messages-embed::-webkit-scrollbar {
    width: 8px;
}

#chat-messages-embed::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

#chat-messages-embed::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* Messages */
.msg-content {
    display: flex;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.msg-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.msg-content .text {
    flex: 1;
    line-height: 1.6;
    font-size: 1rem;
    columns: auto !important;
    column-count: auto !important;
    white-space: pre-wrap;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* User Message */
.msg-embed.user .msg-content {
    flex-direction: row-reverse;
}

.msg-embed.user .msg-avatar {
    background: var(--primary);
    color: white;
}

.msg-embed.user .text {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

/* AI Message */
.msg-embed.model .msg-avatar {
    background: white;
    color: var(--primary);
}

.msg-embed.model .text {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.msg-embed.model {
    background: transparent;
    padding: 0;
    margin: 0;
    border: none;
}

/* Delete Button */
.delete-msg-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 5px;
    opacity: 0;
    /* Hidden by default */
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Position based on message type */
.msg-embed.user .delete-msg-btn {
    left: -35px;
    /* Show to the left of user message */
}

.msg-embed.model .delete-msg-btn {
    right: -35px;
    /* Show to the right of AI message */
}

/* Show on hover of the message container */
.msg-content:hover .delete-msg-btn,
.delete-msg-btn:hover {
    opacity: 1;
}

.delete-msg-btn:hover {
    color: #ef4444;
    /* Red on hover */
    transform: translateY(-50%) scale(1.1);
}

/* CSS Cleanup - Controls are now handled in the main block above */

.chat-input-wrapper {
    width: 100%;
    max-width: 900px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 50px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#chat-input-embed {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    padding: 5px;
}

#chat-input-embed::placeholder {
    color: #94a3b8;
}

#chat-send-btn-embed {
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

#chat-send-btn-embed:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .qa-grid {
        height: 80vh;
    }
}