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

:root {
  --bg:       #ffffff;
  --surface:  #f5f3ff;
  --border:   #e9d5ff;
  --accent:   #9333ea;
  --accent2:  #c084fc;
  --grad:     linear-gradient(135deg, #7b2fbe, #9333ea, #c084fc);
  --text:     #1a0a2e;
  --muted:    #9278a8;
  --user-bg:  #f3e8ff;
  --bot-bg:   #faf5ff;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
}

/* ── Fond Vanta ── */
#vanta-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ── Layout ── */
.layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  width: 100%;
  max-width: 760px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 40px rgba(147, 51, 234, 0.08), 0 2px 24px rgba(0,0,0,0.06);
}

/* ── Panneau conseils ── */
.tips-panel {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 2px 16px rgba(0,0,0,0.05);
}

.tips-panel h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tip-block {
  margin-bottom: 14px;
}

.tip-block strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.tip-block p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-family: 'DM Mono', monospace;
}

.tip-block .example {
  margin-top: 5px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 5px 8px;
  border-radius: 0 6px 6px 0;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #6b21a8;
}

.tips-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ── Panneau cartographie (droite) ── */
.map-panel {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.05);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.map-panel h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-loading {
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-align: center;
  padding: 12px 0;
}

.map-error {
  font-size: 12px;
  color: #c02020;
  font-family: 'DM Mono', monospace;
  text-align: center;
  padding: 8px 0;
}

.map-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.map-item:hover {
  background: #f0f9e0;
  border-color: #d3e9b0;
}
.map-item .map-url {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-item .map-file {
  font-size: 10.5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Deploy panel ── */
.deploy-status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.deploy-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.deploy-status-text {
  font-size: 11.5px;
  font-family: 'DM Mono', monospace;
  color: var(--text);
}
.deploy-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 2px;
}
.btn-preview, .btn-prod {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
}
.btn-preview {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-preview:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-preview:disabled { opacity: .4; cursor: default; }
.btn-prod {
  background: var(--grad);
  color: #fff;
}
.btn-prod:hover:not(:disabled) { opacity: .85; }
.btn-prod:disabled { opacity: .5; cursor: default; }

/* ── Historique ── */
.history-item {
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 5px;
  background: var(--bg);
}
.history-msg {
  font-size: 11.5px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.history-sha {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  color: var(--accent);
  background: #f3e8ff;
  padding: 1px 5px;
  border-radius: 4px;
}
.history-date {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  flex: 1;
}
.btn-rollback {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s;
}
.btn-rollback:hover { border-color: #e53535; color: #e53535; background: rgba(229,53,53,0.05); }

@media (max-width: 1060px) {
  .tips-panel { display: none; }
  .layout { padding: 0; }
}
@media (max-width: 1280px) {
  .map-panel { display: none; }
}

/* ── Login overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.login-overlay.hidden { display: none; }

.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
  text-align: center;
}

.login-logo-img {
  height: 90px;
  width: auto;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  font-family: 'DM Mono', monospace;
}

.login-box input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Nunito', sans-serif;
  background: var(--surface);
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
  transition: border-color .2s;
}
.login-box input:focus { border-color: var(--accent); }

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--grad);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: #ffffff;
  cursor: pointer;
  transition: opacity .2s;
  margin-top: 4px;
}
.login-box button:hover { opacity: .85; }
.login-box button:disabled { opacity: .5; cursor: not-allowed; }

.login-error {
  margin-top: 12px;
  font-size: 12.5px;
  color: #c02020;
  min-height: 18px;
  font-family: 'DM Mono', monospace;
}

/* ── Header ── */
header {
  padding: 20px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
}
.logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
}
.header-info h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text);
}
.header-info p  { font-size: 12px; color: var(--muted); font-family: 'DM Mono', monospace; margin-top: 2px; }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
button#disconnectBtn {
  margin-left: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  transition: all .15s;
}
button#disconnectBtn:hover { border-color: #e53535; color: #e53535; background: rgba(229,53,53,0.05); }
button#disconnectBtn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Messages ── */
.messages {
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: transparent;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: fadeUp .25s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-label {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 4px;
}

.bubble {
  padding: 13px 17px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 88%;
  white-space: pre-wrap;
}

.msg.user { align-items: flex-end; }
.msg.user .bubble {
  background: var(--user-bg);
  border: 1px solid #d8b4fe;
  border-bottom-right-radius: 4px;
  color: var(--text);
}

.msg.bot { align-items: flex-start; }
.msg.bot .bubble {
  background: var(--bot-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: #2a1040;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.msg.bot .bubble.thinking {
  color: var(--muted);
  font-style: italic;
}
.cursor {
  display: inline-block;
  width: 8px; height: 13px;
  background: var(--grad);
  border-radius: 2px;
  margin-left: 3px;
  animation: blink .8s step-end infinite;
  vertical-align: middle;
}
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: 0 } }

/* ── Suggestions ── */
.suggestions {
  padding: 0 24px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: transparent;
}
.chip {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover {
  border-color: #9333ea;
  color: #6b21a8;
  background: #f3e8ff;
  box-shadow: 0 0 8px #9333ea33;
}

/* ── Input ── */
.input-area {
  padding: 14px 20px 22px;
  border-top: 1px solid var(--border);
  background: transparent;
}
.input-row {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input-row:focus-within {
  border-color: #9333ea;
  box-shadow: 0 0 0 3px #9333ea1a;
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  resize: none;
  height: 24px;
  max-height: 120px;
  line-height: 1.5;
}
textarea::placeholder { color: var(--muted); }

button#send {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--grad);
  color: #1a2a00;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
button#send:hover { opacity: .9; box-shadow: 0 4px 14px #9333ea55; }
button#send:active { transform: scale(.95); }
button#send:disabled { opacity: .3; cursor: default; }

.hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  font-family: 'DM Mono', monospace;
}

/* ── Image preview ── */
.img-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #f3e8ff;
  border: 1.5px dashed #9333ea;
  border-radius: 10px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
}
.img-preview.active { display: flex; }
.img-preview img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.img-preview .img-name { flex: 1; color: var(--text); }
.img-preview .img-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
}
.img-preview .img-remove:hover { color: #e53535; }

/* Bouton paperclip */
button#attach {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}
button#attach:hover { border-color: #9333ea; color: #6b21a8; box-shadow: 0 0 6px #9333ea22; }
button#attach.has-file { border-color: #9333ea; color: #6b21a8; background: #f3e8ff; }

/* Drag over */
.input-row.drag-over {
  border-color: #9333ea;
  background: #f3e8ff;
  box-shadow: 0 0 16px #9333ea22;
}

/* Message image dans le chat */
.msg-image {
  max-width: 200px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* ── Badges d'activité des outils ── */
.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-family: 'DM Mono', monospace;
  padding: 4px 10px;
  border-radius: 20px;
  margin: 3px 2px;
  transition: all 0.25s ease;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tool-badge.thinking { background: rgba(168,230,61,0.10); color: #6a9020; border: 1px solid rgba(168,230,61,0.25); }
.tool-badge.thinking .badge-dot { background: #a8c860; animation: pulse-dot 1s infinite; }
.tool-badge.running  { background: rgba(59,130,246,0.08); color: #2563eb; border: 1px solid rgba(59,130,246,0.20); }
.tool-badge.running  .badge-dot { background: #3b82f6; animation: spin-dot 0.8s linear infinite; }
.tool-badge.success  { background: rgba(93,184,42,0.10); color: #3a7a10; border: 1px solid rgba(93,184,42,0.25); }
.tool-badge.success  .badge-dot { background: #5db82a; }
.tool-badge.error    { background: rgba(229,53,53,0.08); color: #c02020; border: 1px solid rgba(229,53,53,0.20); }
.tool-badge.error    .badge-dot { background: #e53535; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes spin-dot  { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.4); opacity: 0.4; } }

.tool-badges-wrap { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 6px; }
.tool-badges-wrap:empty { margin-bottom: 0; }

/* ── Curseur streaming ── */
.bubble.streaming .bubble-text::after {
  content: "▍";
  display: inline-block;
  animation: blink-cursor 0.7s steps(1) infinite;
  margin-left: 1px;
  opacity: 0.7;
}
@keyframes blink-cursor { 0%, 100% { opacity: 0.7; } 50% { opacity: 0; } }

/* ── Modal Build ── */
.build-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 10, 46, 0.55);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.build-modal.open { display: flex; }

.build-modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  box-shadow: 0 24px 64px rgba(147, 51, 234, 0.18);
  min-width: 340px;
}

.build-track {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  position: relative;
  height: 72px;
}

.build-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  position: absolute;
  left: 0;
  animation: logo-fly 1.6s ease-in-out infinite alternate;
  filter: drop-shadow(0 4px 12px rgba(147,51,234,0.3));
  z-index: 2;
}
.build-logo.landed {
  animation: logo-land 0.5s ease-out forwards;
}

@keyframes logo-fly {
  0%   { left: 0;    transform: rotate(-8deg) scale(1); }
  100% { left: calc(100% - 80px); transform: rotate(8deg) scale(1.05); }
}
@keyframes logo-land {
  0%   { transform: scale(1.1); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); left: calc(100% - 80px); }
}

.build-pipe {
  flex: 1;
  height: 3px;
  background: linear-gradient(90deg, #e9d5ff, #9333ea);
  border-radius: 2px;
  margin: 0 8px;
  position: relative;
  overflow: hidden;
}
.build-pipe::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  animation: pipe-shine 1.2s linear infinite;
}
@keyframes pipe-shine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.build-target {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  transition: background 0.4s, border-color 0.4s;
}
.build-target.ready {
  background: #f0fdf4;
  border-color: #86efac;
  animation: target-pop 0.4s ease-out;
}
@keyframes target-pop {
  0%   { transform: scale(0.8); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.build-status-text {
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

.build-preview-btn {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  animation: fade-in-up 0.4s ease-out;
}
.build-preview-btn:hover { opacity: 0.88; }

.build-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Signature « Powered by » ── */
.powered-by {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(147, 51, 234, 0.12);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.powered-by img {
  height: 16px;
  width: auto;
  display: block;
}

/* Sous la modal de build (z-index 200) et masquée quand la place manque. */
@media (max-width: 1060px) {
  .powered-by { display: none; }
}
