:root {
    --bg-main: #ffffff;
    --sidebar-bg: #f8f9fa;
    --chat-bg: #ffffff;
    --text-main: #1a1a1a;
    --text-muted: #6e6e73;
    --accent: #333333; /* Soft dark grey instead of pure black */
    --accent-light: #f5f5f7;
    --user-msg: #f5f5f7;
    --bot-msg: transparent;
    --input-bg: #ffffff;
    --sidebar-hover: #efeff3;
    --sidebar-active: #e5e5ea;
    --border-color: rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 18px 1.2rem; /* Aligné avec le header */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.new-chat-btn {
    background: var(--accent);
    border: none;
    color: white;
    height: 35px;
    padding: 0 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px; /* Réduit le gap de l'icône */
    transition: transform 0.2s, background 0.2s;
    margin-bottom: 2rem;
    width: 100%;
    justify-content: center;
    font-size: 0.8rem; /* Réduit la taille du texte */
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-top: 0;
}

.new-chat-btn svg {
    width: 14px; /* Réduit la taille de l'icône */
    height: 14px;
}

.new-chat-btn:hover {
    background: #4a4a4a;
    transform: translateY(-1px);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin: 1.5rem 0.5rem 0.8rem;
    font-weight: 700;
}

.conv-item {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
}

.conv-item:hover {
    background: var(--sidebar-hover);
}

.conv-item.active {
    background: white;
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    font-weight: 600;
}

.conv-item svg {
    flex-shrink: 0;
    opacity: 0.4;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--chat-bg);
}

.chat-header {
    padding: 0 2.5rem;
    height: calc(35px + 18px + 18px); /* Calcule la hauteur pour correspondre au bouton + padding */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.chat-header h2 {
    font-size: 1.1rem; /* Réduit de 1.2rem */
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0;
    height: 35px;
}

.header-subtitle {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem; /* Réduit de 0.95rem */
}

.header-subtitle strong {
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem; /* Réduit de 1.1rem */
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.footer-brand {
    font-size: 0.85rem;
    font-weight: 800; /* Plus gras pour Hierark */
    color: var(--accent);
    letter-spacing: 0.5px;
}

.footer-version {
    font-size: 0.6rem; /* Encore plus petit pour la version */
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.8;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}

#chat-messages::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.message-wrapper {
    width: 100%;
    display: flex;
    padding: 0 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    max-width: 850px;
    margin: 0 auto;
    display: flex;
    gap: 1.8rem;
    width: 100%;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.avatar.user { background: var(--accent); color: white; }
.avatar.bot { background: var(--accent-light); color: var(--accent); border: 1px solid var(--border-color); }

.content {
    flex: 1;
    line-height: 1.6;
    font-size: 0.95rem; /* Réduit de 1.05rem */
    color: #333;
}

.content p { margin-bottom: 1.2rem; }
.content code { background: #f5f5f7; padding: 3px 6px; border-radius: 6px; font-family: 'SF Mono', monospace; font-size: 0.9em; }
.content pre { background: #1a1a1a; color: white; padding: 1.2rem; border-radius: 12px; overflow-x: auto; margin-bottom: 1.5rem; }

/* Bot Actions */
.bot-actions {
    display: flex;
    gap: 8px;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-wrapper:hover .bot-actions {
    opacity: 1;
}

.action-btn {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: 0.2s;
    font-weight: 600;
}

.action-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.action-btn svg {
    width: 12px;
    height: 12px;
}

/* Input Area */
.input-container {
    max-width: 850px;
    width: 92%;
    margin: 0 auto 2.5rem auto;
    position: relative;
}

.input-wrapper {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.6rem 1.2rem; /* Réduit le padding vertical */
    display: flex;
    align-items: center; /* Centre verticalement le contenu */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem; /* Taille de texte réduite */
    resize: none;
    max-height: 200px;
    outline: none;
    padding: 4px 1rem 4px 0;
    line-height: 1.4;
}

.send-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: #333;
}

.send-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Typing Animation */
.typing {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    margin-left: 0.5rem;
    display: none;
    letter-spacing: 0.5px;
}

/* Mobile Menu */
.mobile-menu-container {
    display: none;
    position: relative;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.mobile-menu-btn:hover {
    color: var(--accent);
}

.mobile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 1rem;
    z-index: 100;
    max-height: 80vh;
    overflow-y: auto;
}

.mobile-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.new-chat-btn-mobile {
    background: var(--accent);
    border: none;
    color: white;
    height: 35px;
    padding: 0 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.conversations-list-mobile {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-menu-container { display: block; }
    .message { gap: 1rem; }
    .chat-header { padding: 0 1.2rem; }
    .input-container { 
        width: 95%; 
        margin-bottom: 1rem; /* Réduit la marge en bas sur mobile */
    }
    .main-chat {
        height: 100%; /* Force la hauteur pleine */
    }
}