/* ============================================
   TEAM R.A.T — Design System
   Cockpit marketing premium, 3 agents
   ============================================ */

:root {
    /* Surfaces */
    --bg-deep: #0A0D14;
    --bg-base: #0E1218;
    --bg-elevated: #151B24;
    --bg-card: #1A2230;
    --bg-input: #0C1119;
    --border: #232C3D;
    --border-strong: #2F3B52;

    /* Texte */
    --text-primary: #E8ECF3;
    --text-secondary: #A4ADBF;
    --text-muted: #6B7388;
    --text-dim: #4A5165;

    /* Agents — chacun sa signature couleur */
    --romain: #7C5CFF;       /* Indigo — stratégie */
    --romain-soft: #7C5CFF1A;
    --ania: #FF8B5C;          /* Coral — créatif */
    --ania-soft: #FF8B5C1A;
    --tibot: #34D399;         /* Emerald — conversion */
    --tibot-soft: #34D3991A;

    /* États */
    --hot: #F87171;
    --warm: #FBBF24;
    --cold: #60A5FA;
    --success: #34D399;

    /* Typo */
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    /* Tailles */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    /* Transitions */
    --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --t: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT — 3 panneaux
   ============================================ */
.app {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    height: 100vh;
    background:
        radial-gradient(1200px 600px at 20% -10%, var(--romain-soft), transparent 50%),
        radial-gradient(1000px 500px at 100% 100%, var(--tibot-soft), transparent 50%),
        var(--bg-deep);
}

/* ============================================
   SIDEBAR GAUCHE
   ============================================ */
.sidebar {
    background: rgba(14, 18, 24, 0.7);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}

.brand {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

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

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.brand-dot:nth-child(1) { background: var(--romain); }
.brand-dot:nth-child(2) { background: var(--ania); }
.brand-dot:nth-child(3) { background: var(--tibot); }

.brand-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 500;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 20px;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 8px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--t-fast);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-footer strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============================================
   PANNEAU CENTRAL — Chat mission
   ============================================ */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(10, 13, 20, 0.4);
}

.main-header {
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.mission-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.mission-title h1 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.3px;
}

.mission-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
    animation: pulse 2s ease-in-out infinite;
}

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

.agent-modes {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--t-fast);
    font-family: inherit;
    font-weight: 500;
}

.mode-btn:hover { color: var(--text-primary); }

.mode-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Chat container */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    scroll-behavior: smooth;
}

.welcome {
    max-width: 720px;
    margin: 40px auto;
    text-align: center;
}

.welcome-hero {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: 16px;
}

.welcome-hero em {
    font-style: italic;
    background: linear-gradient(135deg, var(--romain), var(--ania), var(--tibot));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-sub {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 540px;
    margin: 0 auto 32px;
    line-height: 1.6;
}

.agent-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.agent-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: left;
    transition: var(--t);
}

.agent-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.agent-card-romain { border-top: 2px solid var(--romain); }
.agent-card-ania { border-top: 2px solid var(--ania); }
.agent-card-tibot { border-top: 2px solid var(--tibot); }

.agent-card-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 4px;
}

.agent-card-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.agent-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.starter-prompts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto;
}

.starter {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    transition: var(--t-fast);
    line-height: 1.5;
}

.starter:hover {
    background: var(--bg-card);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.starter-cmd {
    font-family: var(--font-mono);
    color: var(--romain);
    font-size: 11px;
    display: block;
    margin-bottom: 2px;
}

/* Messages */
.msg {
    max-width: 820px;
    margin: 0 auto 28px;
    animation: fadeIn 0.3s ease;
}

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

.msg-user {
    display: flex;
    justify-content: flex-end;
}

.msg-user .msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    padding: 12px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    max-width: 75%;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.msg-assistant {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    position: relative;
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.team-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.team-badge-dots {
    display: flex;
    gap: 3px;
}

.team-badge-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.team-badge-dots span:nth-child(1) { background: var(--romain); }
.team-badge-dots span:nth-child(2) { background: var(--ania); }
.team-badge-dots span:nth-child(3) { background: var(--tibot); }

.msg-meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

.msg-content {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.7;
}

.msg-content h1, .msg-content h2, .msg-content h3 {
    font-family: var(--font-display);
    font-weight: 400;
    margin: 20px 0 10px;
    color: var(--text-primary);
}

.msg-content h1 { font-size: 22px; }
.msg-content h2 { font-size: 18px; }
.msg-content h3 { font-size: 16px; }

.msg-content h2:has(+ *)::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 14px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
    background: var(--text-muted);
}

.msg-content strong { color: var(--text-primary); font-weight: 600; }

.msg-content p { margin: 8px 0; }

.msg-content ul, .msg-content ol {
    margin: 8px 0 8px 20px;
    color: var(--text-secondary);
}

.msg-content li { margin: 4px 0; }

.msg-content code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ania);
}

.msg-content pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
}

.msg-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
}

.msg-content blockquote {
    border-left: 3px solid var(--romain);
    padding-left: 14px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Sections multi-agents dans la réponse */
.msg-content h2:has-text("Romain"),
.msg-content h2:has-text("ROMAIN") { color: var(--romain); }

/* Typing indicator */
.typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

/* Composer */
.composer {
    border-top: 1px solid var(--border);
    padding: 20px 28px;
    background: rgba(14, 18, 24, 0.6);
    backdrop-filter: blur(10px);
}

.composer-inner {
    max-width: 820px;
    margin: 0 auto;
}

.composer-commands {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cmd-chip {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    transition: var(--t-fast);
}

.cmd-chip:hover {
    background: var(--bg-card);
    color: var(--romain);
    border-color: var(--romain);
}

.composer-input {
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    transition: var(--t-fast);
}

.composer-input:focus-within {
    border-color: var(--romain);
    box-shadow: 0 0 0 3px var(--romain-soft);
}

.composer-input textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
}

.composer-input textarea::placeholder { color: var(--text-muted); }

.send-btn {
    background: var(--text-primary);
    color: var(--bg-deep);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: var(--t-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.send-btn:hover:not(:disabled) {
    background: white;
    transform: translateY(-1px);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.composer-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

.composer-hint kbd {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 10px;
}

/* ============================================
   PANNEAU DROIT — Mission control
   ============================================ */
.aside {
    background: rgba(14, 18, 24, 0.6);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
}

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

.aside-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aside-title::before {
    content: '';
    width: 8px;
    height: 1px;
    background: var(--text-muted);
}

.campaign-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.campaign-card .name {
    font-family: var(--font-display);
    font-size: 17px;
    margin-bottom: 4px;
}

.campaign-card .meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.kpi {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.kpi-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--text-primary);
}

.kpi-delta {
    font-size: 10px;
    color: var(--success);
    margin-top: 2px;
}

.lead-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    margin-bottom: 6px;
    cursor: pointer;
    transition: var(--t-fast);
}

.lead-item:hover {
    background: var(--bg-card);
}

.lead-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--romain), var(--ania));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.lead-info { flex: 1; min-width: 0; }

.lead-name {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-source {
    font-size: 10px;
    color: var(--text-muted);
}

.lead-score {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.lead-score.hot {
    background: rgba(248, 113, 113, 0.15);
    color: var(--hot);
}

.lead-score.warm {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warm);
}

.lead-score.cold {
    background: rgba(96, 165, 250, 0.15);
    color: var(--cold);
}

.action-card {
    background: linear-gradient(135deg, var(--romain-soft), transparent);
    border: 1px solid var(--romain);
    border-left-width: 3px;
    border-radius: var(--radius);
    padding: 12px 14px;
}

.action-card .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--romain);
    margin-bottom: 4px;
    font-weight: 600;
}

.action-card .text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Responsive */
@media (max-width: 1280px) {
    .app { grid-template-columns: 240px 1fr 280px; }
}

@media (max-width: 1024px) {
    .app { grid-template-columns: 240px 1fr; }
    .aside { display: none; }
}

@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .welcome-hero { font-size: 36px; }
    .agent-cards { grid-template-columns: 1fr; }
    .starter-prompts { grid-template-columns: 1fr; }
    .main-header { padding: 14px 18px; flex-wrap: wrap; }
    .chat { padding: 18px; }
    .composer { padding: 14px 18px; }
}

/* Police de chargement (Google Fonts en fallback) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap');
