:root {
            /* Light Mode (Default) */
            --widget-bg-color: #FFFFFF;
            --header-gradient-start: #007BFF;
            --header-gradient-end: #00C6FF;
            --header-text-color: #FFFFFF;
            --online-indicator-color: #28A745;
            --message-area-bg: #FFFFFF;
            --assistant-bubble-bg: #F0F2F5;
            --assistant-text-color: #050505;
            --user-bubble-bg: #007BFF;
            --user-text-color: #FFFFFF;
            --quick-reply-border: #007BFF;
            --quick-reply-text: #007BFF;
            --quick-reply-bg: #FFFFFF;
            --quick-reply-bg-hover: #F0F2F5;
            --quick-reply-bg-active: #007BFF;
            --quick-reply-text-active: #FFFFFF;
            --input-placeholder-color: #6C757D;
            --input-text-color: #212529;
            --input-area-border-color: #E9ECEF;
            --send-button-gradient-start: #007BFF;
            --send-button-gradient-end: #00C6FF;
            --icon-color: #495057;
            --widget-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
            --widget-border-radius: 20px;
            --dropdown-bg: #FFFFFF;
            --dropdown-shadow: 0 4px 12px rgba(0,0,0,0.1);
            --dropdown-item-hover-bg: #F0F2F5;
            --dropdown-text-color: #212529;
            --code-bg: #e9ecef;
            --code-text: #212529;
            --link-color: #007BFF;
            --body-bg: #E9ECEF;
            --dark-mode-toggle-bg: #F0F2F5;
            --dark-mode-toggle-icon: #495057;
            --dark-mode-toggle-bg-hover: #DADDE0;
        }

        html[data-theme="dark"] {
            /* Dark Mode Overrides */
            --widget-bg-color: #1E1E1E;
            --header-gradient-start: #0056b3; /* Darker Blue */
            --header-gradient-end: #007bff;   /* Slightly Lighter Dark Blue */
            /* --header-text-color: #FFFFFF; // Stays the same */
            /* --online-indicator-color: #28A745; // Stays the same */
            --message-area-bg: #1E1E1E;
            --assistant-bubble-bg: #2C2C2E;
            --assistant-text-color: #E0E0E0;
            --user-bubble-bg: #0056b3; /* Darker blue for user bubble */
            /* --user-text-color: #FFFFFF; // Stays the same */
            --quick-reply-border: #007bff;
            --quick-reply-text: #007bff;
            --quick-reply-bg: #2C2C2E;
            --quick-reply-bg-hover: #3A3A3C;
            --quick-reply-bg-active: #007bff;
            /* --quick-reply-text-active: #FFFFFF; // Stays the same */
            --input-placeholder-color: #8E8E93;
            --input-text-color: #E0E0E0;
            --input-area-border-color: #3A3A3C;
            /* --send-button-gradient-start: #0056b3; // Can stay same or darken */
            /* --send-button-gradient-end: #007bff;   // Can stay same or darken */
            --icon-color: #AEAEB2;
            --widget-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
            /* --widget-border-radius: 20px; // Stays the same */
            --dropdown-bg: #2C2C2E;
            --dropdown-shadow: 0 4px 12px rgba(0,0,0,0.25);
            --dropdown-item-hover-bg: #3A3A3C;
            --dropdown-text-color: #E0E0E0;
            --code-bg: #2C2C2E;
            --code-text: #E0E0E0;
            --link-color: #0A84FF; /* Brighter blue for links in dark mode */
            --body-bg: #000000;
            --dark-mode-toggle-bg: #2C2C2E;
            --dark-mode-toggle-icon: #AEAEB2;
            --dark-mode-toggle-bg-hover: #3A3A3C;
        }


        @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

        html, body {
            height: 100%;
            margin: 0;
        }

        body {
            font-family: 'Roboto', Arial, sans-serif;
            background-color: var(--body-bg);
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0;
            box-sizing: border-box;
            transition: background-color 0.3s ease;
        }

        .chat-widget {
            width: 700px;
            height: 800px;
            max-height: 90vh;
            background-color: var(--widget-bg-color);
            border-radius: var(--widget-border-radius);
            box-shadow: var(--widget-shadow);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
            transition: background-color 0.3s ease, box-shadow 0.3s ease;
        }

        .widget-header {
            background: linear-gradient(135deg, var(--header-gradient-start), var(--header-gradient-end));
            color: var(--header-text-color);
            padding: 20px 25px;
            display: flex;
            flex-direction: column;
            position: relative;
            border-top-left-radius: var(--widget-border-radius);
            border-top-right-radius: var(--widget-border-radius);
            z-index: 10;
            padding-bottom: 45px;
            transition: background 0.3s ease;
        }

        .widget-header::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30px;
            background-color: var(--message-area-bg);
            border-top-left-radius: 50% 20px;
            border-top-right-radius: 50% 20px;
            transform: translateY(1px);
            transition: background-color 0.3s ease;
        }


        .header-main-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: relative;
            z-index: 1;
        }

        .header-avatar-title {
            display: flex;
            align-items: center;
        }

        .header-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: #FFF; /* Kept light for contrast */
            margin-right: 15px;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            border: 2px solid rgba(255,255,255,0.5);
        }
        .header-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .header-title {
            font-size: 1.25rem;
            font-weight: 500;
            color: var(--header-text-color); /* Explicitly set */
        }

        .header-actions {
            display: flex;
            align-items: center;
            position: relative;
        }
        .header-actions .icon-button {
            background: none;
            border: none;
            color: var(--header-text-color);
            padding: 7px;
            margin-left: 12px;
            cursor: pointer;
            opacity: 0.9;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }
        .header-actions .icon-button:hover {
            opacity: 1;
            background-color: rgba(255,255,255,0.1);
        }
        .header-actions .icon-button svg {
            width: 24px;
            height: 24px;
            fill: currentColor;
        }
        /* Dark Mode Toggle Button Specific Styles */
        #darkModeToggle {
            margin-left: 0; /* Adjust as it's the first in its group now */
            padding: 8px;
            background-color: var(--dark-mode-toggle-bg);
            border-radius: 50%;
            color: var(--dark-mode-toggle-icon);
            transition: background-color 0.2s ease, color 0.2s ease;
        }
        #darkModeToggle:hover {
            background-color: var(--dark-mode-toggle-bg-hover);
        }


        .header-status-row {
            margin-top: 10px;
            display: flex;
            align-items: center;
            font-size: 0.9rem;
            opacity: 0.9;
            position: relative;
            z-index: 1;
            color: var(--header-text-color); /* Explicitly set */
        }

        .online-indicator {
            width: 10px;
            height: 10px;
            background-color: var(--online-indicator-color);
            border-radius: 50%;
            margin-right: 8px;
            box-shadow: 0 0 6px var(--online-indicator-color);
        }

        .dropdown-menu {
            display: none;
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            background-color: var(--dropdown-bg);
            border-radius: 8px;
            box-shadow: var(--dropdown-shadow);
            padding: 8px 0;
            z-index: 100;
            min-width: 190px;
            list-style: none;
            margin: 0;
            transition: background-color 0.3s ease, box-shadow 0.3s ease;
        }
        .dropdown-menu.active { display: block; }
        .dropdown-menu li {
            padding: 10px 18px;
            font-size: 0.95rem;
            color: var(--dropdown-text-color);
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: background-color 0.2s ease, color 0.3s ease;
        }
        .dropdown-menu li:hover { background-color: var(--dropdown-item-hover-bg); }
        .dropdown-menu li .flag-icon {
            width: 22px;
            height: 22px; /* Task #2: Make height same as width for circle */
            margin-right: 12px;
            border: 1px solid #DDD; /* Keep subtle border */
            border-radius: 50%; /* Task #2: Circular flags */
            object-fit: cover; /* Ensure flag content fits well in circle */
            flex-shrink: 0;
        }


        .chat-messages-container {
            flex-grow: 1;
            background-color: var(--message-area-bg);
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 18px;
            scroll-behavior: smooth;
            position: relative;
            z-index: 1;
            transition: background-color 0.3s ease;
        }
        .chat-messages-container::-webkit-scrollbar { display: none; }
        .chat-messages-container { -ms-overflow-style: none; scrollbar-width: none; }

        .message-wrapper { display: flex; flex-direction: column; max-width: 85%; }
        .message-bubble {
            margin-top: 0;
            padding: 12px 18px;
            border-radius: 18px;
            font-size: 0.95rem;
            line-height: 1.5;
            word-wrap: break-word;
            transition: background-color 0.3s ease, color 0.3s ease;
        }
        .assistant-message { align-self: flex-start; }
        .assistant-message .message-bubble {
            background-color: var(--assistant-bubble-bg);
            color: var(--assistant-text-color);
            border-bottom-left-radius: 6px;
        }
        .user-message { align-self: flex-end; }
        .user-message .message-bubble {
            background-color: var(--user-bubble-bg);
            color: var(--user-text-color);
            border-bottom-right-radius: 6px;
        }
        .message-bubble p:last-child { margin-bottom: 0; }
        .message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 0.5em 0; }
        .message-bubble li { margin-bottom: 0.25em; }
        .message-bubble a { color: var(--link-color); text-decoration: underline; transition: color 0.3s ease; }
        .message-bubble code {
            background-color: var(--code-bg); color: var(--code-text);
            padding: 0.2em 0.4em; border-radius: 4px; font-size: 0.9em;
            font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
            transition: background-color 0.3s ease, color 0.3s ease;
        }
        .message-bubble pre {
            background-color: var(--code-bg); color: var(--code-text);
            padding: 0.8em; border-radius: 6px; overflow-x: auto; margin: 0.5em 0;
            font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
            font-size: 0.9em;
            transition: background-color 0.3s ease, color 0.3s ease;
        }
        .message-bubble pre code { background-color: transparent; padding: 0; }
        .message-bubble h1, .message-bubble h2, .message-bubble h3 { margin-top: 0.8em; margin-bottom: 0.4em; line-height: 1.3; }
        .message-animation { animation: fadeIn 0.3s ease-out; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        .widget-input-area {
            background-color: var(--widget-bg-color);
            padding: 15px 20px;
            border-top: 1px solid var(--input-area-border-color);
            display: flex;
            align-items: center;
            gap: 12px;
            position: relative;
            z-index: 5;
            border-bottom-left-radius: var(--widget-border-radius);
            border-bottom-right-radius: var(--widget-border-radius);
            transition: background-color 0.3s ease, border-top-color 0.3s ease;
        }
        .widget-input-area .icon-button { background: none; border: none; padding: 8px; cursor: pointer; color: var(--icon-color); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: color 0.3s ease; }
        .widget-input-area .icon-button:hover svg { fill: var(--send-button-gradient-start); }
        .widget-input-area .icon-button svg { width: 24px; height: 24px; fill: currentColor; transition: fill 0.2s ease-in-out; }
        .widget-input-area input[type="text"] {
            flex-grow: 1; border: none; outline: none; background-color: transparent;
            font-size: 1rem; color: var(--input-text-color); padding: 10px 0;
            font-family: 'Roboto', Arial, sans-serif;
            transition: color 0.3s ease;
        }
        .widget-input-area input[type="text"]::placeholder { color: var(--input-placeholder-color); font-weight: 400; transition: color 0.3s ease; }
        .send-button {
            width: 44px; height: 44px; border-radius: 50%;
            background: linear-gradient(135deg, var(--send-button-gradient-start), var(--send-button-gradient-end));
            color: white; border: none; cursor: pointer; display: flex; align-items: center;
            justify-content: center; flex-shrink: 0;
            box-shadow: 0 3px 8px rgba(0, 123, 255, 0.4);
            transition: transform 0.1s ease-out, box-shadow 0.1s ease-out, background 0.3s ease;
        }
        .send-button:hover { box-shadow: 0 4px 12px rgba(0, 123, 255, 0.5); }
        .send-button:active { transform: scale(0.95); box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3); }
        .send-button svg { width: 20px; height: 20px; fill: currentColor; }
        .speech-status { display: none; }

        @media (max-width: 600px) {
            body { padding: 0; align-items: flex-start; }
            .chat-widget { width: 100%; height: 100%; max-height: 100%; border-radius: 0; box-shadow: none; }
            .widget-header, .widget-input-area { border-radius: 0; }
            .widget-header::after { border-top-left-radius: 30% 20px; border-top-right-radius: 30% 20px; }
            .header-title { font-size: 1.1rem; }
            .header-avatar { width: 40px; height: 40px; margin-right: 12px;}
            .widget-header { padding: 15px 18px 40px 18px; }
            .header-actions .icon-button svg { width: 22px; height: 22px; }
            .chat-messages-container { padding: 15px; gap: 12px; }
            .message-bubble { padding: 10px 15px; font-size: 0.9rem; }
            .widget-input-area { padding: 12px 15px; gap: 10px;}
            .widget-input-area input[type="text"] { font-size: 0.95rem; }
            .widget-input-area .icon-button svg { width: 22px; height: 22px; }
            .send-button { width: 40px; height: 40px; }
            .send-button svg { width: 18px; height: 18px; }
        }
        @media (min-width: 601px) and (max-width: 900px) {
            .chat-widget { width: 450px; height: 70vh; max-height: 650px; }
            .header-title { font-size: 1.15rem; }
            .widget-header { padding-bottom: 40px; }
        }

        /* In your style.css */
.message-wrapper .typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 3px;
    background-color: var(--assistant-message-text, #333); /* Use a CSS variable */
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.4s infinite ease-in-out;
}

.message-wrapper.dark-mode .typing-dot { /* Or body.dark-mode .typing-dot */
    background-color: var(--assistant-message-text, #ccc); /* Adjust for dark mode */
}


.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.75); }
}

.mic-button.mic-active svg { /* If you want mic icon to change color when active */
    fill: var(--accent-color, #EF4444); /* Or your preferred active color */
}

.speech-status {
    font-size: 0.75rem;
    color: var(--text-secondary-color);
    text-align: center;
    padding-top: 4px; /* Adjust as needed */
    min-height: 1.2em;
    visibility: hidden; /* Initially hidden, controlled by JS */
}