/**
 * KOAEE Research Mode - Style type Perplexity
 * Layout pleine page avec 90% largeur et scroll global
 */

/* ============================================
   LAYOUT WIDGET (Garder format widget)
   ============================================ */

/* Chat output avec scroll interne et largeur centrée à 90% */
#koaee_chat-output {
    max-width: 90% !important;
    width: 90% !important;
    margin: 0 auto !important;
    padding: 24px 32px 80px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    /* PAS de height: 100% - fullpage-mode gère avec flex */
}

/* Tous les messages centrés sur 100% de la largeur du container */
#koaee_chat-output > *,
#koaee_chat-output .koaee_message,
#koaee_chat-output .koaee_user,
#koaee_chat-output .koaee_gpt {
    max-width: 100% !important;
    width: 100% !important;
    align-self: center !important;
}

/* ============================================
   HEADER QUESTION (FORMAT PERPLEXITY)
   ============================================ */

.koaee_user {
    margin-bottom: 20px !important;
    text-align: center !important;
}

.koaee_message_content,
.koaee_user .koaee_message-container {
    font-size: 32px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.5px !important;
    color: #ffffff !important;
    margin-bottom: 16px !important;
    max-width: 800px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
}

/* Masquer messages marketing, welcome et bouton de fermeture */
#koaee_welcome-container,
.encryption-message,
.koaee_welcome-message,
#koaee_close-chat,
.koaee_chat-close-button {
    display: none !important;
}

/* ============================================
   TABS NAVIGATION
   ============================================ */

.koaee-tabs-navigation {
    display: flex;
    gap: 6px; /* Réduit de 8px à 6px */
    padding: 6px 0; /* Réduit de 8px à 6px */
    margin-bottom: 8px; /* Réduit de 10px à 8px */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    scrollbar-width: none;
}

.koaee-tabs-navigation::-webkit-scrollbar {
    display: none;
}

.koaee-tab-button {
    display: flex;
    align-items: center;
    gap: 5px; /* Réduit de 6px à 5px */
    padding: 5px 10px; /* Réduit de 6px 12px à 5px 10px */
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px; /* Réduit de 13px à 12px */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.koaee-tab-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.koaee-tab-button.active {
    background: rgba(0, 166, 255, 0.1);
    border-color: rgba(0, 166, 255, 0.5);
    color: #00a6ff;
}

.koaee-tab-icon {
    font-size: 16px; /* Réduit de 18px à 16px */
    line-height: 1;
}

.koaee-tab-count {
    opacity: 0.7;
}

/* ============================================
   CAROUSEL IMAGES (Widget Format)
   ============================================ */

.koaee-image-carousel {
    position: relative;
    margin-bottom: 8px; /* Réduit de 12px à 8px */
}

.koaee-carousel-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 4px 0;
}

.koaee-carousel-scroll::-webkit-scrollbar {
    display: none;
}

.koaee-carousel-image {
    flex: 0 0 auto;
    width: 240px;
    height: 120px;
    border-radius: 0;
    border: none !important;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    transition: opacity 0.2s;
}

.koaee-carousel-image:hover {
    opacity: 0.92;
}

.koaee-carousel-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.koaee-carousel-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    color: #000;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    z-index: 10;
}

.koaee-carousel-arrow:hover {
    background: white;
    transform: translateY(-50%) scale(1.05);
}

/* ============================================
   RÉPONSE FORMATÉE (Widget Format)
   ============================================ */

.koaee-response-final {
    font-size: 15px !important;
    line-height: 1.6 !important;
    color: #ffffff !important;
}

.koaee-response-final h1,
.koaee-response-final h2 {
    font-size: 22px !important;
    font-weight: 700 !important;
    margin: 28px 0 14px !important;
    letter-spacing: -0.3px !important;
    line-height: 1.3 !important;
}

.koaee-response-final h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 20px 0 10px !important;
}

.koaee-response-final p {
    font-size: 15px !important;
    line-height: 1.6 !important;
    margin-bottom: 12px !important;
    color: #ffffff !important;
}

.koaee-response-final em {
    font-family: 'STIX Two Math', 'Latin Modern Math', serif;
    font-style: italic;
    font-weight: 500;
}

.koaee-response-final strong {
    font-weight: 600;
}

/* Listes */
.koaee-response-final ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.koaee-response-final li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.6;
}

.koaee-response-final li::before {
    content: '•';
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    flex-shrink: 0;
}

/* Formule centrée */
.koaee-response-final blockquote {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 0;
    margin: 24px 0;
    font-family: 'STIX Two Math', 'Latin Modern Math', serif;
    font-size: 24px;
    font-style: italic;
    border: none;
    background: transparent;
}

/* Variables mathématiques en italique avec font professionnelle */
.koaee-response-final em,
.koaee-response-final .variable,
.koaee-response-final code {
    font-family: 'STIX Two Math', 'Latin Modern Math', serif;
    font-style: italic;
    font-weight: 500;
}

/* Blocs de formules */
.koaee-response-final .formula-block,
.koaee-response-final .katex {
    font-family: 'STIX Two Math', 'Latin Modern Math', serif;
    font-size: 20px;
}

/* ============================================
   QUESTIONS OUVERTES
   ============================================ */

.koaee-followup-questions {
    margin: 40px 0 32px;
    padding-top: 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.koaee-questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.koaee-question-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    padding: 16px 20px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.koaee-question-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 183, 255, 0.4);
    color: #ffffff;
}

/* ============================================
   BOUTON EXPAND
   ============================================ */

.koaee-expand-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 40px auto 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.koaee-expand-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(2px);
    color: #ffffff;
}

/* ============================================
   MEDIA STRIP DANS RESEARCH MODE
   ============================================ */

.koaee-media-strip {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 0 40px 0 !important;
}

.koaee-images-scroll {
    gap: 16px !important;
}

.koaee-image-card {
    width: 280px !important;
    height: 186px !important;
    border: none !important;
    border-radius: 0 !important;
}

/* Badge sources adapté */
.koaee-sources-badge {
    position: static !important;
    display: inline-flex !important;
    margin-top: 16px !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1200px) {
    #koaee_chat-output {
        width: 95% !important;
        max-width: 95% !important;
        padding: 30px 40px !important;
    }
}

@media (max-width: 768px) {
    #koaee_chat-output {
        width: 100% !important;
        max-width: 100% !important;
        padding: 24px 20px !important;
    }

    .koaee_message_content,
    .koaee_user .koaee_message-container {
        font-size: 32px !important;
    }

    .koaee-response-final h1,
    .koaee-response-final h2 {
        font-size: 24px !important;
    }

    .koaee-response-final p {
        font-size: 16px !important;
    }

    .koaee-carousel-image {
        width: 240px !important;
        height: 160px !important;
    }
}

/* ============================================
   HEADER CHAT ADAPTÉ
   ============================================ */

.koaee_chat-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    backdrop-filter: blur(10px) !important;
    background: rgba(26, 26, 26, 0.95) !important;
}

/* ============================================
   INPUT EN BAS DU WIDGET
   ============================================ */

.koaee_chat-input {
    padding: 20px !important;
    background: rgba(26, 26, 26, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}
