/* Importation de la police Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Default Light Mode Variables (White background) */
:root {
    --bg-main: #ffffff;
    --bg-panel: #f3f4f6;
    --bg-input: #ffffff; /* Rendu blanc */
    --text-main: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    --accent-color: #8b5cf6;
    --accent-color-dark: #a78bfa; /* Swapped for better contrast */
}

/* Dark Mode Variables modifié pour blanc/noir */
body.dark-mode {
    --bg-main: #ffffff;        /* fond principal blanc */
    --bg-panel: #f0f0f0;       /* fond des panneaux clair */
    --bg-input: #ffffff;       /* champs de formulaire blanc */
    --text-main: #000000;      /* texte principal noir */
    --text-secondary: #4b4b4b; /* texte secondaire gris foncé */
    --border-color: #cccccc;    /* bordures gris clair */
    --accent-color: #1e40af;    /* accent bleu */
    --accent-color-dark: #1d4ed8; /* accent bleu foncé */
}

body {
    font-family: 'Inter', sans-serif; background-color: var(--bg-main);
    color: var(--text-main); -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale; overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInPop { 0% { opacity: 0; transform: translateY(20px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fadeOutDown { from { opacity: 1; } to { opacity: 0; transform: translateY(20px); } }
@keyframes slideInFromRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
/* New: Animation for AI response appearance */
@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* New: Pulsation for thinking indicator */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}
/* New: Premium badge animation */
@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}
/* New: Google login loading animation */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
/* New: Premium offer button animation */
@keyframes neonPulse {
    0% { box-shadow: 0 0 5px var(--accent-color), 0 0 10px var(--accent-color-dark); }
    50% { box-shadow: 0 0 10px var(--accent-color-dark), 0 0 20px var(--accent-color); }
    100% { box-shadow: 0 0 5px var(--accent-color), 0 0 10px var(--accent-color-dark); }
}
/* New: CRT Logo Spinner */
@keyframes rotateCrtLogo {
    from { transform: rotate(0deg); }
    to { transform: 360deg; }
}


/* --- Scrollbar --- */
.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--bg-main); }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* --- Chat Bubbles & Cards --- */
.chat-bubble-user {
    max-width: 80%; padding: 0.9rem 1.2rem; border-radius: 1.25rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); position: relative;
    animation: slideInPop 0.4s ease-out forwards; background-color: var(--accent-color-dark);
    color: white; margin-left: auto; border-bottom-right-radius: 0.5rem;
}

/* Adjusted for "aerated" text response */
.ai-response-card {
    background-color: transparent; /* Make background transparent */
    border: none; /* Remove border */
    border-radius: 0; /* Remove border-radius */
    padding: 0 1.5rem; /* Only horizontal padding */
    margin-bottom: 1.5rem; /* Increased spacing between responses */
    box-shadow: none; /* Remove shadow */
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInSlide 0.4s ease forwards;
    color: var(--text-main);
    width: 100%;
    position: relative;
}
.ai-response-card h1, .ai-response-card h2, .ai-response-card h3 {
    font-weight: 700; color: var(--accent-color); margin-top: 1.5em; margin-bottom: 0.75em; padding-bottom: 0.25em; border-bottom: 1px solid var(--border-color);
}
.ai-response-card p {
    line-height: 1.8; /* More aerated line height */
    margin-bottom: 1.2em; /* More space between paragraphs */
}
.ai-response-card ul, .ai-response-card ol {
    margin-left: 1.8rem; /* Increased indent */
    margin-bottom: 1.2em;
}
.ai-response-card li { margin-bottom: 0.5em; padding-left: 0.5em; }
.ai-response-card strong { font-weight: 600; color: var(--text-main); }
.ai-response-card a { color: #93c5fd; text-decoration: underline; transition: color 0.2s; }
.ai-response-card a:hover { color: #60a5fa; }
.ai-response-card pre { position: relative; background-color: var(--bg-main); padding: 1.2rem; border-radius: 0.5rem; overflow-x: auto; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.9rem; line-height: 1.6; color: var(--text-secondary); border: 1px solid var(--border-color); margin-bottom: 1em; }
.ai-response-card code:not(pre > code) { background-color: var(--border-color); padding: 0.2em 0.4em; margin: 0; font-size: 85%; border-radius: 3px; }
.copy-code-btn { position: absolute; top: 0.5rem; right: 0.5rem; background-color: #4b5563; color: white; border: none; border-radius: 0.375rem; padding: 0.25rem 0.5rem; cursor: pointer; opacity: 0; transition: opacity 0.2s; display: flex; align-items: center; gap: 0.25rem; }
.ai-response-card pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn .copy-feedback { font-size: 0.75rem; }

/* New: Copy response button - Adjusted for aerated text */
.copy-response-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: var(--bg-main); /* Match main background */
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Add a subtle shadow */
}
.ai-response-card:hover .copy-response-btn {
    opacity: 1;
}
.copy-response-btn:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

/* New: Read response button - Adjusted for aerated text */
.read-response-btn {
    position: absolute;
    top: 0.75rem;
    right: 6rem; /* Adjusted to make space for copy button */
    background-color: var(--bg-main); /* Match main background */
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Add a subtle shadow */
}
.ai-response-card:hover .read-response-btn {
    opacity: 1;
}
.read-response-btn:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}
.read-response-btn.active {
    background-color: var(--accent-color);
    color: white;
}

/* New: Thin separator line for AI responses */
.ai-response-card hr.thin-separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0; /* Adjust spacing as needed */
    opacity: 0.7;
}


.thinking-indicator-card {
    display: flex;
    align-items: center;
    justify-content: center; /* Center the logo */
    padding: 1.5rem;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    margin-bottom: 1.2rem;
    animation: fadeIn 0.3s ease-out; /* Removed pulse from here */
    color: var(--text-secondary);
    min-height: 60px; /* Ensure enough space for the logo */
}

/* Hide the generic spinner and text */
.thinking-indicator-card .spinner { display: none; }
.thinking-indicator-card span { display: none; }

/* Style for the CRT logo inside the thinking indicator */
.crt-logo-spinner {
    width: 40px; /* Adjust size as needed */
    height: 40px;
    animation: rotateCrtLogo 1.5s linear infinite; /* Apply rotation */
    color: var(--accent-color); /* Use accent color for the logo */
}
.crt-logo-spinner path {
    stroke: currentColor; /* Ensure paths inherit color */
}
.crt-logo-spinner circle {
    fill: currentColor; /* Ensure circle inherits color */
}


/* New: Voice Status Indicator */
.voice-status-indicator {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 1rem;
    background-color: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: 0.75rem; margin-top: 1rem;
    animation: fadeIn 0.3s ease-out;
    justify-content: center;
    color: var(--accent-color);
    font-weight: 500;
}
.voice-status-indicator .waveform {
    width: 20px; height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 8h4M8 4h4M14 8h4M20 4h2M2 16h4M8 20h4M14 16h4M20 20h2'/%3E%3Csvg%3E");
    background-size: contain;
    animation: pulse 1s infinite alternate;
}
.voice-status-indicator button {
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    margin-left: 0.5rem;
}
.voice-status-indicator button:hover {
    color: var(--text-main);
}


/* --- Panels & UI Elements --- */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100%;
    background-color: var(--bg-panel);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 900;
    display: flex;
    flex-direction: column;
}
.side-panel.open { transform: translateX(0); }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); }
.panel-header h3 { font-size: 1.25rem; font-weight: bold; color: var(--accent-color); }
.panel-content { flex-grow: 1; overflow-y: auto; padding: 1.5rem; }
.panel-close-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; transition: color 0.2s, transform 0.2s; }
.panel-close-btn:hover { color: white; transform: rotate(90deg); }

.styled-button { transition: all 0.2s ease-in-out; border-radius: 0.75rem; font-weight: 600; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.styled-button:hover { transform: translateY(-2px); box-shadow: 0 7px 10px rgba(0, 0, 0, 0.15); }
.styled-button.purple-gradient { background-image: linear-gradient(to right, var(--accent-color-dark), #d946ef); color: white; }
.styled-button.red-accent { background-color: var(--error-color); color: white; }
.styled-button.yellow-accent { background-color: var(--warning-color); color: white; }

.styled-select, .styled-input { padding: 0.6rem 1rem; border-radius: 0.75rem; border: 1px solid var(--border-color); background-color: var(--bg-input); color: var(--text-main); }
.styled-select:focus, .styled-input:focus, #user-input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.4); }
.styled-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3Csvg%3E"); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.2em; }

.theme-option.selected { border: 2px solid var(--accent-color); }
.toggle-checkbox { height: 0; width: 0; visibility: hidden; }
.toggle-label { cursor: pointer; text-indent: -9999px; width: 50px; height: 28px; background: grey; display: block; border-radius: 100px; position: relative; }
.toggle-label:after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; background: #fff; border-radius: 90px; transition: 0.3s; }
.toggle-checkbox:checked + .toggle-label { background: var(--accent-color); }
.toggle-checkbox:checked + .toggle-label:after { left: calc(100% - 2px); transform: translateX(-100%); }

/* New: Welcome Message Card */
#welcome-message-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 100;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.5s ease-out;
}
#welcome-message-card h2 {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 1rem;
}
#welcome-message-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
#welcome-message-card button {
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
}

/* Responsive language selector */
#lang-selector-desktop {
    display: block;
}
#lang-selector-mobile {
    display: none;
}

/* New: Quick Tools Modal */
.quick-tools-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.quick-tools-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.quick-tools-modal-content {
    background-color: var(--bg-panel);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    width: 90%;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}
.quick-tools-modal-overlay.open .quick-tools-modal-content {
    transform: translateY(0);
    opacity: 1;
}
.quick-tool-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--bg-input);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    text-align: left;
    transition: background-color 0.2s, border-color 0.2s;
    cursor: pointer;
}
.quick-tool-button:hover {
    background-color: var(--border-color);
    border-color: var(--accent-color);
}
.quick-tool-button h4 {
    font-weight: 600;
    color: var(--text-main);
}
.quick-tool-button p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* CRT+ Banner */
#premium-banner {
    background-image: linear-gradient(to right, #8b5cf6, #d946ef);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: none; /* Hidden by default, shown for premium users */
    animation: fadeIn 0.5s ease-out;
}

/* Upgrade Modal */
#upgrade-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#upgrade-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
#upgrade-modal-content {
    background-color: var(--bg-panel);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    max-width: 550px;
    width: 90%;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}
#upgrade-modal-overlay.open #upgrade-modal-content {
    transform: translateY(0);
    opacity: 1;
}
#upgrade-modal-content h3 {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}
#upgrade-modal-content .price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1rem;
}
#upgrade-modal-content .features-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    display: inline-block; /* To center the list */
    font-size: 1rem;
    color: var(--text-secondary);
}
#upgrade-modal-content .features-list li {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#upgrade-modal-content .features-list li i {
    color: var(--success-color);
}
#upgrade-modal-content button.subscribe-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    margin-top: 1.5rem;
}
#upgrade-modal-content button.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 1rem;
}
#upgrade-modal-content button.close-btn:hover {
    color: var(--text-main);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #lang-selector-desktop {
        display: none;
    }
    #lang-selector-mobile {
        display: none; /* Hidden as per new design */
    }
    .side-panel {
        width: 100vw;
        max-width: 100vw; /* Full width on mobile */
    }
    .read-response-btn {
        right: 5rem; /* Adjust for smaller screens */
    }
    /* Removed flex-wrap.gap-2.mt-4.justify-center styles as this section is refactored */
    .chat-bubble-user, .ai-response-card {
        padding: 0 1rem; /* Adjust horizontal padding for chat content */
    }
    .ai-response-card p {
        line-height: 1.6; /* Slightly less aerated for mobile density */
    }
    /* Removed #user-input, #dictation-btn, #send-btn min-height/width as they are now integrated */
    .panel-content {
        padding: 1rem; /* Adjust panel padding for mobile */
    }
    .panel-header {
        padding: 0.75rem 1rem; /* Adjust panel header padding */
    }
    #welcome-message-card {
        padding: 1.5rem;
    }
    #welcome-message-card h2 {
        font-size: 1.5rem;
    }
    #welcome-message-card button {
        padding: 0.7rem 1.2rem;
        font-size: 1rem;
    }
    .quick-tool-button {
        padding: 0.8rem; /* Adjust quick tool button padding */
    }
    .quick-tool-button h4 {
        font-size: 0.95rem;
    }
    .quick-tool-button p {
        font-size: 0.75rem;
    }

    /* Mobile specific layout for main content */
    #main-content {
        flex-direction: column; /* Stack chat and canva vertically */
    }
    #discussions-sidebar {
        position: fixed; /* Make sidebar fixed on mobile */
        left: 0;
        top: 0;
        width: 100vw;
        height: 100%;
        transform: translateX(-100%); /* Hide by default */
        transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
        z-index: 950; /* Above chat, below panels */
    }
    #discussions-sidebar.open {
        transform: translateX(0);
    }
    #chat-area {
        width: 100%; /* Full width for chat */
    }
    #canva-area {
        width: 100%; /* Full width for canva */
        height: 100vh; /* Full height for canva on mobile */
        position: fixed; /* Fixed position for canva on mobile */
        top: 0;
        left: 0;
        z-index: 960; /* Above sidebar */
    }
    /* Show a button to open sidebar on mobile */
    #sidebar-toggle-btn {
        display: block;
    }
}

/* Styling for legal sections and footer */
.legal-footer {
    padding: 2em;
    background-color: var(--bg-panel);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.legal-footer a {
    margin-right: 1em;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.legal-footer a:hover {
    color: var(--text-main);
    text-decoration: underline;
}

/* Payment security text styling */
.payment-security-text {
    font-size: 0.9rem;
    color: var(--text-secondary); /* Use CSS variable for dark/light mode */
    margin-top: 0.5em;
    line-height: 1.4;
}
.payment-security-text a {
    text-decoration: underline;
    color: var(--accent-color); /* Use accent color for links */
}

/* Toast close button - Updated for absolute positioning */
.toast-close-btn {
    position: absolute;
    top: 0.25rem; /* Adjust as needed */
    right: 0.25rem; /* Adjust as needed */
    background: none;
    border: none;
    color: inherit; /* Inherit color from parent toast */
    cursor: pointer;
    padding: 0.25rem; /* Added padding for easier click */
    border-radius: 9999px; /* Make it round */
    opacity: 0.8;
    transition: opacity 0.2s, background-color 0.2s;
}
.toast-close-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.3); /* Darker background on hover */
}
/* New: Spinner for Stripe loading */
.stripe-loading-spinner {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Styles for Caneva Tab and Canvas */
#main-content {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

#chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#canva-area {
    flex-grow: 1;
    display: none; /* Hidden by default */
    flex-direction: column;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    position: relative;
}

/* New: Highlight for active Caneva tab */
#canva-area.active-tab {
    background-color: var(--accent-color-dark); /* Highlight color */
    border-left: 1px solid var(--accent-color);
}

#canva-iframe-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

#canva-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white; /* Default background for canvas */
}

#canva-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 100;
    transition: background-color 0.2s, color 0.2s;
}
#canva-close-btn:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}

/* Sidebar for discussions */
#discussions-sidebar {
    width: 280px; /* Fixed width for the sidebar on desktop */
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0; /* Prevent shrinking */
    position: relative; /* Added for absolute positioning of close button */
}

/* Adjust dropdown for top-left positioning */
#discussions-sidebar .dropdown {
    align-self: flex-start; /* Align to start (left) */
    margin-bottom: 1rem; /* Space below the menu */
    position: absolute; /* Position absolutely within sidebar */
    top: 1rem; /* From top */
    left: 1rem; /* From left */
    z-index: 10; /* Ensure it's above other content */
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-panel);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    /* right: 0; /* Removed for top-left positioning */
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0;
}

.dropdown-content button, .dropdown-content select {
    color: var(--text-main);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.dropdown-content button:hover, .dropdown-content select:hover {
    background-color: var(--bg-input);
}

.dropdown-content select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3Csvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1.2em;
    border-radius: 0; /* Remove border-radius for dropdown items */
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Style for the close button in discussions sidebar */
#discussions-sidebar-close-btn {
    position: absolute;
    top: 1rem; /* Adjust as needed */
    right: 1rem; /* Adjust as needed */
    background-color: var(--error-color); /* Make it red for visibility */
    color: white;
    border: none;
    border-radius: 9999px; /* Make it round */
    padding: 0.5rem; /* Increase padding for better click area */
    cursor: pointer;
    z-index: 20; /* Ensure it's above the dropdown and other content */
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3); /* Add a subtle shadow */
}
#discussions-sidebar-close-btn:hover {
    background-color: #dc2626; /* Darker red on hover */
    transform: rotate(90deg) scale(1.1); /* Rotate and slightly enlarge on hover */
}


#discussions-list {
    flex-grow: 1;
    margin-top: 4rem; /* Adjust margin to make space for the menu and close button */
    overflow-y: auto;
}

.discussion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background-color: var(--bg-input);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}
.discussion-item:hover {
    background-color: var(--border-color);
}
.discussion-item.active {
    background-color: var(--accent-color-dark);
    color: white;
    font-weight: 600;
}
.discussion-item span {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.discussion-item .edit-title-btn, .discussion-item .delete-discussion-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.25rem;
    margin-left: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
}
.discussion-item.active .edit-title-btn, .discussion-item.active .delete-discussion-btn {
    color: white;
}
.discussion-item .edit-title-btn:hover, .discussion-item .delete-discussion-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

/* File input styling */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}
.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}
.file-input-wrapper .styled-button {
    cursor: pointer;
}

/* New: Header Profile/Login Button */
#header-auth-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem; /* Slightly rounded corners for a button look */
    background-color: black; /* Black background */
    color: white; /* White text */
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    cursor: pointer;
    font-weight: 600;
    border: 1px solid black; /* Black border */
}
#header-auth-btn:hover {
    background-color: #333; /* Slightly lighter black on hover */
    border-color: #333;
}
#header-auth-btn img {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    object-fit: cover;
}

/* Dropdown menu for main navigation */
.dropdown {
    position: relative;
    display: inline-block;
    /* Ensure it aligns to the right within its flex container */
    /* align-self: flex-end; /* Removed for top-left positioning */
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-panel);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    /* right: 0; /* Removed for top-left positioning */
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0;
}

.dropdown-content button, .dropdown-content select {
    color: var(--text-main);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.dropdown-content button:hover, .dropdown-content select:hover {
    background-color: var(--bg-input);
}

.dropdown-content select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3Csvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1.2em;
    border-radius: 0; /* Remove border-radius for dropdown items */
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Responsive adjustments for mobile sidebar */
@media (max-width: 768px) {
    #discussions-sidebar {
        padding-top: 4rem; /* Add padding to the top to make space for the close button */
    }
    #discussions-sidebar .dropdown {
        top: 1rem;
        left: 1rem;
    }
    #discussions-sidebar-close-btn {
        top: 1rem;
        right: 1rem;
        display: block; /* Ensure it's visible on mobile */
    }
}

/* NEW STYLES FOR COMPACT INPUT AREA */
.input-area-container {
    position: relative;
    display: flex;
    flex-direction: column; /* Stack input and tools vertically */
    gap: 0.75rem; /* Space between input and tools */
    padding: 1rem; /* Padding around the whole container */
    background-color: var(--bg-main);
    z-index: 40;
    /* Ensure it stays at the bottom of its parent (#chat-area) */
    flex-shrink: 0; /* Prevent it from shrinking */
}

.input-main-row {
    display: flex;
    align-items: flex-end; /* Align items to the bottom */
    gap: 0.5rem; /* Space between file input and main input wrapper */
}

.input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column; /* Stack textarea and quick actions vertically */
    flex-grow: 1; /* Allow it to take available space */
    border-radius: 0.75rem; /* Rounded corners for the whole input area */
    border: 1px solid var(--border-color);
    background-color: var(--bg-input); /* Utilise la variable plus grise */
    padding: 0.5rem; /* Padding inside the input wrapper */
}

#user-input {
    flex-grow: 1;
    padding: 0.5rem 0.75rem; /* Padding for text inside textarea */
    padding-left: 3.5rem; /* Added padding for the new left button */
    border: none; /* Remove border from textarea itself */
    background-color: var(--bg-input); /* Rendu blanc */
    color: var(--text-main);
    placeholder-color: var(--text-secondary);
    resize: vertical; /* Allow vertical resizing */
    min-height: 48px; /* Minimum height for usability */
    max-height: 200px; /* Max height before scrollbar appears */
    overflow-y: auto; /* Enable scrollbar if content exceeds max-height */
    line-height: 1.5;
    font-size: 1rem;
    outline: none; /* Remove outline on focus */
}

#user-input:focus {
    box-shadow: none; /* Remove default focus shadow */
}

.input-buttons-group {
    position: absolute; /* Position buttons absolutely within the input-wrapper */
    top: 0.5rem; /* Align with top padding of input-wrapper */
    right: 0.5rem; /* Align with right padding of input-wrapper */
    display: flex;
    gap: 0.5rem; /* Space between buttons */
    align-items: flex-end; /* Align buttons to the bottom */
    z-index: 1; /* Ensure buttons are above textarea */
}

/* New: Left-aligned input buttons group */
.input-buttons-group-left {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    z-index: 1;
}

.input-buttons-group .styled-button,
.input-buttons-group-left .styled-button { /* Apply to both groups */
    padding: 0; /* Remove padding from styled-button */
    border-radius: 9999px; /* Make them round */
    box-shadow: none; /* No shadow for integrated buttons */
    min-width: 40px; /* Augmenté pour la visibilité */
    min-height: 40px; /* Augmenté pour la visibilité */
    background-color: var(--accent-color); /* Rendre plus visible */
    color: white; /* Couleur de l'icône */
    border: 1px solid var(--accent-color-dark); /* Bordure pour le faire ressortir */
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-buttons-group .styled-button:hover,
.input-buttons-group-left .styled-button:hover { /* Apply to both groups */
    transform: none; /* Remove hover transform */
    box-shadow: none; /* Remove hover shadow */
    opacity: 1; /* S'assurer qu'il ne s'estompe pas trop */
    background-color: var(--accent-color-dark); /* Slight hover background */
}

/* Quick Action Buttons (now inside input-wrapper) */
.quick-actions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem; /* Smaller gap for more compact layout */
    justify-content: flex-start; /* Align to start */
    margin-top: 0.75rem; /* Space between textarea and quick actions */
    padding-top: 0.75rem; /* Add padding to separate from textarea */
}

.quick-actions-container button {
    padding: 0.6rem 1rem; /* Adjusted padding */
    font-size: 0.875rem; /* Slightly smaller font */
    border-radius: 0.5rem; /* Consistent border-radius */
    flex-grow: 1; /* Permettre aux boutons de prendre tout l'espace disponible */
    flex-shrink: 1; /* Allow shrinking */
    white-space: nowrap; /* Prevent text wrapping */
    background-color: var(--bg-input); /* Keep existing background */
    color: var(--text-secondary); /* Keep existing text color */
    border: 1px solid var(--border-color); /* Keep existing border */
}

.quick-actions-container button:hover {
    background-color: var(--border-color);
}

/* Adjust chat history padding to account for new input area height */
#chat-history {
    padding-bottom: 1rem; /* Adjust as needed, will be overridden by JS */
    /* Add flex-grow to chat-history to take available space */
    flex-grow: 1;
    overflow-y: auto;
}

/* Voice status indicator positioning */
#voice-status-indicator {
    margin-top: 0; /* Remove top margin as it's now inside the new container */
    margin-bottom: 0.75rem; /* Add some space below it */
}

/* Responsive adjustments for new input area */
@media (max-width: 768px) {
    .input-area-container {
        padding: 0.75rem; /* Smaller padding on mobile */
    }
    .input-main-row {
        flex-direction: column; /* Stack file input and main input vertically on mobile */
        align-items: stretch; /* Stretch items to fill width */
    }
    .input-wrapper {
        padding: 0.4rem;
    }
    #user-input {
        padding: 0.4rem 0.6rem;
        padding-left: 3rem; /* Adjust padding for mobile */
        min-height: 44px;
    }
    .input-buttons-group .styled-button,
    .input-buttons-group-left .styled-button { /* Apply to both groups */
        padding: 0.5rem;
        min-width: 32px;
        min-height: 32px;
    }
    .quick-actions-container {
        justify-content: flex-start; /* Align left on mobile */
        padding: 0 0.5rem; /* Add horizontal padding */
    }
    .quick-actions-container button {
        flex-grow: 1; /* Allow buttons to grow and fill space */
    }
}