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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background: #1a1a2e;
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.nav-brand {
  font-size: 18px;
  font-weight: 600;
}

.nav-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.doc-badge {
  background: #16213e;
  color: #a8d8ea;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.nav-link {
  color: #a8d8ea;
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover {
  color: white;
}

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.login-header p {
  color: #666;
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
}

.form-group input[type="password"],
.form-group input[type="file"],
.form-group input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #1a1a2e;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: #1a1a2e;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #16213e;
}

.error-message {
  background: #fde8e8;
  color: #c0392b;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
}

.success-message {
  background: #e8fde8;
  color: #27ae60;
  padding: 10px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
  text-align: center;
}

/* Chat */
.chat-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message.bot .message-avatar {
  background: #e8f0fe;
}

.message.user .message-avatar {
  background: #1a1a2e;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
}

.message.bot .message-content {
  background: white;
  border: 1px solid #e0e0e0;
  border-top-left-radius: 4px;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 12px 0 6px;
  font-size: inherit;
  font-weight: 600;
}

.message-content h1 { font-size: 17px; }
.message-content h2 { font-size: 16px; }
.message-content h3 { font-size: 15px; }

.message-content ul,
.message-content ol {
  margin: 6px 0;
  padding-left: 22px;
}

.message-content li {
  margin: 3px 0;
}

.message-content p {
  margin: 6px 0;
}

.message-content p:first-child {
  margin-top: 0;
}

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

.message-content code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.message-content pre {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
}

.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

.message-content blockquote {
  border-left: 3px solid #1a1a2e;
  padding-left: 12px;
  margin: 8px 0;
  color: #555;
}

.message.user .message-content {
  background: #1a1a2e;
  color: white;
  border-top-right-radius: 4px;
}

.typing {
  color: #999;
  font-style: italic;
}

.chat-input-container {
  padding: 16px 0;
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 8px;
}

#message-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
}

#message-input:focus {
  outline: none;
  border-color: #1a1a2e;
}

#send-btn {
  padding: 14px 24px;
  background: #1a1a2e;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

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

/* Admin */
.admin-layout {
  max-width: 700px;
  width: 100%;
  margin: 24px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.admin-card h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.admin-card p {
  color: #666;
  font-size: 14px;
  margin-bottom: 16px;
}

.file-list {
  list-style: none;
}

.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.file-name {
  font-size: 14px;
}

.btn-delete {
  padding: 4px 12px;
  background: #fee;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.btn-delete:hover {
  background: #fdd;
}

.empty-state {
  color: #999;
  font-style: italic;
}

/* ─── Résultats d'upload ──────────────────────────────────────────────── */
.result-list {
  list-style: none;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.result-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.result-ok .result-icon { color: #27ae60; }
.result-err .result-icon { color: #c0392b; }

.result-name {
  flex: 1;
  word-break: break-all;
}

.result-detail {
  color: #666;
  font-size: 13px;
  white-space: nowrap;
}

/* ─── Formulaire URL ──────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group-half {
  flex: 1;
  margin-bottom: 0;
}

.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.form-group select:focus {
  outline: none;
  border-color: #1a1a2e;
}

/* ─── Sites web (arborescence) ────────────────────────────────────────── */
.crawl-group {
  margin-bottom: 8px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
}

.crawl-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8f9fa;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.crawl-header::-webkit-details-marker {
  margin-right: 4px;
}

.crawl-domain {
  font-weight: 600;
  flex: 1;
}

.crawl-meta {
  color: #666;
  font-size: 12px;
  white-space: nowrap;
}

.crawl-pages {
  list-style: none;
  border-top: 1px solid #e8e8e8;
}

.crawl-page {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 32px;
  font-size: 13px;
  border-bottom: 1px solid #f5f5f5;
}

.crawl-page:last-child {
  border-bottom: none;
}

.page-title {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-url {
  color: #999;
  font-size: 11px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sm {
  padding: 2px 8px;
  font-size: 11px;
}
