/* === STYLES PRINCIPAUX DU CHAT === */
.ast-container, 
.site-content, 
#primary, 
.entry-content {
    min-height: 70vh !important;
}

#esotericism-chat-container {
    border: 1px solid #e0d4af;
    border-radius: 12px;
    background: #fefcf3;
    max-width: 800px;
    margin: 20px auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 95%;
}

.chat-header {
    background: #8b7355;
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.expert-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #d4af37;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    animation: pulse-gold 2s infinite;
    flex-shrink: 0;
}

.expert-badge .expert-icon {
    font-size: 14px;
}

.expert-badge .expert-name {
    color: white;
}

.expert-badge .expert-title {
    color: rgba(255,255,255,0.8);
    font-weight: normal;
}

/* === BARRE DE STATUT UTILISATEUR === */
.user-status-bar {
    background: #f8f6f0;
    padding: 10px 20px;
    border-bottom: 1px solid #e0d4af;
    font-size: 12px;
}

.status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.plan-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 10px;
    text-transform: uppercase;
}

.plan-badge.gratuit {
    background: #8b7355;
    color: white;
}

.plan-badge.premium {
    background: #d4af37;
    color: white;
}

.token-count {
    color: #666;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e0d4af;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #8b7355;
    transition: width 0.3s ease;
}

.progress-fill.premium {
    background: #d4af37;
}

/* === BARRE DES EXPERTS === */
.experts-bar {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #f5f0e6;
    border-bottom: 1px solid #e0d4af;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #8b7355 #f5f0e6;
}

.expert-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #e0d4af;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.3s ease;
    position: relative;
}

.expert-pill:hover {
    background: #8b7355;
    color: white;
    border-color: #8b7355;
}

.expert-pill:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2a2a2a;
    color: #f5f0e6;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-line;
    z-index: 1000;
    margin-bottom: 8px;
    max-width: 280px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #8b7355;
    text-align: left;
    font-family: inherit;
}

.expert-pill.active {
    background: #8b7355;
    color: white;
    border-color: #8b7355;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(139, 115, 85, 0.3);
}

/* === ZONE DE MESSAGES === */
.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: #faf5e9;
    scrollbar-width: thin;
    scrollbar-color: #8b7355 #faf5e9;
}

.message {
    margin-bottom: 15px;
    display: flex;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.user-message .message-content {
    background: #8b7355;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: white;
    border: 1px solid #e0d4af;
    border-bottom-left-radius: 4px;
}

/* === ZONE DE SAISIE === */
.chat-input {
    padding: 20px;
    border-top: 1px solid #e0d4af;
    display: flex;
    gap: 10px;
}

#user-message {
    flex: 1;
    padding: 12px;
    border: 1px solid #e0d4af;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
}

#send-message {
    background: #8b7355;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

#send-message:hover {
    background: #765c3f;
}

/* === ANIMATIONS === */
@keyframes pulse-gold {
    0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(212, 175, 55, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

/* === MESSAGE DE CONNEXION === */
.esotericism-chat-login-required {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #d4af37;
    border-radius: 20px;
    max-width: 600px;
    margin: 40px auto;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.esotericism-chat-login-required h3 {
    color: #d4af37;
    font-size: 28px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.esotericism-chat-login-required p {
    color: #ccc;
    font-size: 16px;
    margin-bottom: 30px;
}

.esotericism-chat-login-required a {
    display: inline-block;
    padding: 15px 30px;
    margin: 5px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: transform 0.3s, box-shadow 0.3s;
}

.esotericism-chat-login-required a:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

/* Styles pour le formatage Markdown */
.esotericism-chat-container .message-content strong {
    font-weight: bold;
    color: #8b7355;
}

.esotericism-chat-container .message-content em {
    font-style: italic;
    color: #d4af37;
}

.esotericism-chat-container .message-content ul {
    margin: 10px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.esotericism-chat-container .message-content li {
    margin: 5px 0;
    line-height: 1.4;
}

.esotericism-chat-container .message-content h1,
.esotericism-chat-container .message-content h2,
.esotericism-chat-container .message-content h3,
.esotericism-chat-container .message-content h4 {
    margin: 15px 0 10px 0;
    color: #8b7355;
    font-weight: bold;
}

.esotericism-chat-container .message-content h1 {
    font-size: 1.4em;
    border-bottom: 2px solid #d4af37;
    padding-bottom: 5px;
}

.esotericism-chat-container .message-content h2 {
    font-size: 1.3em;
}

.esotericism-chat-container .message-content h3 {
    font-size: 1.2em;
}

.esotericism-chat-container .message-content h4 {
    font-size: 1.1em;
}

.esotericism-chat-container .message-content blockquote {
    border-left: 4px solid #d4af37;
    margin: 10px 0;
    padding: 10px 15px;
    background: rgba(139, 115, 85, 0.1);
    font-style: italic;
}

.esotericism-chat-container .message-content hr {
    border: none;
    border-top: 2px solid #d4af37;
    margin: 15px 0;
    opacity: 0.5;
}

.esotericism-chat-container .message-content p {
    margin: 8px 0;
    line-height: 1.5;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    #esotericism-chat-container {
        margin: 10px auto;
        width: 98%;
        border-radius: 8px;
    }
    
    .chat-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .chat-header h3 {
        font-size: 1.2em;
        margin-bottom: 5px;
    }
    
    .expert-badge {
        font-size: 11px;
        padding: 5px 10px;
    }
    
    .experts-bar {
        padding: 10px 15px;
        gap: 6px;
    }
    
    .expert-pill {
        font-size: 11px;
        padding: 5px 10px;
        white-space: nowrap;
    }
    
    .expert-pill .expert-name {
        display: none; /* Hide names on mobile, show only icons */
    }
    
    .expert-pill:hover::after {
        max-width: 220px;
        font-size: 11px;
        padding: 10px 12px;
        margin-bottom: 6px;
    }
    
    .expert-pill:hover::after {
        max-width: 220px;
        font-size: 11px;
        padding: 10px 12px;
        margin-bottom: 6px;
    }
    
    .chat-messages {
        height: 350px;
        padding: 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .chat-input {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    #user-message {
        min-height: 60px;
    }
    
    #send-message {
        align-self: flex-end;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .chat-messages {
        height: 300px;
        padding: 10px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .experts-bar {
        padding: 8px 10px;
    }
    
    .expert-pill {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .expert-pill .expert-icon {
        font-size: 14px;
    }
    
    .expert-pill:hover::after {
        max-width: 180px;
        font-size: 10px;
        padding: 8px 10px;
        margin-bottom: 5px;
    }
    
    .expert-pill:hover::after {
        max-width: 180px;
        font-size: 10px;
        padding: 8px 10px;
        margin-bottom: 5px;
    }
}

/* === LOADING STATES & TYPING INDICATOR === */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(139, 115, 85, 0.1);
    border: 1px solid rgba(139, 115, 85, 0.2);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b7355;
    animation: typing-bounce 1.4s ease-in-out infinite both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    color: #8b7355;
    font-style: italic;
    font-size: 14px;
}

/* Disabled state styling */
#user-message:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

#send-message:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* === ACCESSIBILITY IMPROVEMENTS === */

/* Screen reader only text */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus styles for keyboard navigation */
.expert-pill:focus {
    outline: 3px solid #d4af37;
    outline-offset: 2px;
    background: #8b7355;
    color: white;
    border-color: #8b7355;
}

#user-message:focus {
    outline: 2px solid #d4af37;
    outline-offset: 2px;
    border-color: #8b7355;
}

#send-message:focus {
    outline: 2px solid #d4af37;
    outline-offset: 2px;
    background: #765c3f;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #esotericism-chat-container {
        border: 2px solid #000;
    }
    
    .chat-header {
        background: #000;
        color: #fff;
    }
    
    .expert-pill {
        border: 2px solid #000;
    }
    
    .expert-pill.active {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .expert-badge {
        animation: none;
    }
    
    .typing-dots span {
        animation: none;
        opacity: 0.7;
    }
    
    .message {
        transition: none;
    }
}

/* Message metadata for better context */
.message-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-message .message-meta {
    justify-content: flex-end;
}

.bot-message .message-meta {
    justify-content: flex-start;
}

/* Focus indicator for chat container */
.chat-input.focused {
    background: rgba(212, 175, 55, 0.05);
    border-top: 2px solid #d4af37;
}

/* Expert locked state accessibility */
.expert-pill.expert-locked {
    cursor: not-allowed;
    opacity: 0.6;
}

.expert-pill.expert-locked:focus {
    outline: 2px dashed #999;
    background: #f5f5f5;
    color: #666;
}

/* Ensure sufficient color contrast */
.chat-header h3 {
    color: #ffffff;
}

.user-message .message-content {
    background: #6b5a3f;
    color: #ffffff;
}

.bot-message .message-content {
    background: #ffffff;
    color: #333333;
    border: 1px solid #cccccc;
}

/* Print styles */
@media print {
    .experts-bar,
    .chat-input,
    .typing-indicator {
        display: none !important;
    }
    
    #esotericism-chat-container {
        border: none;
        box-shadow: none;
        background: white;
    }
    
    .chat-messages {
        height: auto;
        overflow: visible;
    }
}