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

* {
    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: linear-gradient(135deg, #f8f4f9 0%, #ffffff 100%);
    color: #2c2c2c;
    line-height: 1.6;
}

/* Header */
.header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    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;
    align-items: center;
    gap: 8px;
}

/* Hero Section */
.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px 40px;
    text-align: center;
}

.hero h1 {
    font-size: 48px;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero .highlight {
    color: var(--rose-vibrant);
}

.hero p {
    font-size: 20px;
    color: #666;
    margin-bottom: 40px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 13px;
    color: #666;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-top: 16px;
}

.trust-icon {
    color: #4CAF50;
    font-size: 16px;
}

/* Main Layout */
.main-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 24px;
    padding: 0 20px 60px;
}

/* Sidebar */
.sidebar {
    display: none;
}

.sidebar-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    position: sticky;
    top: 100px;
}

/* Mobile Drawer */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    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;
    align-items: center;
}

.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-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.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;
    align-items: center;
    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 {
    background: white;
    border-color: var(--rose-vibrant);
    color: #2c2c2c;
}

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

/* Chat Container */
.chat-container {
    flex: 1;
    max-width: 900px;
}

.chat-box {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    overflow: hidden;
}

.chat-welcome {
    padding: 32px;
    background: linear-gradient(135deg, var(--rose-vibrant) 0%, #d4176b 100%);
    color: white;
    text-align: center;
}

.chat-welcome h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
}

.chat-welcome p {
    font-size: 16px;
    opacity: 0.95;
}

.chat-messages {
    padding: 32px;
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    transition: min-height 0.4s ease, max-height 0.4s ease, padding 0.3s ease;
}

/* État initial compact (avant premier message) */
.chat-box--initial .chat-messages {
    min-height: 0;
    max-height: 0;
    padding: 0 32px;
    overflow: hidden;
}

.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 */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    background: var(--rose-poudre);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
}

.typing-indicator.active {
    display: flex;
}

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

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

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

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

/* Chat Input */
.chat-input-area {
    padding: 24px;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    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);
}

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

.send-button {
    background: var(--digital-rose);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    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;
    margin-top: 24px;
}

.export-button {
    background: var(--rose-poudre);
    border: 2px solid var(--rose-vibrant);
    color: var(--rose-vibrant);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    transition: all 0.3s;
    font-family: var(--font-main);
}

.export-button:hover {
    background: var(--rose-vibrant);
    color: white;
    transform: scale(1.02);
}

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

.export-button:disabled:hover {
    background: var(--rose-poudre);
    color: var(--rose-vibrant);
    transform: none;
}

/* Suggestions */
.suggestions {
    padding: 24px;
    background: white;
    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;
}

.suggestion-clarify {
    background: #f0f4ff;
    border-color: rgba(91, 124, 255, 0.3);
}

.suggestion-clarify:hover {
    background: #5b7cff;
    border-color: #5b7cff;
}

/* Modules Section */
.modules-section {
    max-width: 1200px;
    margin: 60px auto;
    padding: 0 20px;
}

.modules-header {
    text-align: center;
    margin-bottom: 40px;
}

.modules-header h2 {
    font-size: 36px;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 12px;
}

.modules-header p {
    font-size: 18px;
    color: #666;
}

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

.module-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    position: relative;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(227, 28, 121, 0.15);
    border-color: var(--rose-vibrant);
}

.module-card.expanded {
    border-color: var(--rose-vibrant);
    box-shadow: 0 8px 24px rgba(227, 28, 121, 0.2);
}

.module-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--rose-vibrant), var(--digital-rose));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.module-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 8px;
}

.module-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.module-content {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.module-content.visible {
    display: block;
}

.module-content ul {
    margin: 0;
    padding-left: 20px;
}

.module-content li {
    font-size: 14px;
    color: #666;
    line-height: 1.8;
    margin-bottom: 8px;
}

.module-arrow {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 20px;
    color: var(--rose-vibrant);
    transition: transform 0.3s;
}

.module-card.expanded .module-arrow {
    transform: rotate(180deg);
}

/* Footer */
.footer {
    background: white;
    padding: 40px 20px;
    text-align: center;
    border-top: 1px solid #f0f0f0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.footer-links a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--rose-vibrant);
}

.footer-text {
    font-size: 14px;
    color: #999;
}

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

    .powered-by {
        display: none;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 32px;
    }

    .hero p {
        font-size: 18px;
    }

    .chat-welcome h2 {
        font-size: 24px;
    }

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

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

    .main-layout {
        padding: 0 16px 40px;
    }

    .modules-header h2 {
        font-size: 28px;
    }

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

    .module-card {
        padding: 20px;
    }

    .module-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .module-title {
        font-size: 18px;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        display: block;
        width: 280px;
        flex-shrink: 0;
    }
}

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

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    background: white;
    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;
}
