/* RAG Agentic Streaming UI Styles */

.message.streaming {
    position: relative;
}

/* Header dans le message-bubble */
.message-bubble .rag-streaming-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.rag-mode-badge {
    font-weight: 600;
    font-size: 13px;
    color: #3498db;
    background: rgba(74, 158, 255, 0.1);
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.streaming-indicator {
    color: #61C276;
    font-size: 16px;
    animation: blink 1s ease-in-out infinite;
}

.streaming-indicator.active {
    display: inline-block;
}

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

/* Progress info dans le message-bubble */
.message-bubble .rag-progress-info {
    display: flex;
    gap: 15px;
    padding: 8px 12px;
    background: rgba(74, 158, 255, 0.08);
    border-radius: 8px;
    font-size: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
}

.hop-indicator,
.phase-indicator,
.duration-info {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #94a3b8;
}

.hop-current,
.hop-total {
    font-weight: 600;
    color: #303D4E;
    font-size: 14px;
}

.phase-name {
    font-weight: 500;
    color: #61C276;
}

.duration-info {
    margin-left: auto;
    color: #94a3b8;
    font-size: 12px;
}

/* Contenu streaming dans le message-bubble */
.message-bubble .rag-streaming-content {
    min-height: 40px;
    line-height: 1.6;
}

.waiting-message {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 20px;
    animation: fadeInOut 2s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.rag-streaming-content p {
    margin: 0 0 10px 0;
}

.rag-streaming-content p:last-child {
    margin-bottom: 0;
}

.rag-streaming-content strong {
    color: #303D4E;
    font-weight: 600;
}

.rag-streaming-content em {
    color: #303D4E;
    font-style: italic;
}

.rag-streaming-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #fbbf24;
}

.rag-streaming-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.rag-streaming-content pre code {
    background: none;
    padding: 0;
    color: #e5e7eb;
}

.rag-streaming-content ul,
.rag-streaming-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.rag-streaming-content li {
    margin: 5px 0;
}

.rag-streaming-content blockquote {
    border-left: 4px solid #303D4E;
    padding-left: 15px;
    margin: 15px 0;
    color: #94a3b8;
    font-style: italic;
}

.message.error .rag-streaming-content {
    background: rgba(197, 66, 43, 0.1);
    border: 1px solid rgba(197, 66, 43, 0.3);
}

.error-message {
    color: #ED7470;
    padding: 15px;
    text-align: center;
}

.error-message strong {
    display: block;
    margin-bottom: 10px;
    font-size: 16px;
}

/* Animation d'apparition */
.message.assistant-message {
    animation: slideIn 0.3s ease-out;
}

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

/* ✨ NOUVEAUX STYLES POUR LES HOPS */

/* Container des hops */
.hops-container {
    margin: 15px 0;
    padding: 12px;
    background: rgba(245, 247, 250, 0.5);
    border-radius: 8px;
}

/* ✨ Hops repliables dans <details> */
.hops-details {
    margin: 15px 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
}

.hops-details[open] {
    background: rgba(245, 247, 250, 0.5);
}

.hops-summary {
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.hops-summary:hover {
    background: rgba(74, 158, 255, 0.08);
    color: #3498db;
}

.hops-summary i.fa-chevron-down {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.hops-details[open] .hops-summary i.fa-chevron-down {
    transform: rotate(180deg);
}

.hops-content {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    display: block; /* S'assurer que le contenu est visible */
}

/* Forcer l'affichage du contenu quand details est ouvert */
.hops-details[open] .hops-content {
    display: block !important;
}

/* Badge de complexité */
.complexity-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #303D4E;
    color: white;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9em;
}

.complexity-label {
    font-weight: 600;
}

.complexity-stars {
    font-size: 1.1em;
}

.multihop-tag {
    background: rgba(255, 255, 255, 0.25);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

/* Container d'un hop */
.hop-container {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 12px;
    transition: all 0.3s ease;
}

.hop-container:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Header du hop */
.hop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.hop-badge {
    font-weight: 700;
    color: #3498db;
    font-size: 1em;
    background: rgba(74, 158, 255, 0.12);
    padding: 5px 12px;
    border-radius: 6px;
}

.hop-status {
    font-size: 0.9em;
    padding: 4px 10px;
    border-radius: 12px;
    background: #FFF3E0;
    color: #F57C00;
    font-weight: 500;
}

/* Query du hop */
.hop-query {
    margin-bottom: 12px;
    padding: 10px;
    background: #f8fafc;
    border-left: 3px solid #3498db;
    border-radius: 4px;
    font-style: italic;
    color: #475569;
    font-size: 0.95em;
}

.hop-query i {
    margin-right: 6px;
    color: #3498db;
}

/* Détails du hop */
.hop-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Documents du hop */
.hop-docs {
    background: #f0f9ff;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #bae6fd;
}

.hop-docs-header {
    font-weight: 600;
    color: #3498db;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.hop-docs-header i {
    margin-right: 6px;
}

.hop-docs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hop-doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: white;
    border-radius: 4px;
    font-size: 0.85em;
}

.doc-icon {
    font-size: 1.1em;
}

.doc-file {
    flex: 1;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-score {
    font-weight: 600;
    color: #3498db;
    font-size: 0.9em;
}

.hop-docs-more {
    font-size: 0.85em;
    color: #64748b;
    font-style: italic;
    text-align: center;
    padding-top: 4px;
}

/* Entités du hop */
.hop-entities {
    background: #f0fdf4;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
}

.hop-entities-header {
    font-weight: 600;
    color: #61C276;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.hop-entities-header i {
    margin-right: 6px;
}

.hop-entities-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.entity-tag {
    display: inline-block;
    padding: 5px 10px;
    background: white;
    border: 1px solid #61C276;
    border-radius: 12px;
    font-size: 0.85em;
    color: #61C276;
    font-weight: 500;
}

.entity-tag.more {
    background: #dcfce7;
    border-color: #61C276;
}

/* Relations du hop */
.hop-relations {
    background: #fef3f2;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.hop-relations-header {
    font-weight: 600;
    color: #ED7470;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.hop-relations-header i {
    margin-right: 6px;
}

.hop-relations-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.relation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    font-size: 0.85em;
}

.relation-subject,
.relation-object {
    font-weight: 600;
    color: #ED7470;
    background: #fee2e2;
    padding: 3px 8px;
    border-radius: 4px;
}

.relation-type {
    color: #64748b;
    font-style: italic;
}

.relation-item i {
    color: #cbd5e1;
    font-size: 0.8em;
}

.hop-relations-more {
    font-size: 0.85em;
    color: #64748b;
    font-style: italic;
    text-align: center;
    padding-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .rag-progress-info {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .duration-info {
        margin-left: 0;
    }

    .hop-container {
        padding: 10px;
    }

    .hop-query {
        font-size: 0.9em;
    }

    .entity-tag {
        font-size: 0.8em;
        padding: 4px 8px;
    }
}
