/* tabler_ai_sidebar.css — sidebar chat Assistant IA pour Tabler (2026-09-06)
   Adapté de writer_ai_sidebar.css. */
.ai-chat-sidebar {
    width: 340px;
    min-width: 340px;
    background: #1e1e2e;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    font-size: 13px;
    color: #cdd6f4;
    /* Borne la hauteur au viewport et colle en haut lors du scroll */
    position: sticky;
    top: 0;
    max-height: 100vh;
    align-self: flex-start;
}

.ai-chat-sidebar.hidden {
    width: 0;
    min-width: 0;
    border-left: none;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* min-height empêche la zone de disparaître quand peu de messages */
    min-height: 80px;
}

.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #45475a; border-radius: 2px; }

.ai-chat-msg { display: flex; }
.ai-chat-msg-user { justify-content: flex-end; }
.ai-chat-msg-assistant { justify-content: flex-start; }

.ai-chat-bubble {
    max-width: 88%;
    padding: 8px 11px;
    border-radius: 10px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-msg-user .ai-chat-bubble {
    background: #89b4fa;
    color: #1e1e2e;
    border-bottom-right-radius: 2px;
}

.ai-chat-msg-assistant .ai-chat-bubble {
    background: #313244;
    color: #cdd6f4;
    border-bottom-left-radius: 2px;
}

.ai-chat-waiting { width: 100%; max-width: 100%; }
.ai-chat-waiting img {
    width: 100%; height: auto; display: block; border-radius: 10px;
    border: 1px solid #45475a; background: #11111b;
}

.ai-chat-selection-chip {
    flex-shrink: 0; margin: 0 8px 6px; padding: 6px 9px;
    background: #313244; border: 1px solid #89b4fa; border-radius: 8px;
    font-size: 11.5px; color: #cdd6f4; display: flex; align-items: center; gap: 8px;
}
.ai-chat-selection-chip.hidden { display: none; }
.ai-chat-chip-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chat-chip-clear { cursor: pointer; color: #a6adc8; flex-shrink: 0; }
.ai-chat-chip-clear:hover { color: #f38ba8; }

.ai-chat-input-row {
    flex-shrink: 0; display: flex; gap: 6px; padding: 8px;
    border-top: 1px solid #333; background: #181825;
}
.ai-chat-input {
    flex: 1; resize: none; background: #11111b; border: 1px solid #45475a;
    border-radius: 8px; color: #cdd6f4; padding: 7px 9px; font-size: 13px; font-family: inherit;
    /* Limite la hauteur max du textarea — jamais plus de ~4 lignes */
    max-height: 100px;
    overflow-y: auto;
}
.ai-chat-input:focus { outline: none; border-color: #89b4fa; }
.ai-chat-send-btn {
    flex-shrink: 0; width: 34px; border: none; background: #89b4fa; color: #1e1e2e;
    border-radius: 8px; cursor: pointer; font-size: 15px;
}
.ai-chat-send-btn:hover { background: #74a8f8; }
.ai-chat-send-btn:disabled { opacity: 0.5; cursor: default; }

.sidebar-header {
    flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: #181825; border-bottom: 1px solid #333;
}
.sidebar-title { font-weight: 700; color: #f5f5f5; font-size: 13px; }
.sidebar-action-btn { cursor: pointer; color: #a6adc8; font-size: 14px; }
.sidebar-action-btn:hover { color: #f38ba8; }

.ai-chat-mode {
    flex-shrink: 0; display: flex; gap: 4px; padding: 6px 10px;
    background: #181825; border-bottom: 1px solid #333;
}
.ai-chat-mode-btn {
    flex: 1; padding: 6px 4px; font-size: 12px; font-weight: 600;
    background: #11111b; color: #a6adc8; border: 1px solid #45475a; border-radius: 7px;
    cursor: pointer; white-space: nowrap;
}
.ai-chat-mode-btn:hover { color: #cdd6f4; border-color: #89b4fa; }
.ai-chat-mode-btn.active {
    background: #89b4fa; color: #1e1e2e; border-color: #89b4fa;
}