:root {
  --dark: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3a;
  --accent: #4f6ef7;
  --accent-hover: #3d5ce0;
  --text: #e8eaf0;
  --muted: #7b7f95;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --font: 'Inter', system-ui, sans-serif;
}

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

body {
  background: var(--dark);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* AUTH */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-box h1 { font-size: 22px; margin-bottom: 8px; }
.auth-box .sub { color: var(--muted); margin-bottom: 28px; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px 14px;
  background: var(--dark); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 6px; font-size: 14px;
  font-weight: 500; cursor: pointer; border: none; transition: .15s;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.err-msg { color: #f87171; font-size: 12px; margin-top: 12px; text-align: center; }

/* LAYOUT APP */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  padding: 0 8px;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.sidebar-logo span { color: var(--text); }

.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 8px;
  margin: 12px 0 4px;
}

.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 13px;
  transition: .15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(79,110,247,.1); color: var(--accent);
}

.sidebar-ccn {
  margin-top: auto;
  padding: 12px;
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.sidebar-ccn .ccn-label { color: var(--muted); margin-bottom: 4px; }
.sidebar-ccn .ccn-name { color: var(--text); font-weight: 500; }

/* MAIN */
.main { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar .ccn-select select {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 7px 12px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
}

/* CHAT */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg { max-width: 760px; }

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px 12px 2px 12px;
  font-size: 14px;
  line-height: 1.5;
}

.msg-ia {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-ia-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 2px 12px 12px 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-tag {
  background: rgba(79,110,247,.12);
  border: 1px solid rgba(79,110,247,.25);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
}

.msg-disclaimer {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
}
.empty-state h3 { font-size: 20px; color: var(--text); }
.empty-state p { font-size: 13px; max-width: 400px; line-height: 1.6; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.suggestion {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: .15s;
}
.suggestion:hover { border-color: var(--accent); color: var(--accent); }

/* INPUT */
.chat-input-area {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  background: var(--dark);
}

.input-box {
  display: flex;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  align-items: flex-end;
  transition: .15s;
}
.input-box:focus-within { border-color: var(--accent); }

.input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  font-family: var(--font);
}

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

.send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}
.dot {
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce .9s infinite;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* SECTIONS */
.section { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.section.active { display: flex; }

/* HISTORIQUE */
.history-list { padding: 24px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.history-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: .15s;
}
.history-item:hover { border-color: var(--accent); }
.history-item .q { font-weight: 500; margin-bottom: 6px; }
.history-item .meta { color: var(--muted); font-size: 12px; }

/* UTILS */
.hidden { display: none !important; }
