/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:        #f5f6fa;
  --bg2:       #ffffff;
  --bg3:       #eef0f6;
  --border:    #dde1ea;
  --border2:   #ccd1dc;
  --accent:    #4f7cff;
  --accent2:   #3d62d4;
  --text:      #1a1e2e;
  --muted:     #6b7490;
  --success:   #2ec37c;
  --warning:   #e59a1a;
  --danger:    #d94444;
  --sidebar-w: 230px;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-img {
  max-width: 160px;
  height: auto;
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.logo-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.1em;
  line-height: 1.1;
}

.logo-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg3);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(79, 124, 255, 0.08);
  border-color: rgba(79, 124, 255, 0.2);
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Main ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 5;
}

.page-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.powered {
  font-size: 12px;
  color: var(--muted);
}

.powered strong { color: var(--accent); }

.content {
  padding: 32px;
  flex: 1;
}

/* ── Dot ────────────────────────────────────────────── */
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  flex-shrink: 0;
}

.dot.green { background: var(--success); box-shadow: 0 0 6px var(--success); }

/* ── Dashboard ──────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card:hover {
  border-color: var(--accent);
  background: var(--bg3);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 4px;
}

.card-label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
}

.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.card-tag {
  margin-top: 8px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(79,124,255,0.1);
  border: 1px solid rgba(79,124,255,0.2);
  border-radius: 4px;
  padding: 3px 8px;
  align-self: flex-start;
}

.status-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Two-col layout ─────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  height: calc(100vh - 130px);
}

.three-col {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 130px);
}

.three-col:not(:has(.compare-panel)) {
  grid-template-columns: 1fr 1fr;
}

/* ── Panel ──────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
}

/* ── Forms ──────────────────────────────────────────── */
.textarea, .form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}

.textarea:focus, .form-input:focus {
  border-color: var(--accent);
}

.textarea {
  flex: 1;
  min-height: 200px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

select.form-input {
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.btn-icon { font-size: 14px; }

.btn-copy {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.15s;
}

.btn-copy:hover { border-color: var(--accent); color: var(--accent); }

/* ── Result ─────────────────────────────────────────── */
.result-block {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
}

.letter-block {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ── Compare panel ──────────────────────────────────── */
.compare-panel {
  overflow-y: auto;
}

.compare-section {
  border-bottom: 1px solid var(--border);
}

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.compare-provider {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 4px;
}

.compare-provider.claude {
  background: rgba(204, 120, 50, 0.12);
  color: #cc7832;
  border: 1px solid rgba(204, 120, 50, 0.25);
}

.compare-provider.gpt {
  background: rgba(16, 163, 127, 0.1);
  color: #10a37f;
  border: 1px solid rgba(16, 163, 127, 0.25);
}

.btn-compare {
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-compare:hover { border-color: var(--accent); background: rgba(79, 124, 255, 0.05); }
.btn-compare:disabled { opacity: 0.6; cursor: not-allowed; }

.compare-body {
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
  flex: 1;
  overflow-y: auto;
}

.compare-error {
  color: var(--danger);
  font-style: italic;
}

.compare-empty {
  color: var(--muted);
  font-style: italic;
}

.query-block {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.query-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.query-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  max-height: 80px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.3;
}

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.alert-error {
  background: rgba(217,68,68,0.08);
  border: 1px solid rgba(217,68,68,0.25);
  color: var(--danger);
}

/* ── Extraction ─────────────────────────────────────── */
.extract-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  margin: 1px;
}

.extract-item {
  background: var(--bg2);
  padding: 14px 16px;
}

.extract-full { grid-column: 1 / -1; }

.extract-key {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.extract-val {
  font-size: 13px;
  color: var(--text);
}

.code-block {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 11.5px;
  color: var(--accent);
  overflow-x: auto;
  white-space: pre;
  margin: 0 16px 16px;
  max-height: 240px;
  overflow-y: auto;
}

/* ── Badges ─────────────────────────────────────────── */
.badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-faible  { background: rgba(46,195,124,0.1); color: var(--success); border: 1px solid rgba(46,195,124,0.2); }
.badge-moyen   { background: rgba(245,166,35,0.1);  color: var(--warning); border: 1px solid rgba(245,166,35,0.2); }
.badge-élevé   { background: rgba(217,68,68,0.08);   color: var(--danger);  border: 1px solid rgba(217,68,68,0.2); }

.badge-timer {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(79, 124, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(79, 124, 255, 0.2);
  margin-right: 6px;
}

.stats-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-tokens {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(46, 195, 124, 0.1);
  color: var(--success);
  border: 1px solid rgba(46, 195, 124, 0.2);
}

.badge-tokens-total {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(245, 166, 35, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 166, 35, 0.2);
}

.msg-timer {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  padding-left: 16px;
}

/* ── Chat ───────────────────────────────────────────── */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 0;
  color: var(--muted);
}

.chat-welcome-icon { font-size: 36px; color: var(--accent); opacity: 0.6; }
.chat-welcome-text { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--text); }
.chat-welcome-sub  { font-size: 13px; }

.chat-msg { display: flex; }
.msg-user      { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
}

.msg-user .msg-bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-assistant .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.typing { color: var(--muted); letter-spacing: 0.1em; }

.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-textarea {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
  min-height: 44px;
}

.chat-textarea:focus { border-color: var(--accent); }

/* ── Scrollbars ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.sidebar { box-shadow: 1px 0 4px rgba(0,0,0,0.05); }

/* ── Upload zone ───────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg3);
}

.upload-zone:hover, .upload-zone.upload-drag {
  border-color: var(--accent);
  background: rgba(79, 124, 255, 0.05);
}

.upload-zone.upload-has-file {
  border-color: var(--success);
  background: rgba(46, 195, 124, 0.05);
}

.upload-icon {
  font-size: 28px;
  color: var(--muted);
  margin-bottom: 8px;
}

.upload-text {
  font-size: 13px;
  color: var(--muted);
}

.upload-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.upload-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Auth pages ────────────────────────────────────────── */
.auth-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

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

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px 32px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.auth-logo {
  text-align: center;
  margin-bottom: 8px;
}

.auth-logo .logo-img {
  max-width: 140px;
}

.auth-subtitle {
  text-align: center;
  font-family: var(--font-head);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  padding: 13px 20px;
  font-size: 14px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link:hover {
  text-decoration: underline;
}

/* ── User info sidebar ─────────────────────────────────── */
.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(217, 68, 68, 0.08);
  color: var(--danger);
}
