/* Styles pour l'assistant IA - Version améliorée */
#ai-assistant-container {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 99999 !important;
    transition: all 0.3s ease;
    display: block !important;
    width: auto !important;
    height: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

#ai-assistant-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00C9FF, #92FE9D);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    border: none;
    z-index: 99999;
    opacity: 1 !important;
    visibility: visible !important;
}

#ai-assistant-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

#ai-assistant-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: var(--bs-dark);
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--bs-gray-700);
}

#panel-header {
    background: linear-gradient(135deg, #00C9FF, #92FE9D);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

#panel-header h5 {
    margin: 0;
    color: white;
    font-weight: 600;
}

.panel-controls {
    display: flex;
    gap: 10px;
}

#panel-header button {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#panel-header button:hover {
    transform: scale(1.1);
}

/* Onglets */
#ai-assistant-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.active-tab {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.hidden-tab {
    display: none;
}

/* Chat */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--bs-dark);
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 5px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message-content {
    width: 100%;
}

.message-actions {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.message:hover .message-actions {
    display: block;
}

.star-button {
    background: transparent;
    border: none;
    color: var(--bs-gray-500);
    cursor: pointer;
    font-size: 14px;
}

.star-button:hover {
    color: var(--bs-warning);
}

.star-button.active i {
    color: var(--bs-warning);
    font-weight: 900;
}

.user-message {
    background: var(--bs-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.assistant-message {
    background: var(--bs-gray-700);
    color: var(--bs-light);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

/* Support pour le formatage Markdown dans les messages de l'assistant */
.assistant-message a {
    color: var(--bs-info);
    text-decoration: underline;
}

.assistant-message pre {
    background-color: var(--bs-gray-800);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.9em;
}

.assistant-message code {
    background-color: var(--bs-gray-800);
    padding: 2px 5px;
    border-radius: 3px;
}

.assistant-message ul, 
.assistant-message ol {
    margin: 10px 0;
    padding-left: 20px;
}

.assistant-message img {
    max-width: 100%;
    border-radius: 5px;
    margin: 10px 0;
}

.assistant-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 0.9em;
}

.assistant-message th, 
.assistant-message td {
    border: 1px solid var(--bs-gray-600);
    padding: 6px;
}

.assistant-message th {
    background-color: var(--bs-gray-800);
}

#typing-indicator {
    align-self: flex-start;
    background: var(--bs-gray-700);
    padding: 10px 15px;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    margin-bottom: 5px;
    display: none;
}

#typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--bs-gray-500);
    border-radius: 50%;
    margin-right: 3px;
    animation: blink 1s infinite;
}

#typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

#typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Questions rapides */
.quick-questions-container {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background-color: var(--bs-gray-800);
    border-top: 1px solid var(--bs-gray-700);
}

.quick-question {
    background-color: var(--bs-gray-700);
    color: var(--bs-light);
    border: none;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.quick-question:hover {
    background-color: var(--bs-gray-600);
}

/* Zone de saisie */
.input-container {
    display: flex;
    padding: 10px;
    background-color: var(--bs-gray-800);
    border-top: 1px solid var(--bs-gray-700);
}

#message-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background-color: var(--bs-gray-700);
    color: var(--bs-light);
    outline: none;
}

#send-button {
    background-color: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

#send-button:hover {
    background-color: var(--bs-primary-hover, #0069d9);
}

#send-button:disabled {
    background-color: var(--bs-gray-600);
    cursor: not-allowed;
}

/* Historique des conversations */
.history-header, .upload-header {
    background: linear-gradient(135deg, #00C9FF, #92FE9D);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h5, .upload-header h5 {
    margin: 0;
    color: white;
    font-weight: 600;
}

.back-button {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--bs-dark);
}

.conversation-item {
    background-color: var(--bs-gray-800);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversation-item:hover {
    background-color: var(--bs-gray-700);
}

.conversation-info h6 {
    margin: 0 0 5px 0;
    color: var(--bs-light);
    font-weight: 600;
}

.conversation-preview {
    margin: 0 0 5px 0;
    color: var(--bs-gray-400);
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-date {
    color: var(--bs-gray-500);
    font-size: 0.8em;
}

.empty-history-message {
    color: var(--bs-gray-500);
    text-align: center;
    padding: 30px;
}

/* Upload d'image */
.upload-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
    background-color: var(--bs-dark);
}

.upload-dropzone {
    border: 2px dashed var(--bs-gray-600);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    color: var(--bs-gray-400);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--bs-primary);
    background-color: var(--bs-gray-800);
}

.upload-dropzone i {
    font-size: 36px;
    margin-bottom: 10px;
    color: var(--bs-gray-500);
}

.upload-preview {
    position: relative;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
}

.upload-preview img {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.cancel-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.analyze-button {
    background-color: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.analyze-button:hover {
    background-color: var(--bs-primary-hover, #0069d9);
}

.analyze-button:disabled {
    background-color: var(--bs-gray-600);
    cursor: not-allowed;
}

.upload-result {
    background-color: var(--bs-gray-800);
    border-radius: 8px;
    padding: 15px;
}

.upload-result h6 {
    margin: 0 0 10px 0;
    color: var(--bs-light);
    font-weight: 600;
}

#analysis-content {
    margin-bottom: 15px;
    color: var(--bs-light);
    line-height: 1.5;
}