/* ==========================================================================
   Plateforme Audiens - Styles CSS
   ========================================================================== */

/* Police Inter auto-hébergée (RGPD compliant) */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/inter-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/inter-medium.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/inter-semibold.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/inter-bold.woff2') format('woff2');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Couleurs Audiens 2024 */
    --rose-vibrant: #e31c79;
    --rose-poudre: #f0e2f1;
    --dark-blue: #3a3e5b;
    --deep-grey: #262936;
    --pure-white: #ffffff;
    --digital-rose: #ff3592;

    /* Typographie */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

body {
    font-family: var(--font-main);
    background: #ffffff;
    color: #2c2c2c;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 110; /* Au-dessus de la sidebar */
}

.header-content {
    display: flex;
    justify-content: flex-start;
    padding-left: 20px;
}

.logo {
    display: flex;
    gap: 8px;
}

.logo-star {
    color: var(--rose-vibrant);
    font-size: 32px;
    line-height: 1;
}

.logo-text {
    color: var(--deep-grey);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.mobile-menu-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--deep-grey);
}

.powered-by {
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 8px;
}

/* Hero Section - SUPPRIMÉ (interface ouverte v2) */

/* ==========================================================================
   App Layout avec Sidebar
   ========================================================================== */

.app-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar Desktop - Position fixe */
.sidebar {
    width: 280px;
    background: #f9f9fb;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 72px;
    height: calc(100vh - 72px - 80px);
    overflow-y: auto;
    z-index: 100;
}

.sidebar.collapsed {
    left: -280px;
}

/* Décalage du contenu principal pour la sidebar fixe */
.app-layout {
    margin-left: 280px;
    transition: margin-left 0.3s ease;
}

/* Effet volet : recentrer le contenu quand sidebar fermée */
.app-layout:has(.sidebar.collapsed) {
    margin-left: 0;
}

/* Synchroniser le footer quand sidebar collapsed */
body:has(.sidebar.collapsed) .legal-footer {
    padding-left: 20px;
    margin-left: 0;
}

.sidebar-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Bouton toggle menu - caché sur desktop */
.menu-toggle-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--deep-grey);
    border-radius: 8px;
    transition: background 0.2s;
}

.menu-toggle-button:hover {
    background: #f0f0f0;
}

/* Accordéons */
.accordion {
    border-radius: 8px;
    overflow: hidden;
}

.accordion-header {
    border: 1px solid #e8e8e8;
    background: white;
    width: 100%;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--deep-grey);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    border-radius: 8px;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #f5f5f5;
}

.accordion-arrow {
    transition: transform 0.3s;
}

.accordion.open .accordion-arrow {
    transform: rotate(180deg);
}

.accordion-content {
    padding-top: 10px;
    background: transparent;
    border: none;
    max-height: 0;
    overflow: hidden;
    border-top: none;
    border-radius: 0 0 8px 8px;
    transition: max-height 0.3s ease;
}

.accordion.open .accordion-content {
    padding-top: 10px;
    background: transparent;
    border: none;
    max-height: 600px;
}

.accordion.open .accordion-header {
    border: 1px solid #e8e8e8;
    background: white;
    border-radius: 8px 8px 0 0;
}

.sidebar-link {
    background: rgba(227, 28, 121, 0.1);
    padding: 12px 16px;
    margin-bottom: 6px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-link:hover {
    background: rgba(227, 28, 121, 0.2);
}

/* ==========================================================================
   Chat Main - Interface ouverte (style Claude/ChatGPT)
   ========================================================================== */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* État initial centré (style Claude/ChatGPT) */
.welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.welcome-state.hidden {
    display: none;
}

.welcome-content {
    margin-bottom: 40px;
}

/* Avatar Nellie (welcome state) */
.nellie-avatar {
    width: 200px;
    height: auto;
    margin-bottom: 20px;
}

/* Avatar Nellie (messages bot) */
.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 12px;
    align-self: flex-start;
    margin-top: 4px;
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--deep-grey);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 28px;
    color: #666;
    font-weight: 700;
}

.welcome-input {
    width: 100%;
    max-width: 800px;
}

/* Masquer l'input du bas dans l'état initial */
.chat-main:has(.welcome-state:not(.hidden)) .chat-input-area {
    display: none;
}

/* Mobile Drawer */
.mobile-drawer {
    background: #f9f9fb;
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    box-shadow: 2px 0 16px rgba(0,0,0,0.1);
    z-index: 200;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.mobile-drawer.open {
    left: 0;
}

.mobile-drawer-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
}

.mobile-drawer-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--deep-grey);
}

.close-drawer-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--deep-grey);
    font-size: 24px;
    line-height: 1;
}

.mobile-drawer-content {
    padding: 20px;
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    display: none;
}

.drawer-overlay.active {
    display: block;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    gap: 8px;
}

.sidebar-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.sidebar-card {
    background: rgba(227, 28, 121, 0.1);
    border: none;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-card:hover {
    background: rgba(227, 28, 121, 0.2);
}

.new-chat-button {
    width: 100%;
    background: var(--digital-rose);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.new-chat-button:hover {
    background: var(--rose-vibrant);
    transform: scale(1.02);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px;
    background: var(--rose-poudre);
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.history-item:hover {
    border-color: var(--rose-vibrant);
    color: #2c2c2c;
}

.history-date {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Zone de messages - Interface ouverte */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.message {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
    animation: fadeInUp 0.4s ease;
}

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

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

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

.message-bubble {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
}

.message.bot .message-bubble {
    background: var(--rose-poudre);
    color: var(--deep-grey);
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: var(--deep-grey);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator - "Je réfléchis..." */
.typing-indicator {
    display: inline-block !important;
    padding: 16px 20px;
    background: var(--rose-poudre);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 15px;
    color: #333;
    font-style: italic;
}

.thinking-text {
    margin-right: 2px;
}

.thinking-dots span {
    opacity: 0;
    animation: thinking-dot 1.4s infinite;
}

.thinking-dots span:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.3s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes thinking-dot {
    0%, 20% {
        opacity: 0;
    }
    40%, 100% {
        opacity: 1;
    }
}

/* Zone de saisie - Interface ouverte */
.chat-input-area {
    padding: 20px 0 30px;
    border-top: 1px solid #f0f0f0;
}

.chat-input-container {
    max-width: 100%;
}

.input-wrapper {
    position: relative;
    display: flex;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 16px 20px;
    transition: all 0.3s;
}

.input-wrapper:focus-within {
    background: #fff;
    box-shadow: 0 0 0 3px rgba(233, 30, 122, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: #2c2c2c;
    outline: none;
    font-family: var(--font-main);
    resize: none;
    min-height: 24px;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-input::placeholder {
    color: #999;
}

.send-button {
    align-items: center;
    background: var(--digital-rose);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    transition: all 0.3s;
    margin-left: 12px;
}

.send-button:hover {
    background: var(--rose-vibrant);
    transform: scale(1.05);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Export Button */
.export-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.export-button {
    background: var(--digital-rose);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    gap: 6px;
    transition: background 0.2s;
    font-family: var(--font-main);
}

.export-button:hover {
    background: #c4166a;
}

.export-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Suggestions */
.suggestions {
    padding: 24px;
    border-top: 1px solid #f0f0f0;
}

.suggestions-title {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestions-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, 1fr);
}

.suggestion-pill {
    background: var(--rose-poudre);
    border: 1px solid rgba(227, 28, 121, 0.2);
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 15px;
    color: #2c2c2c;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.suggestion-pill:hover {
    background: var(--digital-rose);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 30, 122, 0.2);
}

/* Boutons suggestions cliquables (après réponse bot) */
.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.05);
    width: 100%;
    flex-basis: 100%;
}

.suggestion-btn {
    background: var(--rose-poudre);
    border: 1px solid rgba(227, 28, 121, 0.2);
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #2c2c2c;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.4;
}

.suggestion-btn:hover {
    background: var(--digital-rose);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(233, 30, 122, 0.25);
}

.suggestion-btn .suggestion-num {
    font-weight: 600;
    color: var(--digital-rose);
}

.suggestion-btn:hover .suggestion-num {
    color: white;
}

/* Modules Section - SUPPRIMÉ (interface ouverte v2) */

/* Footer - SUPPRIMÉ (interface ouverte v2) */

/* Responsive */
@media (max-width: 1023px) {
    .menu-toggle-button {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .app-layout {
        margin-left: 0;
    }

    .legal-footer {
        padding-left: 20px;
    }

    .powered-by {
        display: none;
    }
}

@media (max-width: 768px) {
    .legal-footer {
        padding: 16px 20px;
        text-align: center;
    }

    .legal-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 12px;
        width: 100%;
    }

    .legal-links a {
        display: block;
        text-align: center;
    }

    .legal-links .separator {
        display: none;
    }
    .welcome-title {
        font-size: 22px;
    }

    .welcome-subtitle {
        font-size: 22px;
    }

    .suggestions-grid {
        grid-template-columns: 1fr;
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-main {
        padding: 0 16px;
    }
}

/* Sidebar desktop - SUPPRIMÉ (interface ouverte v2) */

/* ==========================================================================
   Markdown Tables (marked.js)
   ========================================================================== */

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-bubble th,
.message-bubble td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.message-bubble th {
    background: var(--dark-blue);
    color: white;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-bubble tr:last-child td {
    border-bottom: none;
}

.message-bubble tr:nth-child(even) {
    background: #f9f9fb;
}

.message-bubble tr:hover {
    background: #f0e2f1;
}

/* Listes markdown */
.message-bubble ul,
.message-bubble ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-bubble li {
    margin: 6px 0;
}

/* Code inline */
.message-bubble code {
    background: #f4f4f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Titres dans les réponses - espacement avant */
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.message-bubble h2:first-child,
.message-bubble h3:first-child,
.message-bubble h4:first-child,
.message-bubble h5:first-child,
.message-bubble h6:first-child {
    margin-top: 0;
}

/* Disclaimer IA */
.ai-disclaimer {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 8px;
    line-height: 1.4;
}

/* Bouton microphone (reconnaissance vocale) */
.mic-button {
    align-items: center;
    background: transparent;
    color: #666; /* WCAG AA : ratio 5.74:1 */
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    transition: all 0.3s;
    margin-right: 4px;
}

.mic-button:hover {
    color: var(--digital-rose);
    background: rgba(255, 53, 146, 0.1);
}

.mic-button.listening {
    color: white;
    background: var(--digital-rose);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 53, 146, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(255, 53, 146, 0);
    }
}

/* Footer légal */
.legal-footer {
    padding: 16px 20px;
    padding-left: 300px; /* Aligné avec le chat (280px sidebar + 20px) */
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.legal-footer .copyright {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.legal-links {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
}

.legal-links a {
    color: #666;
    text-decoration: none;
    transition: color 0.2s;
}

.legal-links a:hover {
    color: var(--digital-rose);
}

.legal-links .separator {
    color: #ccc;
}

@media (max-width: 768px) {
    .legal-footer {
        padding: 16px 20px;
        text-align: center;
    }

    .legal-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 12px;
        width: 100%;
    }

    .legal-links a {
        display: block;
        text-align: center;
    }

    .legal-links .separator {
        display: none;
    }

}


/* Hidden utility class */
.hidden {
    display: none !important;
}






/* Welcome info - aligné comme le footer */
.welcome-info {
    padding: 15px 20px;
    padding-left: 300px;
    font-size: 11px;
    color: #999;
    text-align: center;
    line-height: 1.4;
}

.welcome-info strong {
    color: #e31c79;
    font-size: 13px;
    display: block;
    margin-bottom: 5px;
}

body:has(.sidebar.collapsed) .welcome-info {
    padding-left: 20px;
}

@media (max-width: 768px) {
    .welcome-info {
        padding-left: 20px;
    }
}
