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

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --border:   #30363d;
  --text:     #e0e0e0;
  --muted:    #8b949e;
  --green:    #00c853;
  --blue:     #58a6ff;
  --radius:   10px;
  --header-h: 64px;
  --footer-h: 72px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ── LAYOUT ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 760px;
  margin: 0 auto;
}

/* ── HEADER ── */
.header {
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 12px; }

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

.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-tag  { font-size: 11px; color: var(--muted); }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.progress-track {
  width: 120px; height: 6px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

.progress-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── CHAT AREA ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.messages { display: flex; flex-direction: column; gap: 12px; }

/* ── MENSAGENS ── */
.msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: fadeIn .25s ease;
}

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

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

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.msg.assistant .msg-avatar { background: var(--green); color: #000; }
.msg.user      .msg-avatar { background: #21262d; color: var(--muted); }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.msg.user .msg-bubble {
  background: #1c4a2e;
  border: 1px solid #2ea043;
  border-bottom-right-radius: 2px;
  color: #e0e0e0;
}

/* bold em mensagens */
.msg-bubble strong { color: #fff; }

/* ── TYPING INDICATOR ── */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
  align-items: center;
}

.typing-dots span {
  width: 7px; height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce .9s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-6px); }
}

/* ── INPUT ZONE ── */
.input-zone {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#userInput {
  flex: 1;
  background: #21262d;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s;
}

#userInput:focus { border-color: var(--green); }
#userInput::placeholder { color: var(--muted); }

.btn-enviar {
  width: 40px; height: 40px;
  background: var(--green);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}

.btn-enviar:hover { background: #00e676; }
.btn-enviar:disabled { background: #2a3f2e; color: #4a6a4a; cursor: not-allowed; }

/* ── BOTÃO GERAR DIAGNÓSTICO ── */
.btn-relatorio {
  display: none;
  margin-bottom: 10px;
}

.btn-diagnostico {
  width: 100%;
  background: var(--green);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  padding: 13px;
  cursor: pointer;
  transition: background .2s;
}

.btn-diagnostico:hover { background: #00e676; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,200,83,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(0,200,83,0); }
}

.pulse { animation: pulse 1.8s infinite; }

/* ── OVERLAY / RELATÓRIO ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 100;
  display: none;
  overflow-y: auto;
  padding: 20px 0;
}

.relatorio-frame {
  background: var(--bg);
  max-width: 960px;
  margin: 0 auto;
  border-radius: 12px;
  min-height: 200px;
  position: relative;
}

.loading-relatorio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid #21262d;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── FECHAR RELATÓRIO ── */
.btn-fechar {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  background: #21262d;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  z-index: 10;
}

.btn-fechar:hover { color: #fff; }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .progress-track { width: 80px; }
  .progress-label { display: none; }
  .logo-tag       { display: none; }
  .msg            { max-width: 96%; }
}
