/* Zone de conversation avec nouveau format */
.chat-content {
    /* Make this row  */
}

/* Styles pour les liens de conversations */
.conversation-link {
    position: relative;
    transition: all 0.3s ease;
}

.conversation-link:hover {
    background-color: var(--kt-gray-100);
    border-radius: 0.5rem;
}

.conversation-link.active {
    background-color: var(--kt-primary-light);
    border-radius: 0.5rem;
    color: var(--kt-primary);
}

.conversation-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background-color: var(--kt-primary);
    border-radius: 0 2px 2px 0;
}

.conversation-link.active .menu-title {
    font-weight: 600;
}

.conversation-link.active .bullet {
    background-color: var(--kt-primary);
}

/* Animation pour le message de bienvenue */
.welcome-message {
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.welcome-message.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

/* Animation pour les messages de chat */
.chat-active #messages-container {
    animation: slideIn 0.4s ease-out;
}

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

#messages-container {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

#messages-container.show {
    opacity: 1;
    transform: translateY(0);
}

/* Messages avec format Metronic - animation d'entrée optimisée */
.d-flex.justify-content-start,
.d-flex.justify-content-end {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInFromBottom 0.4s ease-out forwards;
}

/* Animation de bienvenue améliorée */
.welcome-message {
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.welcome-message.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

/* Styles pour les messages avec avatars */
/* .symbol img {
    border-radius: 50%;
    object-fit: cover;
} */

/* Amélioration des bulles de messages */
[data-kt-element="message-text"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

[data-kt-element="message-text"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Support pour le mode sombre */
[data-bs-theme="dark"] [data-kt-element="message-text"].bg-light-info {
    background-color: var(--bs-gray-800) !important;
    color: var(--bs-gray-100) !important;
    border: 1px solid var(--bs-gray-700);
}

[data-bs-theme="dark"] [data-kt-element="message-text"].bg-light-primary {
    background-color: var(--bs-primary) !important;
    color: white !important;
}

/* Animation du prompt vers le bas */
.prompt-container {
    transition: all 0.5s ease-out;
}

.prompt-container.chat-mode {
    position: sticky;
    display: block!important;
    margin-top: auto!important;
    z-index: 1000;
    align-self: end;
}

/* Animation de frappe améliorée pour le nouveau format */
.typing-indicator {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInFromBottom 0.3s ease-out forwards;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--bs-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Animation du curseur de frappe pour le streaming */
.typing-cursor {
    color: var(--bs-primary);
    font-weight: bold;
}

.typing-cursor.blinking {
    animation: blink 1s infinite;
}

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

/* Amélioration de l'affichage du streaming */
.streaming-message {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInFromBottom 0.4s ease-out forwards;
}

.streaming-content {
    animation: typewriter 0.1s ease-out;
}

@keyframes typewriter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Styles spécifiques Clara */
body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.glass {
    --glass-lightness: 100%;
    --glass-blur: 40px;
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
}

.chat-container {
    overflow-y: auto;
    padding: 1rem 0;
}

.chat-message {
    margin-bottom: 1.5rem;
}

.chat-message.user {
    text-align: right;
}

.chat-message.assistant {
    text-align: left;
}

.message-bubble {
    display: inline-block;
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
}

.message-bubble.user {
    background-color: var(--bs-primary);
    color: white;
}

.message-bubble.assistant {
    background-color: var(--bs-gray-100);
    color: var(--bs-gray-900);
    border: 1px solid var(--bs-gray-300);
}

/* Dark mode support pour les messages */
[data-bs-theme="dark"] .message-bubble.assistant {
    background-color: var(--bs-gray-800);
    color: var(--bs-gray-100);
    border-color: var(--bs-gray-700);
}

/* Hidden elements */
.jumbotron-header {
    min-height: 40vh;
    display: flex; /* S'assurer qu'il est visible par défaut */
}

/* Masquer seulement quand explicitement marqué comme caché */
.jumbotron-header.d-none {
    display: none !important;
}

.chat-container-hidden {
    display: none;
}

.prompt-container {
    max-width: 800px;
}

.tools-count-hidden {
    display: none;
}

/* Disable button states */
.btn-send.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send:not(.disabled) {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: white !important;
}

/* Cursor styles */
.cursor-pointer {
    cursor: pointer;
}

/* Badge styles for tools */
.badge.badge-primary {
    background-color: var(--bs-primary) !important;
    color: white !important;
}

/* Dropdown item hover effects */
.dropdown-item:hover {
    background-color: var(--bs-gray-100);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: var(--bs-gray-800);
}

/* Tools container responsive */
#selected-tools-container {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
    max-width: 250px;
}

#selected-tools-container::-webkit-scrollbar {
    display: none;
}

#selected-tools-container .badge {
    white-space: nowrap;
    font-size: 0.75rem;
}

/* Textarea auto-resize */
.input-prompt-field {
    resize: none;
    min-height: 2.5rem;
    max-height: 8rem;
    transition: height 0.2s ease;
    border: none;
    outline: none;
    box-shadow: none;
}

.input-prompt-field:focus {
    border: none;
    box-shadow: none;
}

/* Animations principales */
@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Animation de l'indicateur de frappe */
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.typing-indicator .spinner-border {
    animation: pulse 1.5s infinite;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {    
    .jumbotron-header {
        min-height: 30vh;
    }
    
    .welcome-message {
        padding: 2rem 1rem;
    }
    
    .chat-container {
        max-height: 50vh;
    }
    
    #selected-tools-container {
        max-width: 100px;
    }
    
    #selected-tools-container .badge {
        font-size: 0.65rem;
    }
    
    /* Hide tool text on mobile, show only icons */
    #selected-tools-container .badge .tool-text {
        display: none;
    }
    
    .prompt-container {
        padding: 0.5rem;
    }
    
    .mw-lg-400px {
        max-width: 90% !important;
    }
    
    /* Réduire la taille des avatars sur mobile */
    .symbol-35px {
        width: 30px !important;
        height: 30px !important;
    }
    
    /* Ajuster l'espacement des messages */
    .mb-10 {
        margin-bottom: 1rem !important;
    }
    
    /* Réduire le padding des bulles de messages */
    [data-kt-element="message-text"] {
        padding: 0.75rem !important;
        font-size: 0.9rem;
    }
}

/* Animation d'état de chat actif */
body.chat-active #jumbotron-header {
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

body.chat-active #jumbotron-header.d-none {
    display: none !important;
}

/* ========================================
 * Styles pour la recherche de conversations
 * ======================================== */

/* Résultats de recherche dans le modal */
.conversation-search-result {
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.conversation-search-result:hover {
    background-color: var(--kt-gray-100) !important;
    border-color: var(--kt-gray-300);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Mise en surbrillance des termes recherchés */
.conversation-search-result mark {
    background-color: #fff3cd !important;
    color: #856404 !important;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* Badges pour indiquer le type de correspondance */
.conversation-search-result .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
}

/* Animation pour les résultats */
.conversation-search-result {
    animation: slideInSearchResult 0.3s ease-out;
}

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

/* Spinner de recherche */
[data-kt-search-element="spinner"] {
    z-index: 10;
}

/* Style pour les extraits de conversation */
.conversation-search-result .text-muted {
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Messages vides améliorés */
[data-kt-search-element="empty"] i {
    opacity: 0.6;
}

/* Focus amélioré pour le champ de recherche */
[data-kt-search-element="input"]:focus {
    border-color: var(--kt-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--kt-primary-rgb), 0.25);
}

/* ========================================
 * Styles pour le drag & drop d'images
 * ======================================== */

/* Zone de drop améliorée */
.prompt-container.drag-over,
#input-prompt-card.drag-over {
    border: 2px dashed var(--bs-primary) !important;
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

#input-prompt-card.drag-active {
    border: 2px dashed var(--bs-success) !important;
    background-color: rgba(var(--bs-success-rgb), 0.05) !important;
    box-shadow: 0 4px 12px rgba(var(--bs-success-rgb), 0.2);
}

/* Message de drop */
#drop-message {
    animation: slideDownDrop 0.3s ease-out;
    border: 1px solid var(--bs-info);
    background-color: rgba(var(--bs-info-rgb), 0.1);
}

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

/* Zone d'attachements */
.attachments-preview {
    border-top: 1px solid var(--bs-gray-200);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.attachment-item {
    transition: all 0.2s ease;
    border: 1px solid var(--bs-gray-200) !important;
}

.attachment-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--bs-primary) !important;
}

/* Prévisualisation d'images dans les attachements */
.attachment-preview {
    border: 1px solid var(--bs-gray-300);
    transition: transform 0.2s ease;
}

.attachment-preview:hover {
    transform: scale(1.05);
}

/* Images dans les messages */
.attachment-display {
    border: 1px solid var(--bs-gray-300);
    border-radius: 8px;
    transition: transform 0.2s ease;
    max-width: 100% !important;
    height: auto !important;
}

.attachment-display:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.attachment-display.attachment-expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.5);
    z-index: 9999;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    cursor: zoom-out;
    background: white;
    padding: 4px;
}

/* Overlay pour l'image agrandie */
.attachment-display.attachment-expanded::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: -1;
}

/* Amélioration des fichiers attachés dans les messages */
.message-with-attachments .attachment-item {
    background-color: rgba(var(--bs-light-rgb), 0.5) !important;
    border-radius: 8px;
    max-width: 280px;
}

/* Animation pour les nouvelles pièces jointes */
.attachment-item {
    animation: attachmentSlideIn 0.3s ease-out;
}

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

/* Support mode sombre pour les attachements */
[data-bs-theme="dark"] .attachment-item {
    background-color: var(--bs-gray-800) !important;
    border-color: var(--bs-gray-700) !important;
    color: var(--bs-gray-100);
}

[data-bs-theme="dark"] .attachments-preview {
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] #drop-message {
    background-color: rgba(var(--bs-info-rgb), 0.2);
    border-color: var(--bs-info);
    color: var(--bs-gray-100);
}

[data-bs-theme="dark"] .attachment-display.attachment-expanded {
    background: var(--bs-gray-900);
}
