/**
 * ChatVraivexSEO - Styles
 * Design cohérent avec le reste du site Vraivex Audit
 */

/* Variables Vraivex */
:root {
    --primary: #1A5DC9;
    --primary-dark: #0f4299;
    --primary-light: #3d7edb;
    --success: #34A853;
    --warning: #FBBC05;
    --danger: #EA4335;
    --dark: #202124;
    --gray: #5f6368;
    --light-gray: #f8f9fa;
    --border: #e5e7eb;
    --white: #ffffff;
    --bg-main: #f9fafb;
}

/* Main Layout */
.chat-main {
    padding-top: 80px;
    min-height: 100vh;
    background: var(--bg-main);
}

.chat-layout {
    display: flex;
    height: calc(100vh - 80px);
    max-width: 1600px;
    margin: 0 auto;
}

/* ==================== SIDEBAR ==================== */
.chat-sidebar {
    width: 320px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 16px;
}

.btn-new-chat {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(26, 93, 201, 0.3);
}

.btn-new-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 93, 201, 0.4);
}

.btn-new-chat span {
    font-size: 18px;
    font-weight: 400;
}

/* Site Selector */
.site-selector-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.site-selector-section label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.site-select {
    width: 100%;
    padding: 12px 14px;
    background: var(--light-gray);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--dark);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.site-select:hover {
    border-color: var(--primary-light);
}

.site-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 93, 201, 0.15);
}

.site-info {
    margin-top: 14px;
    padding: 14px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f0fe 100%);
    border-radius: 10px;
    border: 1px solid rgba(26, 93, 201, 0.1);
}

.site-info:empty {
    display: none;
}

.site-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.site-info-item:first-child {
    margin-bottom: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(26, 93, 201, 0.1);
}

.site-info-item:first-child strong {
    color: var(--primary);
    font-size: 14px;
}

.info-label {
    color: var(--gray);
}

.info-value {
    font-weight: 600;
    color: var(--dark);
}

.info-value.score-excellent { color: var(--success); }
.info-value.score-good { color: var(--primary); }
.info-value.score-average { color: var(--warning); }
.info-value.score-poor { color: var(--danger); }

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.no-conversations {
    text-align: center;
    padding: 30px 20px;
    color: var(--gray);
}

.no-conversations p {
    font-size: 14px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 6px;
}

.conversation-item:hover {
    background: var(--light-gray);
}

.conv-icon {
    font-size: 18px;
}

.conv-details {
    flex: 1;
    min-width: 0;
}

.conv-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-preview {
    font-size: 12px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== CHAT AREA ==================== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--white);
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.welcome-content {
    max-width: 800px;
    text-align: center;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-content h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--gray);
    margin-bottom: 40px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.feature-card {
    background: var(--light-gray);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    text-align: left;
    transition: all 0.3s ease;
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(26, 93, 201, 0.15);
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
}

.feature-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
}

.feature-card p {
    font-size: 14px;
    color: var(--gray);
    line-height: 1.5;
}

/* Suggestions */
.suggestions-section {
    margin-top: 20px;
    display: none;
}

.suggestions-title {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 16px;
    font-weight: 500;
}

.suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.suggestion-btn {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 25px;
    padding: 10px 18px;
    color: var(--dark);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 300px;
    text-align: left;
}

.suggestion-btn:hover {
    background: var(--light-gray);
    border-color: var(--primary);
    color: var(--primary);
}

/* Select Site Prompt */
.select-site-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 2px dashed #fb923c;
    border-radius: 16px;
    margin-top: 30px;
}

.select-site-prompt span {
    font-size: 32px;
}

.select-site-prompt p {
    color: #c2410c;
    font-size: 15px;
    font-weight: 500;
}

/* ==================== MESSAGES ==================== */
.messages-container {
    flex: 1;
    display: none;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    gap: 20px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
}

.message.user .message-avatar {
    background: var(--success);
    border: none;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.message.user .message-header {
    flex-direction: row-reverse;
}

.message-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.message-time {
    font-size: 12px;
    color: var(--gray);
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--dark);
    background: var(--light-gray);
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.message.user .message-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
}

.message.assistant .message-text {
    background: var(--white);
    border: 1px solid var(--border);
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text h2, .message-text h3, .message-text h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary);
}

.message.user .message-text h2,
.message.user .message-text h3,
.message.user .message-text h4 {
    color: white;
}

.message-text ul, .message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 6px;
}

.message-text code {
    background: rgba(26, 93, 201, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--primary-dark);
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message-text pre {
    background: #1e293b;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
}

.message-text strong {
    font-weight: 700;
}

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

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite both;
}

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

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

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

/* ==================== INPUT AREA ==================== */
.input-area {
    padding: 20px;
    background: var(--white);
    border-top: 1px solid var(--border);
}

/* Attachments Preview */
.attachments-preview {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--light-gray);
    border-radius: 12px;
    margin-bottom: 12px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    position: relative;
}

.attachment-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.attachment-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-gray);
    border-radius: 6px;
}

.attachment-info {
    display: flex;
    flex-direction: column;
}

.attachment-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--dark);
}

.attachment-size {
    font-size: 11px;
    color: var(--gray);
}

.attachment-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.attachment-remove:hover {
    background: #c53030;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--light-gray);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    transition: all 0.2s ease;
    max-width: 900px;
    margin: 0 auto;
}

.input-wrapper.drag-over {
    border-color: var(--primary);
    background: rgba(26, 93, 201, 0.05);
}

/* Attach Button */
.attach-btn {
    width: 44px;
    height: 44px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: var(--light-gray);
    border-color: var(--primary);
    color: var(--primary);
}

.attach-btn svg {
    width: 20px;
    height: 20px;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26, 93, 201, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--dark);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 200px;
}

.input-wrapper textarea:focus {
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: var(--gray);
}

.input-wrapper textarea:disabled {
    opacity: 0.5;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(26, 93, 201, 0.4);
}

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

.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--gray);
    margin-top: 12px;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 1000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--gray);
    font-size: 15px;
    font-weight: 500;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .chat-sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 80px);
    }
    
    .chat-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 300px;
        overflow-y: auto;
    }
    
    .chat-area {
        min-height: 500px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .welcome-content h1 {
        font-size: 28px;
    }
    
    .welcome-icon {
        font-size: 48px;
    }
    
    .message {
        padding: 0 10px;
    }
    
    .input-area {
        padding: 15px;
    }
    
    #mobile-menu-toggle {
        display: block !important;
    }
    
    .nav-links {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .chat-main {
        padding-top: 70px;
    }
    
    .chat-layout {
        height: calc(100vh - 70px);
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .message {
        gap: 10px;
    }
    
    .feature-card {
        padding: 16px;
    }
    
    .suggestion-btn {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* Scrollbar */
.chat-sidebar::-webkit-scrollbar,
.messages-container::-webkit-scrollbar,
.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.chat-sidebar::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track,
.conversations-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-sidebar::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb,
.conversations-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-sidebar::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover,
.conversations-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}
