/*
 * General Styles
 */
#fina-chatbot-container {
    /* Fixed position to make it float */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;

    /* Appearance */
    width: 320px;
    height: 450px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    transition: all 0.3s ease-in-out;
    overflow: hidden; /* Ensures content doesn't spill out */
}

/*
 * Full Header Styles
 */
#fina-chatbot-header {
    background-color: #1c3d29; /* Dark green from the palette */
    color: #ffffff;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none; /* Prevents text selection on header */
    gap: 8px;
}

#fina-chatbot-container.minimized {
    width: auto; /* Allow width to be determined by content */
    height: auto;
    background-color: #f0f2f5; /* Lighter background for the pill shape */
    border-radius: 50px; /* Pill shape */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#fina-chatbot-container.minimized #fina-chatbot-body,
#fina-chatbot-container.minimized #fina-chatbot-form {
    display: none;
}

#fina-chatbot-container.minimized #fina-chatbot-header {
    background-color: transparent;
    color: #08110b; /* Dark text */
    padding: 0; /* Remove padding */
    justify-content: flex-start;
    gap: 10px;
}

.chatbot-logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/*
 * Chat Body (The message area)
 */
#fina-chatbot-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    border-bottom: 1px solid #f0f0f0;
    background-color: #d3ddd3; /* Light gray/green from the palette */
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar for a cleaner look */
#fina-chatbot-body::-webkit-scrollbar {
    width: 8px;
}
#fina-chatbot-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}
#fina-chatbot-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}
#fina-chatbot-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/*
 * Message Styles
 */
.fina-message {
    padding: 10px 15px;
    border-radius: 20px;
    margin-bottom: 10px;
    line-height: 1.5;
    word-wrap: break-word; /* Prevents long words from breaking layout */
    max-width: 80%; /* Limits message width */
    font-size: 14px;
}

.user-message {
    background-color: #5c955e; /* Green from the palette */
    color: #ffffff;
    align-self: flex-end; /* Pushes the message to the right */
    border-bottom-right-radius: 4px;
}

.model-message {
    background-color: #ffffff; /* White background for model messages */
    color: #08110b; /* Very dark green/black for the text */
    align-self: flex-start; /* Pushes the message to the left */
    border-bottom-left-radius: 4px;
}

.loading-message {
    background-color: #d3ddd3;
    font-style: italic;
    color: #08110b;
    animation: pulse 1.5s infinite ease-in-out;
}

/* Optional: Loading animation for the "Thinking..." message */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/*
 * Chat Form
 */
#fina-chatbot-form {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

#fina-chatbot-input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #cccccc;
    border-radius: 25px; /* Rounded input field */
    font-size: 14px;
    transition: border-color 0.2s;
}

#fina-chatbot-input:focus {
    outline: none;
    border-color: #2a6142; /* Medium green from the palette */
}

#fina-chatbot-form button {
    padding: 12px 18px;
    margin-left: 10px;
    background-color: #2a6142; /* Medium green from the palette */
    color: #ffffff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s;
}

#fina-chatbot-form button:hover {
    background-color: #1c3d29; /* Dark green on hover */
}

/*
 * Markdown Formatting
 */
.model-message h1,
.model-message h2,
.model-message h3,
.model-message h4,
.model-message h5,
.model-message h6 {
    margin-top: 15px;
    margin-bottom: 8px;
    font-weight: bold;
}

.model-message h1 { font-size: 1.5em; }
.model-message h2 { font-size: 1.4em; }
.model-message h3 { font-size: 1.3em; }
.model-message h4 { font-size: 1.2em; }
.model-message h5 { font-size: 1.1em; }
.model-message h6 { font-size: 1em; }

.model-message p {
    margin-bottom: 10px;
}

.model-message strong,
.model-message b {
    font-weight: bold;
}

.model-message em,
.model-message i {
    font-style: italic;
}

.model-message ul,
.model-message ol {
    margin: 0 0 10px 20px;
    padding: 0;
}

.model-message li {
    margin-bottom: 5px;
}

.model-message a {
    color: #2a6142; /* A link color that fits the theme */
    text-decoration: none;
    border-bottom: 1px solid #2a6142;
}

.model-message a:hover {
    color: #1c3d29;
    border-bottom-color: #1c3d29;
}