/* ─── HECTOR Design System ─── */
/* Palette Québec : bleu #3B82F6 · blanc #F0F2F8 · fond #080B14 */

:root {
  --bg: #080B14;
  --bg-panel: #0C1020;
  --bg-card: #111628;
  --bg-elevated: #161C35;
  --bg-hover: #1B2240;
  --bg-input: #0E1325;
  --blue: #3B82F6;
  --blue-light: #60A5FA;
  --blue-bright: #93C5FD;
  --blue-dim: #1E3A6E;
  --blue-muted: #1E2D50;
  --blue-glow: #3B82F620;
  --white: #F0F2F8;
  --white-dim: #B8BDD0;
  --white-muted: #6B7194;
  --white-faint: #3D4466;
  --border: #1E2440;
  --border-light: #2A3355;
  --green: #34D399;
  --green-bg: #0D2D22;
  --yellow: #FBBF24;
  --yellow-bg: #2D2410;
  --red: #F87171;
  --red-bg: #2D1010;
  --accent: #818CF8;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--white);
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: 0; }

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--white);
}

.logo-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--white-muted);
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.sidebar-actions { padding: 16px; }

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--border-light);
  background: transparent;
  color: var(--white-dim);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-new-chat:hover {
  border-color: var(--blue);
  color: var(--blue-light);
  background: var(--blue-glow);
}

.sidebar-history {
  padding: 0 16px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--white-faint) transparent;
}

.history-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--white-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.history-item:hover {
  background: var(--bg-elevated);
}

.history-item.active {
  background: var(--bg-elevated);
  border-left: 2px solid var(--blue);
}

.history-item-title {
  font-size: 13px;
  color: var(--white-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item.active .history-item-title {
  color: var(--white);
}

.history-item-time {
  font-size: 10px;
  color: var(--white-faint);
  margin-top: 2px;
}

.history-empty {
  font-size: 12px;
  color: var(--white-faint);
  padding: 8px 12px;
  font-style: italic;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--white-muted);
}

.footer-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px #34D39960;
  animation: statusPulse 3s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 8px #34D39960; }
  50% { box-shadow: 0 0 14px #34D39980; }
}

/* ─── MAIN ─── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--white-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
}

.btn-icon:hover { color: var(--white); background: var(--bg-elevated); }

.powered-by {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--white-muted);
}

/* ─── MESSAGES ─── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--white-faint) transparent;
  scroll-behavior: smooth;
}

.messages {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 0;
}

/* ─── WELCOME ─── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
  padding: 40px 0;
}

.welcome-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #3B82F620, #3B82F605);
  border: 1px solid #3B82F620;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.welcome-logo span {
  font-family: 'Libre Baskerville', serif;
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome h1 {
  font-family: 'Libre Baskerville', serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.welcome p {
  font-size: 15px;
  color: var(--white-muted);
  margin-bottom: 44px;
  text-align: center;
  max-width: 440px;
  line-height: 1.6;
}

/* ─── SUGGESTIONS ─── */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 620px;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-card:hover {
  border-color: #3B82F640;
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

.suggestion-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.suggestion-cat {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.suggestion-bottom {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.suggestion-icon { font-size: 18px; flex-shrink: 0; }
.suggestion-text { font-size: 13px; color: var(--white-dim); line-height: 1.5; }

/* ─── MESSAGE BUBBLES ─── */
.message {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 32px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.avatar-user {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
}

.avatar-hector {
  background: linear-gradient(135deg, #3B82F630, #3B82F610);
  border: 1px solid #3B82F630;
  font-family: 'Libre Baskerville', serif;
  font-weight: 700;
  color: var(--blue-light);
}

.message-user-text {
  font-size: 15px;
  line-height: 1.7;
  padding-top: 5px;
}

.message-response { flex: 1; padding-top: 2px; min-width: 0; }

/* ─── BADGES ─── */
.badges { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.badge-quebec { background: #3B82F612; border: 1px solid #3B82F620; color: var(--blue-light); }
.badge-general { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--white-muted); }

.badge-confidence-high { background: var(--green-bg); border: 1px solid #34D39920; color: var(--green); }
.badge-confidence-medium { background: var(--yellow-bg); border: 1px solid #FBBF2420; color: var(--yellow); }
.badge-confidence-low { background: var(--red-bg); border: 1px solid #F8717120; color: var(--red); }

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

.confidence-dots { display: flex; gap: 3px; }
.confidence-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─── RESPONSE CONTENT ─── */
.response-intro {
  font-size: 15px;
  line-height: 1.85;
  margin-bottom: 16px;
}

/* Markdown dans les réponses */
.response-intro p {
  margin-bottom: 12px;
}

.response-intro p:last-child {
  margin-bottom: 0;
}

.response-intro strong {
  color: var(--white);
  font-weight: 600;
}

.response-intro em {
  color: var(--blue-bright);
  font-style: italic;
}

/* ─── ENTITY CARDS ─── */
.entity-cards {
  margin-bottom: 16px;
}

.entity-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  transition: all 0.3s;
  border-left: 3px solid #3B82F660;
  margin-bottom: 10px;
}

.entity-card:hover { background: var(--bg-hover); }

.entity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.entity-name { font-size: 15px; font-weight: 600; color: var(--blue-light); }

.entity-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--green-bg);
  color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.entity-detail { font-size: 13px; color: var(--white-dim); line-height: 1.7; }

.entity-specs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.entity-spec {
  padding: 4px 10px;
  border-radius: 5px;
  background: var(--blue-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--blue-bright);
}

/* ─── FOLLOW-UPS ─── */
.follow-ups-section { margin-bottom: 16px; }

.follow-ups-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--white-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.follow-ups { display: flex; gap: 8px; flex-wrap: wrap; }

.follow-up-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--white-dim);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.follow-up-btn:hover {
  border-color: #3B82F650;
  color: var(--blue-light);
  background: var(--bg-elevated);
}

/* ─── SOURCES ─── */
.sources-section { margin-top: 8px; }

.sources-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--white-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

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

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: default;
  transition: all 0.2s;
}

.source-pill:hover { border-color: #3B82F650; background: var(--bg-hover); }
.source-pill-name { font-size: 11px; color: var(--white-dim); }

.source-verified {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--green-bg);
  color: var(--green);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ─── TYPING ─── */
.typing { display: flex; align-items: center; gap: 4px; padding: 8px 0; }
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
.typing-label { font-size: 11px; color: var(--white-muted); margin-top: 4px; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

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

.fade-up { animation: fadeUp 0.5s ease forwards; }

/* ─── INPUT ─── */
.input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 4px 4px 4px 18px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper.focused {
  border-color: #3B82F660;
  box-shadow: 0 0 0 4px #3B82F610;
}

.input-sparkle { color: var(--white-faint); margin-right: 4px; padding-bottom: 10px; display: flex; }

#query-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 8px;
  min-height: 24px;
  max-height: 120px;
  scrollbar-width: none;
}

#query-input::placeholder { color: var(--white-faint); }

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--bg-elevated);
  color: var(--white-faint);
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  flex-shrink: 0;
}

.btn-send.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-dim));
  color: var(--white);
  cursor: pointer;
}

.btn-send.active:hover {
  box-shadow: 0 0 16px #3B82F640;
}

.input-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--white-muted);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.collapsed {
    width: 0;
    box-shadow: none;
  }

  .suggestions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .welcome h1 {
    font-size: 22px;
    padding: 0 16px;
  }

  .welcome p {
    font-size: 14px;
    padding: 0 16px;
  }

  .messages-container {
    padding: 0 16px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .topbar {
    padding: 0 16px;
  }

  .powered-by {
    font-size: 10px;
  }

  .entity-specs {
    flex-direction: column;
    gap: 4px;
  }

  .follow-ups {
    flex-direction: column;
  }

  .follow-up-btn {
    width: 100%;
    justify-content: space-between;
  }

  .input-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .badges {
    gap: 6px;
  }

  .badge {
    font-size: 10px;
    padding: 3px 8px;
  }
}
