/* ============================================
   CHAT AI PAGE STYLES
   Mandataire Auto - Assistant IA
   ============================================ */

:root {
    --primary: #00D9A5;
    --primary-dark: #00B88A;
    --bg-dark: #0a0f1c;
    --bg-card: #111827;
    --bg-input: #1a2234;
    --bg-message: #1e293b;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --border-color: #2d3748;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --ai-purple: #8B5CF6;
    --ai-blue: #3B82F6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon { font-size: 24px; }
.logo-text { font-size: 20px; font-weight: 700; }
.logo-accent { color: var(--primary); }

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--text-primary); }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
}

.nav-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: var(--bg-dark);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

/* ============================================
   CHAT PAGE LAYOUT
   ============================================ */

.chat-page {
    padding-top: 60px;
    height: 100vh;
}

.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 60px);
}

/* ============================================
   SIDEBAR
   ============================================ */

.chat-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 12px;
    color: var(--text-secondary);
}

.agents-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.agent-btn:hover {
    border-color: var(--border-color);
    background: var(--bg-message);
}

.agent-btn.active {
    border-color: var(--primary);
    background: rgba(0, 217, 165, 0.1);
}

.agent-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-dark);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
}

.agent-avatar.large {
    width: 48px;
    height: 48px;
    font-size: 24px;
}

.status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.status-dot.online {
    background: var(--success);
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-desc {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.ai-indicator {
    width: 8px;
    height: 8px;
    background: var(--ai-purple);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   CHAT MAIN
   ============================================ */

.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.chat-header {
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-agent {
    display: flex;
    align-items: center;
    gap: 16px;
}

.agent-details h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.agent-status .status-dot {
    position: static;
    width: 8px;
    height: 8px;
    border: none;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-message);
    color: var(--text-primary);
}

/* ============================================
   CHAT MESSAGES
   ============================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: var(--bg-dark);
}

.message-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-dark);
    border: none;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
}

.message-text p {
    margin-bottom: 8px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-text li {
    margin-bottom: 4px;
}

.message-text strong {
    color: var(--primary);
}

.message.user .message-text strong {
    color: var(--bg-dark);
}

.message-time {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.message.user .message-time {
    color: rgba(0, 0, 0, 0.5);
}

/* Quick suggestions */
.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 48px;
}

.suggestion-btn {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    border-color: var(--primary);
    background: rgba(0, 217, 165, 0.1);
}

/* Code blocks in messages */
.message-text pre {
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text code {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
}

/* Tables in messages */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.message-text th,
.message-text td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
    font-size: 13px;
}

.message-text th {
    background: var(--bg-input);
}

/* ============================================
   CHAT INPUT
   ============================================ */

.chat-input-area {
    padding: 16px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 16px;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--primary);
}

.attach-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.attach-btn:hover {
    opacity: 1;
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: var(--bg-dark);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 8px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.char-count {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ============================================
   LOADING STATE
   ============================================ */

.message.loading .message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: loadingDot 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        display: none;
    }

    .nav-links {
        display: none;
    }

    .message {
        max-width: 95%;
    }

    .quick-suggestions {
        padding: 0;
    }
}

