/* ============================================================
   style.css — Chat Clone Dark Theme + Glassmorphism
   Couleurs Hostinity : #9a5bff / #2d3032
   ============================================================ */

:root {
    --primary:       #9a5bff;
    --primary-dark:  #7c3fe0;
    --primary-glow:  rgba(154, 91, 255, 0.25);
    --primary-soft:  rgba(154, 91, 255, 0.12);
    --bg-deep:       #0e0f11;
    --bg-base:       #141618;
    --bg-surface:    #1a1c20;
    --bg-glass:      rgba(26, 28, 32, 0.7);
    --bg-card:       rgba(30, 32, 38, 0.85);
    --border:        rgba(154, 91, 255, 0.15);
    --border-soft:   rgba(255, 255, 255, 0.06);
    --text-primary:  #f0f0f5;
    --text-secondary: #9a9bab;
    --text-muted:    #5a5b6e;
    --user-bg:       rgba(154, 91, 255, 0.15);
    --user-border:   rgba(154, 91, 255, 0.3);
    --success:       #3dd68c;
    --error:         #ff5b5b;
    --warning:       #f5a623;
    --code-bg:       #0d0e10;
    --radius-sm:     6px;
    --radius-md:     12px;
    --radius-lg:     18px;
    --radius-xl:     24px;
    --shadow:        0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg:     0 8px 48px rgba(0, 0, 0, 0.6);
    --font-main:     'Sora', 'Segoe UI', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
}

/* Fond animé */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 10% 10%, rgba(154,91,255,0.08) 0%, transparent 60%),
        radial-gradient(ellipse 50% 35% at 90% 90%, rgba(124,63,224,0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout principal ─────────────────────────────────────── */
#app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 12px;
}

/* ── Header ───────────────────────────────────────────────── */
#header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.header-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 16px var(--primary-glow);
    flex-shrink: 0;
}

.header-info { flex: 1; }
.header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-surface);
    border-radius: 20px;
    border: 1px solid var(--border-soft);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}
.status-dot.dot-ready    { background: var(--success); }
.status-dot.dot-thinking { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.dot-stream   { background: var(--primary); animation: pulse 0.7s infinite; }

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

/* Modèle select */
.model-select {
    padding: 5px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 11px;
    font-family: var(--font-main);
    cursor: pointer;
    outline: none;
}
.model-select:focus { border-color: var(--primary); }

/* Bouton clear */
.btn-clear {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 13px;
}
.btn-clear:hover { background: rgba(255,91,91,0.1); border-color: var(--error); color: var(--error); }

/* ── Zone chat ────────────────────────────────────────────── */
#chatArea {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#chatArea.drag-over::after {
    content: 'Déposer les fichiers ici';
    position: absolute;
    inset: 0;
    background: rgba(154,91,255,0.1);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--primary);
    z-index: 10;
}

#chatMessages {
    height: 100%;
    overflow-y: auto;
    padding: 8px 4px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
#chatMessages::-webkit-scrollbar { width: 4px; }
#chatMessages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Welcome ──────────────────────────────────────────────── */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    margin: auto 0;
}
.welcome-logo {
    font-size: 48px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px var(--primary-glow));
}
.welcome-message h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.welcome-message p { font-size: 13px; margin-bottom: 24px; }
.welcome-message strong { color: var(--primary); }

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.chip {
    padding: 7px 14px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--primary);
    font-size: 12px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover { background: var(--primary-glow); border-color: var(--primary); transform: translateY(-1px); }

/* ── Messages ─────────────────────────────────────────────── */
.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeInUp 0.25s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
}

.message-user .message-avatar  { background: var(--user-bg); border-color: var(--user-border); }

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

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.message-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.message-time { font-size: 10px; color: var(--text-muted); }

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    line-height: 1.7;
    word-break: break-word;
}

.message-user .message-content {
    background: var(--user-bg);
    border-color: var(--user-border);
    color: var(--text-primary);
}

.message-content h1, .message-content h2, .message-content h3 {
    color: var(--text-primary);
    font-weight: 700;
    margin: 12px 0 6px;
}
.message-content h1 { font-size: 18px; }
.message-content h2 { font-size: 16px; }
.message-content h3 { font-size: 14px; color: var(--primary); }
.message-content p  { margin: 6px 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 6px 0; }
.message-content li { margin: 3px 0; }
.message-content a  { color: var(--primary); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }
.message-content hr { border: none; border-top: 1px solid var(--border-soft); margin: 12px 0; }
.message-content strong { color: var(--text-primary); font-weight: 700; }

.msg-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    object-fit: contain;
    background: var(--bg-surface);
}

.file-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.file-badge {
    padding: 3px 8px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--primary);
}

/* Actions message */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .message-actions { opacity: 1; }
.action-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s;
}
.action-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--border); }

/* Curseur typing */
.typing-cursor::after {
    content: '▋';
    color: var(--primary);
    animation: blink 0.8s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Blocs de code ────────────────────────────────────────── */
.code-block {
    margin: 10px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--border);
}
.code-lang { font-size: 11px; color: var(--primary); font-family: var(--font-mono); font-weight: 600; text-transform: uppercase; }
.btn-copy {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover { background: var(--primary-glow); color: var(--primary); }
.code-block pre {
    margin: 0;
    padding: 14px;
    background: var(--code-bg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    color: #c9d1d9;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.code-block pre code { background: none; padding: 0; font-size: inherit; }
.inline-code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(154,91,255,0.1);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--primary);
}

/* Boutons téléchargement */
.download-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
}
.btn-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 12px;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 12px var(--primary-glow);
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(154,91,255,0.4); }
.btn-download:active { transform: translateY(0); }

/* ── Erreur ───────────────────────────────────────────────── */
.error-msg { color: var(--error); }

/* ── Zone input ───────────────────────────────────────────── */
#inputArea {
    flex-shrink: 0;
    padding: 8px 0 12px;
}

/* Prévisualisation fichiers */
#filePreview {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.file-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-primary);
}
.file-icon { font-size: 13px; }
.file-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--text-muted); font-size: 10px; }
.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}
.file-remove:hover { color: var(--error); }

/* Input wrapper */
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#filePreview[style*="flex"] + .input-wrapper {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

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

.btn-attach {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}
.btn-attach:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--border); }

.input-inner { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

#userInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 22px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}
#userInput::placeholder { color: var(--text-muted); }

.input-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
}
.char-count { margin-left: auto; }

.input-actions {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.btn-stop {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255,91,91,0.1);
    border: 1px solid rgba(255,91,91,0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.btn-stop:hover { background: rgba(255,91,91,0.2); }

.btn-send {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 10px var(--primary-glow);
    flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(154,91,255,0.5); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    #app { padding: 0 6px; }
    .header-subtitle { display: none; }
    .model-select { max-width: 110px; }
    .welcome-message { padding: 24px 12px; }
    .message { gap: 8px; }
    .message-content { padding: 10px 12px; font-size: 13px; }
}
