/* --- AI Chat Styles --- */

/* Floating Chat Button */
#ai-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff; /* Example color - match your theme */
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 24px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

#ai-chat-button:hover {
    background-color: #0056b3; /* Darker shade on hover */
}

/* Chat Window */
#ai-chat-window {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 90px; /* Adjusted position */
    right: 30px; /* Adjusted position */
    width: 50%; /* Increased width */
    max-height: 80vh; /* Limit height to 80% of viewport */
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000; /* Ensure it's above other content when open */
    flex-direction: column;
}

/* Style for the resize handle (now an inline icon) */
#ai-chat-resize-handle {
    cursor: nwse-resize; /* Keep cursor indicating diagonal resize */
    z-index: 1001; /* Ensure handle is clickable above header elements if overlapping */
    color: #6c757d; /* Adjust icon color */
    line-height: 1; /* Align SVG better vertically if needed */
}

#ai-chat-resize-handle:hover {
    color: #343a40; /* Darken icon on hover */
}

#ai-chat-window.show {
    display: flex; /* Override display: none to show */
}

/* Chat Header */
#ai-chat-header {
    background-color: #e9ecef; /* Slightly darker header */
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#ai-chat-close-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
}

#ai-chat-reset-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    margin-left: auto;
    margin-right: 5px;
}

/* Message Area */
#ai-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px; /* Slightly increased padding */
    border-bottom: 1px solid #eee;
    min-height: 200px; /* Increased minimum height */
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

/* -- Chat Messages Styling -- */
.ai-chat-message {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    max-width: 85%; /* Limit width for better readability */
}

.ai-chat-message.user {
    background-color: #e3f2fd; /* Light blue for user */
    color: #0d47a1;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.ai-chat-message.ai {
    background-color: #f6f8fc; /* Light grey for AI */
    color: #202124;
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 2px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    padding: 14px 18px;
}

.ai-chat-message.ai ul {
    padding-left: 20px;
    margin: 8px 0 12px 0;
}

.ai-chat-message.ai li {
    margin-bottom: 8px;
    padding-left: 5px;
}

.ai-chat-message.ai strong {
    color: #1a73e8;
    font-weight: 600;
}

.ai-chat-message.ai p {
    margin-bottom: 12px;
}

.ai-chat-message.ai > p:first-child {
    margin-top: 0;
}

.ai-chat-message.error {
    background-color: #f8d7da; /* Error message background */
    color: #721c24; /* Error message text */
    border: 1px solid #f5c6cb;
    align-self: center;
    max-width: 90%;
    text-align: center;
}

/* Styling for bond comparison specific elements */
.ai-chat-message.ai .bond-comparison-intro {
    background-color: #e8f0fe;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 3px solid #4285f4;
}

.ai-chat-message.ai .bond-category {
    margin-bottom: 16px;
}

.ai-chat-message.ai .bond-category h4 {
    color: #202124;
    font-size: 15px;
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #dadce0;
}

.ai-chat-message.ai .bond-summary {
    background-color: #f8f9fa;
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 16px;
    border-left: 3px solid #34a853;
    font-style: italic;
}

/* Input Area */
#ai-chat-input-area {
    border-top: 1px solid #dee2e6;
    padding: 10px;
    display: flex;
    background-color: #f8f9fa;
}

#ai-chat-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 20px; /* Rounded input */
    margin-right: 10px;
    resize: none; /* Prevent manual resizing */
    height: 40px; /* Adjust as needed */
    line-height: 1.5;
}

#ai-chat-send-button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-chat-send-button:hover {
    background-color: #0056b3;
}

/* Loading indicator (optional) */
.ai-chat-message.loading {
    font-style: italic;
    color: #6c757d;
    align-self: flex-start;
    background-color: #f1f0f0;
}
