
/*Light Mode (Default) */
:root {
    --cgg-primary: #363054;
    --cgg-secondary: #252c34;
    --cgg-accent: #0488cd;
    --cgg-light-bg: #f8f7f3;
    --cgg-border: #eceae4;
    --cgg-text: #666;
    --cgg-text-dark: #333;
    --cgg-white: #fff;
    --header-height: 60px;
    --input-area-height: 200px;
    --user-message-bg: #e0f2fe;
    --assistant-message-bg: #ffffff;
}


/* Dark Mode Variables */
.dark-mode {
    --cgg-primary: #4a4268;
    --cgg-secondary: #5a5a7a;
    --cgg-accent: #4a9bd1;
    --cgg-light-bg: #2a2a2a;
    --cgg-border: #404040;
    --cgg-text: #b0b0b0;
    --cgg-text-dark: #e0e0e0;
    --cgg-white: #1a1a1a;
    --chat-bg: #2d2d2d;
    --input-bg: #3a3a3a;
    --button-hover: #404040;
    --user-message-bg: #1e3a8a;
    --assistant-message-bg: #1f2937;
}


body {
    font-family: 'Inter', sans-serif;
    color: var(--cgg-text);
    background-color: var(--cgg-white);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    min-height: 100vh;
    padding-bottom: 10px;
}

/* Desktop Layout */
.desktop-layout {
    display: block;
}

.mobile-layout {
    display: none;
}

.chat-container {
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: 20px; /* Add space at the bottom */
    /* padding-bottom: 150px; */
}

/* Chat interface*/
.chat-interface {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--cgg-white);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px); 
    max-height: none; 
}

.dark-mode .chat-interface {
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.chat-header {
    background: linear-gradient(135deg, var(--cgg-primary) 0%, var(--cgg-secondary) 100%);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.05) 50%, transparent 70%);
    pointer-events: none;
}

.chat-header h1 {
    margin: 0;
    font-weight: 600;
    font-size: 2em;
    position: relative;
}

.chat-header .description {
    font-size: 0.9em;
    opacity: 0.9;
    margin-top: 8px;
    position: relative;
    text-align: center;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 40px;
    background: var(--cgg-white);
    transition: background-color 0.3s ease;
    padding: 0;
}

/* Ensure messages expand properly */
.message {
    
    border-radius: 0.75rem;
    max-width: 90%;
    animation: fadeIn 0.3s ease-out;
    word-wrap: break-word; /* Ensure long words don't overflow */
}

.chat-messages.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    color: var(--cgg-text);
    padding: 30px;
}

/* Messages content wrapper */
.messages-content {
    padding: 20px;
}

.welcome-message {
    /*max-width: 470px;
    background: var(--cgg-light-bg); 
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);*/
    padding: 30px;
    
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    margin: 0 auto;
}

.dark-mode .welcome-message {
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.welcome-message h4 {
    color: var(--cgg-text-dark);
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.2em;
}


.welcome-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    font-size: 14px;
}

.welcome-footer label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.welcome-footer input[type="checkbox"] {
    margin-right: 8px;
}
                               

.user-message {
    background-color: var(--user-message-bg);
    align-self: flex-end;
    border-bottom-right-radius: 0.25rem;
    padding: 1rem;
}

.assistant-message {
    /*background-color: var(--assistant-message-bg); */
    align-self: flex-start;
    /*border-bottom-left-radius: 0.25rem;
    box-shadow: 0 2px 5px var(--shadow-color);*/
    font-size: 1.75rem;
    line-height: 1.875;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.references {
    font-family:'Roboto', sans-serif;
}

ul.references {
    list-style-type:none;
    padding-left:0;
}

li.references {
    font-family:'Roboto Thin', sans-serif;
    font-size:14pt;
    margin-bottom:10px;
}

li.references a {
    text-decoration:none;
}

.references-desc {
    font-size:12pt;
    line-height:1.25em;
}

/* Mobile Layout Styles */
@media (max-width: 768px) {
    .desktop-layout {
        display: none;
    }

    .mobile-layout {
        display: flex;
        flex-direction: column;
        height: 100vh;
        
    }

    body {
        height: 100vh;
        
    }

    /* Mobile header */
    .mobile-header {
        background: linear-gradient(135deg, var(--cgg-primary) 0%, var(--cgg-secondary) 100%);
        color: white;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 100;
        min-height: var(--header-height);
        flex-shrink: 0;
    }

    .mobile-header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .menu-button {
        background: none;
        border: none;
        color: white;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-title {
        font-size: 1.1em;
        font-weight: 600;
    }

    .mobile-header-actions {
        display: flex;
        gap: 8px;
    }

    /*Mobile chat area */
    .mobile-chat-wrapper {
        flex: 1;
        overflow-y: auto;
        background: var(--cgg-white);
        position: relative;
        -webkit-overflow-scrolling: touch;
        min-height: 0; 
        padding-bottom: 180px; /* Enough for expanded input + safe area */
    }

    .mobile-chat-messages {
        padding: 20px 16px;
        min-height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* Mobile welcome screen */
    .mobile-welcome-screen {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 20px;
    }

    .mobile-welcome-card {
        background: var(--cgg-light-bg);
        border-radius: 16px;
        padding: 24px;
        max-width: 380px;
        width: 100%;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .mobile-welcome-card h2 {
        color: var(--cgg-text-dark);
        font-size: 1.4em;
        margin-bottom: 12px;
        font-weight: 600;
    }

    .mobile-welcome-card p {
        color: var(--cgg-text);
        margin-bottom: 20px;
        font-size: 0.95em;
    }

    .feature-list {
        text-align: left;
        color: var(--cgg-text);
        font-size: 0.9em;
        list-style: none;
        padding: 0;
    }

    .feature-list li {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 8px;
    }

    .feature-list li::before {
        content: "âœ“";
        color: var(--cgg-accent);
        font-weight: bold;
        margin-top: 1px;
    }

    /* Mobile message styles */
    .mobile-message-group {
        margin-bottom: 24px;
        animation: fadeInUp 0.3s ease-out;
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .mobile-user-message {
        background: var(--cgg-accent);
        color: white;
        padding: 12px 16px;
        border-radius: 18px 18px 4px 18px;
        margin-left: auto;
        margin-bottom: 12px;
        max-width: 85%;
        word-wrap: break-word;
        font-size: 0.95em;
        box-shadow: 0 2px 8px rgba(4, 136, 205, 0.2);
    }

    .mobile-assistant-message {
        background: var(--cgg-light-bg);
        color: var(--cgg-text-dark);
        padding: 16px 20px;
        border-radius: 4px 18px 18px 18px;
        max-width: 95%;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        margin-bottom: 20px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Mobile message actions */
    .mobile-message-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .mobile-action-button {
        background: var(--cgg-white);
        border: 1px solid var(--cgg-border);
        color: var(--cgg-text);
        padding: 6px 12px;
        border-radius: 16px;
        font-size: 0.75em;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 4px;
        transition: all 0.2s ease;
        white-space: nowrap;
    }

    .mobile-action-button:active {
        transform: scale(0.95);
        background: var(--cgg-light-bg);
    }

    /* Mobile input area */
    .mobile-input-area {
        background: var(--cgg-white);
        border-top: 1px solid var(--cgg-border);
        padding: 8px 16px 16px; 
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        z-index: 100;
        flex-shrink: 0;
    }

    .mobile-disclaimer {
        background: var(--cgg-light-bg);
        border-radius: 8px;
        padding: 8px 12px;
        margin-bottom: 8px; 
        font-size: 0.75em;
        color: var(--cgg-text);
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .mobile-disclaimer.hidden {
        display: none;
    }

    .mobile-response-pills {
        display: flex;
        gap: 8px;
        margin-bottom: 8px; 
        justify-content: center;
    }

    .mobile-response-pill {
        background: var(--cgg-light-bg);
        border: 1px solid var(--cgg-border);
        padding: 6px 16px;
        border-radius: 20px;
        font-size: 0.8em;
        cursor: pointer;
        transition: all 0.2s ease;
        color: var(--cgg-text);
    }

    .mobile-response-pill.active {
        background: var(--cgg-accent);
        color: white;
        border-color: var(--cgg-accent);
    }

    .mobile-input-form {
        display: flex;
        gap: 8px;
        align-items: flex-end;
    }

    .mobile-message-input {
        flex: 1;
        padding: 12px 16px;
        border: 2px solid var(--cgg-border);
        border-radius: 24px;
        font-size: 1em;
        resize: none;
        min-height: 44px;
        max-height: 100px;
        font-family: inherit;
        transition: all 0.2s ease;
        background: var(--cgg-white);
        color: var(--cgg-text-dark);
    }

    .mobile-message-input:focus {
        outline: none;
        border-color: var(--cgg-accent);
    }

    .mobile-send-button {
        background: var(--cgg-accent);
        color: white;
        border: none;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .mobile-send-button:active {
        transform: scale(0.9);
    }

    .mobile-send-button:disabled {
        background: var(--cgg-border);
        cursor: not-allowed;
        transform: none;
    }

    .mobile-send-button.loading {
        background: var(--cgg-border);
        cursor: not-allowed;
    }

    .mobile-send-button.loading svg {
        animation: spin 1s linear infinite;
    }


    /* PWA-style safe area handling */
    @supports (padding: max(0px)) {
        .mobile-header {
            padding-top: max(12px, env(safe-area-inset-top));
        }

        .mobile-input-area {
            padding-bottom: max(16px, env(safe-area-inset-bottom));
        }
    }
}

/* Common styles for both layouts */
.query-display {
    background: var(--cgg-light-bg);
    border-left: 4px solid var(--cgg-accent);
    padding: 15px 20px;
    margin-bottom: 25px;
    margin-top: 30px;
    border-radius: 0 8px 8px 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.query-display .query-label {
    font-size: 0.85em;
    color: var(--cgg-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-weight: 600;
}

.query-display .query-text {
    color: var(--cgg-text-dark);
    font-size: 1.05em;
    margin: 0;
}

.response-content {
    color: var(--cgg-text-dark);
    line-height: 1.7;
    font-size: 1em;
    padding: 0 20px;
}

.response-content h3 {
    color: var(--cgg-primary);
    margin: 25px 0 15px 0;
    font-size: 1.3em;
    font-weight: 600;
}

.response-content h4 {
    color: var(--cgg-text-dark);
    margin: 20px 0 10px 0;
    font-size: 1.1em;
    font-weight: 600;
}

.response-content p {
    margin-bottom: 15px;
}

.response-content ul {
    margin: 15px 0;
    padding-left: 20px;
}

.response-content li {
    margin-bottom: 8px;
    list-style-type: disc;
}

.response-content blockquote {
    background: var(--cgg-light-bg);
    border-left: 4px solid var(--cgg-accent);
    padding: 15px 20px;
    margin: 20px 0;
    font-style: italic;
    color: var(--cgg-text);
}

.response-content .highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
}

.response-content strong {
    color: var(--cgg-text-dark);
    font-weight: 600;
}

.response-content em {
    color: var(--cgg-accent);
    font-style: italic;
}

/* Message actions */
.message-actions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--cgg-border);
    display: flex;
    gap: 10px;
    transition: opacity 0.3s ease;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.message.assistant:hover .message-actions {
    opacity: 1;
}

.action-button {
    background: var(--cgg-white);
    border: 1px solid var(--cgg-border);
    color: var(--cgg-text);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.action-button:hover {
    background: var(--cgg-light-bg);
    border-color: var(--cgg-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.dark-mode .action-button:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Download modal */
.download-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.download-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.download-modal {
    background: var(--cgg-white);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.download-modal-overlay.active .download-modal {
    transform: translateY(0);
}

.download-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--cgg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.download-modal-title {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--cgg-text-dark);
}

.download-modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--cgg-text);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.download-modal-close:hover {
    background: var(--cgg-light-bg);
}

.download-modal-content {
    padding: 16px 24px 24px;
}

.download-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid var(--cgg-border);
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--cgg-white);
}

.download-option:hover {
    border-color: var(--cgg-accent);
    background: var(--cgg-light-bg);
}

.download-option:last-child {
    margin-bottom: 0;
}

.download-option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--cgg-light-bg);
    border-radius: 12px;
    color: var(--cgg-accent);
}

.download-option:hover .download-option-icon {
    background: var(--cgg-accent);
    color: white;
}

.download-option-content {
    flex: 1;
}

.download-option-title {
    font-weight: 600;
    color: var(--cgg-text-dark);
    margin-bottom: 4px;
    font-size: 1.1em;
}

.download-option-description {
    color: var(--cgg-text);
    font-size: 0.9em;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .download-modal {
        width: 95%;
        max-width: 350px;
    }

    .download-modal-header {
        padding: 20px 20px 16px;
    }

    .download-modal-content {
        padding: 16px 20px 20px;
    }

    .download-option {
        padding: 14px;
    }

    .download-option-icon {
        width: 44px;
        height: 44px;
    }

    .download-option-title {
        font-size: 1em;
    }

    .download-option-description {
        font-size: 0.85em;
    }
}

/* Disclaimer styling */
.disclaimer {
    position: relative; /* Allow absolute positioning for button */
    background: var(--cgg-light-bg);
    border: 1px solid var(--cgg-border);
    border-radius: 8px;
    padding: 12px 16px 40px 16px;
    margin-bottom: 20px;
    margin-top: 35px;
    font-size: 0.85em;
    color: var(--cgg-text);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    transition: all 0.3s ease;
}

.disclaimer-icon {
    font-size: 14px;
    margin-top: 1px;
}

.disclaimer strong {
    color: var(--cgg-text-dark);
}

.acknowledge-btn {
    position: absolute;
    bottom: 0.5rem; /* Small margin from bottom */
    right: 0.5rem; /* Small margin from right */
    background: #2273c3;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: .5rem;
    margin-left: .5rem;
}

.acknowledge-btn:hover {
    background: #0056b3;
}

.acknowledge-btn:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.disclaimer.acknowledged {
    display: none;
}

/*Input styling for desktop */
.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--cgg-white);
    border-top: 1px solid var(--cgg-border);
    padding: 1rem;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 1200px;
    margin: 0 auto;
    transition: all 0.3s ease;   
    border-radius: 0 0 8px 8px;
    
}

.dark-mode .input-container {
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Make the input form flexible */
#message-form {
    display: flex;
    align-items: center; /* Align button with textarea baseline */
    gap: 10px; /* Space between textarea and button */
}

.textarea-wrapper {
    flex-grow: 1;
    position: relative;
}

#message-input {
    width: 100%;
    flex: 1;
    padding: 0 20px;
    border: 2px solid var(--cgg-border);
    border-radius: 25px;
    font-size: 1em;
    min-width: 0; /* Prevent flex item from overflowing */
    box-sizing: border-box;
    resize: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 52px;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--cgg-white);
    color: var(--cgg-text-dark);
}

.message-input:focus {
    outline: none;
    border-color: var(--cgg-accent);
    box-shadow: 0 0 0 3px rgba(4, 136, 205, 0.1);
}

.message-input::placeholder {
    color: var(--cgg-text);
    transition: color 0.3s ease;
}


.send-button {
    background: linear-gradient(135deg, var(--cgg-accent) 0%, #0371a8 100%);
    color: white;
    border: none;
    padding: 18px 18px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(4, 136, 205, 0.3);
    width: 52px;
    height: 52px;
    display: flex;
    box-sizing: border-box;
    margin-bottom: 4px;
}

.send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(4, 136, 205, 0.4);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.send-button.loading {
    background: #ccc;
    cursor: not-allowed;
}

.send-button.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* Response type selector */
.response-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.response-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
}

.response-option input[type="radio"] {
    accent-color: var(--cgg-accent);
}

.bottom-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.new-chat-button {
    background: var(--cgg-white);
    border: 1px solid var(--cgg-border);
    color: var(--cgg-text);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.new-chat-button:hover {
    background: var(--cgg-light-bg);
}

/* Container for response-type buttons (second row) */
.message-actions.response-type-actions {
    margin-top: 10px;
    padding-top: 0;
    border-top: none;
    justify-content: center;
    margin-bottom: 0;
}

.action-button.response-type-button {
    background: var(--cgg-white);
    border: 1px solid var(--cgg-border);
    color: var(--cgg-text);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.action-button.response-type-button strong {
    font-weight: 600;
}

.action-button.response-type-button:hover {
    background: var(--cgg-light-bg);
    border-color: var(--cgg-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Dark mode adjustments */
.dark-mode .action-button.response-type-button {
    background: var(--cgg-white);
    border: 1px solid var(--cgg-border);
}

.dark-mode .action-button.response-type-button:hover {
    background: var(--cgg-light-bg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Mobile adjustments for extra spacing */
@media (max-width: 768px) {
    .message-actions {
        margin-bottom: 25px;
    }
    
    .message-actions.response-type-actions {
        margin-bottom: 0;
    }
}

.connection-status {
    font-size: 0.8em;
    color: var(--cgg-text);
    text-align: right;
}

.connection-status.connected {
    color: #28a745;
}

.connection-status.disconnected {
    color: #dc3545;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px;
    color: var(--cgg-text);
    font-style: italic;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--cgg-text);
    border-radius: 50%;
    animation: typingPulse 1.4s ease-in-out infinite both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingPulse {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .message {
        max-width: 95%;
    }
    
    .input-container {
        padding: 0.75rem;
    }
    
    #message-input {
        padding: 0.5rem 0.75rem;
    }

    .message-input {
        font-size: 16px;
        line-height: 52px;  /* Updated: Override to match desktop for consistent centering */
    }
    
    button {
        padding: 0.5rem;
    }

    .send-button {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
        padding: 0;  /* Reset padding, let flexbox center the icon */
    }
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .button-group {
        flex-direction: row;
        align-items: center;
    }
    
    #new-chat-button {
        margin-top: 0;
        width: auto;
    }
}

/* If you want it to always be at the bottom even with little content */
@media screen and (min-height: 800px) {
    .body {
        min-height: 100vh;
    }
}

/* Ensure the input container has proper padding on the sides to match the container */
@media (min-width: 1200px) {
    .input-container {
        left: calc((100% - 1200px) / 2);
        right: calc((100% - 1200px) / 2);
    }
}

/* Collapsed state for mobile */
@media (max-width: 768px) {
    .input-container.collapsed {
        transform: translateY(calc(100% - 70px)); /* Show only the input field */
    }
    
    .input-container.collapsed .response-type-selector,
    .input-container.collapsed .connection-status {
        opacity: 0;
        pointer-events: none;
    }
    
    /* Ensure the input is always accessible */
    .input-container.collapsed #message-form {
        opacity: 1;
    }
    
    /* Add a subtle indicator that more is available */
    .input-container.collapsed::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 4px;
        background-color: var(--border-color);
        border-radius: 2px;
        opacity: 0.7;
    }
}

/* Ensure desktop view is not affected */
@media (min-width: 769px) {
    .input-container.collapsed {
        transform: none;
    }
    
    .input-container.collapsed .response-type-selector,
    .input-container.collapsed .connection-status {
        opacity: 1;
        pointer-events: auto;
    }
}

@media screen and (min-height: 800px) {
  .body {
    min-height: 100vh;
  }
}

@media (max-width: 768px) {
    .input-container {
        bottom: 0;
        left: 0;
        width: 100vw;                  /* Full viewport width */
        max-width: none;               /* Remove max-width restriction */
        padding: 12px 16px;            /* Generous horizontal padding for comfort */
        box-sizing: border-box;
        background: var(--cgg-white);
        border-top: 1px solid var(--cgg-border);
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
        z-index: 1000;
        display: flex;
        flex-direction: column;
        gap: 12px;                      /* Vertical spacing between sections */
        /* Safe area handling for modern devices (iPhone X+, Android notches/home indicator) */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        bottom: env(safe-area-inset-bottom, 0);
    }

    /* Form row: textarea + send button */
    #message-form {
        display: flex;
        align-items: end;              /* Align send button to bottom of growing textarea */
        gap: 12px;
    }

    .textarea-wrapper {
        flex: 1;
    }

    #message-input {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;               /* Prevents iOS zoom on focus */
        min-height: 48px;
        max-height: 120px;
    }

    .chat-container {
        padding-bottom: 180px; /* Enough for expanded input + safe area */
    }

    .send-button {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    /* Response type selector – centered and compact */
    .response-type-selector {
        text-align: center;
    }

    .response-options {
        justify-content: center;
        gap: 24px;
        font-size: 0.9em;
    }

    /* Bottom actions – spaced evenly */
    .bottom-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.85em;
    }

    .new-chat-button {
        padding: 8px 14px;
        font-size: 0.9em;
    }

    #connection-status {
        color: #28a745; /* Green when connected */
    }
}