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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #1a2332;
    --bg-input: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #f59e0b;
    --success: #22c55e;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* LOGIN */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--bg-card); border-radius: 16px; padding: 48px; max-width: 400px; width: 100%; text-align: center; border: 1px solid var(--border); }
.login-logo { width: 80px; margin-bottom: 24px; }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; color: var(--text); font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-card button { background: var(--primary); color: white; border: none; border-radius: 8px; padding: 12px; font-size: 16px; cursor: pointer; font-weight: 600; }
.login-card button:hover { background: var(--primary-hover); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* HEADER */
header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 36px; height: 36px; }
header h1 { font-size: 18px; font-weight: 600; }

/* LAYOUT */
main { display: flex; height: calc(100vh - 65px); }

/* SIDEBAR */
#sidebar { width: 280px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.comparatif-list { flex: 1; overflow-y: auto; padding: 8px; }
.comparatif-item { padding: 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; transition: background 0.15s; }
.comparatif-item:hover { background: var(--bg-input); }
.comparatif-item.active { background: var(--primary); }
.comparatif-item h3 { font-size: 14px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comparatif-item .meta { font-size: 12px; color: var(--text-muted); }
.comparatif-item.active .meta { color: rgba(255,255,255,0.7); }

/* EDITOR AREA */
#editor-area { flex: 1; overflow-y: auto; padding: 24px; }

/* EMPTY STATE */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; }
.empty-state h2 { font-size: 28px; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); max-width: 500px; margin-bottom: 32px; line-height: 1.6; }
.quick-start { display: flex; gap: 12px; width: 100%; max-width: 600px; }
.query-input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; color: var(--text); font-size: 15px; }
.query-input:focus { outline: none; border-color: var(--primary); }

/* EDITOR */
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.edit-title { background: transparent; border: none; color: var(--text); font-size: 24px; font-weight: 700; flex: 1; min-width: 200px; }
.edit-title:focus { outline: none; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.query-section { background: var(--bg-card); border-radius: 12px; padding: 20px; margin-bottom: 20px; border: 1px solid var(--border); }
.query-section label { font-size: 13px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 8px; }
.query-row { display: flex; gap: 8px; margin-bottom: 12px; }
.query-options { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.query-options input { width: 200px; }

select { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; }

.content-area { background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border); min-height: 400px; margin-bottom: 16px; }
.content-preview { padding: 32px; line-height: 1.8; font-size: 15px; }
.content-preview h1 { font-size: 28px; margin-bottom: 16px; color: var(--accent); }
.content-preview h2 { font-size: 22px; margin: 24px 0 12px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.content-preview h3 { font-size: 18px; margin: 16px 0 8px; }
.content-preview p { margin-bottom: 12px; color: var(--text); }
.content-preview ul, .content-preview ol { margin: 12px 0 12px 24px; }
.content-preview li { margin-bottom: 6px; }
.content-preview table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.content-preview th { background: var(--bg-input); padding: 10px 12px; text-align: left; font-size: 13px; text-transform: uppercase; color: var(--text-muted); }
.content-preview td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.content-preview .highlight { background: rgba(37, 99, 235, 0.1); border-left: 3px solid var(--primary); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 12px 0; }
.content-preview strong { color: var(--accent); }

.content-source { width: 100%; min-height: 400px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; color: var(--text); font-family: 'Fira Code', monospace; font-size: 14px; line-height: 1.6; resize: vertical; }

.editor-footer { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 13px; color: var(--success); }

/* BUTTONS */
.btn-primary { background: var(--primary); color: white; border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-large { padding: 14px 24px; font-size: 16px; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-danger:hover { background: var(--danger); color: white; }

/* LOADING */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; }
.spinner { width: 48px; height: 48px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* RESPONSIVE */
@media (max-width: 768px) {
    main { flex-direction: column; }
    #sidebar { width: 100%; height: auto; max-height: 200px; }
    .quick-start { flex-direction: column; }
    .query-row { flex-direction: column; }
    .toolbar-actions { justify-content: flex-start; }
}
