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

:root {
  --bg-primary: #fbf8f8;
  --bg-secondary: #b3b3c9;
  --bg-tertiary: #fefbf5;
  --text-primary: #212121;
  --text-secondary: #a6a6be;
  --border-color: #e5e5e5;
  --button-bg: #939392;
  --button-hover: #4b5563;
  --input-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #343541;
    --bg-secondary: #40414f;
    --bg-tertiary: #555764;
    --text-primary: #ececf1;
    --text-secondary: #8e8ea0;
    --border-color: #565869;
    --button-bg: #6b7280;
    --button-hover: #4b5563;
    --input-bg: #40414f;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  position: fixed;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-tertiary);
}

#cabecalho-img {
  max-height: 230px;
  height: auto;
}

#secaochaveapi {
  position: fixed;
  top: 80px;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

#secaochaveapi label {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 1rem;
  white-space: nowrap;
}

#chaveApi {
  width: 400px;
  max-width: 60%;
  padding: 0.75rem 1rem;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

#chaveApi:focus {
  outline: none;
  border-color: var(--button-bg);
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.1);
}

#chaveApi::placeholder {
  color: var(--text-secondary);
}

main {
  flex: 1;
  max-width: 768px;
  margin: 150px auto 120px auto;
  padding: 2rem 1rem;
  width: 100%;
  min-height: calc(100vh - 270px);
}

#secao-resposta {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  animation: slideIn 0.3s ease-out;
  box-shadow: 0 2px 8px var(--shadow);
}

#secao-resposta h2 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

#resposta {
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 1rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 0;
}

/* Estilos para o histórico de mensagens */
.mensagem {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 12px;
  animation: fadeIn 0.3s ease-out;
}

.mensagem.pergunta {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  margin-left: 2rem;
}

.mensagem.resposta {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  margin-right: 2rem;
}

.mensagem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.mensagem-header strong {
  color: var(--text-primary);
}

.timestamp {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.mensagem-conteudo {
  color: var(--text-primary);
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Animação de loading */
.loading .mensagem-conteudo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-dots {
  display: flex;
  gap: 0.2rem;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

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

#secaochavepergunta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  z-index: 999;
  max-width: 70%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "label label"
    "pergunta botao";
  gap: 1rem;
}

#secaochavepergunta label {
  grid-area: label;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 1rem;
}

#pergunta {
  grid-area: pergunta;
  width: 100%;
  min-height: 60px;
  max-height: 150px;
  padding: 1rem;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: all 0.2s ease;
}

#pergunta:focus {
  outline: none;
  border-color: var(--button-bg);
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.1);
}

#pergunta::placeholder {
  color: var(--text-secondary);
}

#botaoPerguntar {
  grid-area: botao;
  background-color: var(--button-bg);
  color: white;
  border: none;
  padding: 0.875rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}

#botaoPerguntar:hover {
  background-color: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.2);
}

#botaoPerguntar:active {
  transform: translateY(0);
}

#botaoPerguntar:disabled {
  background-color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

@media (max-width: 768px) {
  #secaochaveapi {
    padding: 1rem 0.5rem;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  #secaochaveapi label {
    text-align: center;
  }

  #chaveApi {
    width: 100%;
    max-width: 100%;
  }

  main {
    margin: 140px 0.5rem 140px 0.5rem;
    padding: 1rem;
  }

  #secaochavepergunta {
    padding: 1rem;
    left: 0;
    right: 0;
    transform: none;
    max-width: none;
  }

  #secao-resposta {
    margin: 2rem 1rem;
  }

  #pergunta {
    min-height: 50px;
  }

  #botaoPerguntar {
    float: none;
    width: 100%;
  }

  header h1 {
    font-size: 1.25rem;
  }

  /* Responsividade para mensagens */
  .mensagem.pergunta {
    margin-left: 0.5rem;
  }

  .mensagem.resposta {
    margin-right: 0.5rem;
  }

  .mensagem-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

@media (max-width: 480px) {
  #botaoPerguntar {
    width: 100%;
    float: none;
  }

  main {
    margin: 130px 0.25rem 120px 0.25rem;
  }
}

input:focus,
textarea:focus,
button:focus {
  outline: 2px solid var(--button-bg);
  outline-offset: 2px;
}
#secao-resposta {
  margin: 2rem 1rem;
}
#secaochaveapi {
  margin-right: 1.5rem;
  margin-left: 1.5rem;
}

#resposta code {
  background-color: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.9em;
  border: 1px solid var(--border-color);
}

#resposta pre {
  background-color: var(--bg-secondary);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
}

#resposta pre code {
  background: none;
  padding: 0;
  border: none;
}

#resposta ul,
#resposta ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

#resposta li {
  margin: 0.5rem 0;
}

/* Novos estilos adicionados para os botões e feedback */
.botoes-resposta {
display: flex;
justify-content: flex-end;
gap: 1rem;
margin-top: 1rem;
}

.botoes-resposta button {
background-color: var(--button-bg);
color: white;
border: none;
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-size: 0.9rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
}

.botoes-resposta button:hover {
background-color: var(--button-hover);
transform: translateY(-1px);
box-shadow: 0 2px 6px rgba(107, 114, 128, 0.2);
}

.botoes-resposta button:active {
transform: translateY(0);
}

.feedback-copiar {
position: fixed;
bottom: 1.5rem;
left: 50%;
transform: translateX(-50%);
background-color: #28a745;
color: white;
padding: 10px 20px;
border-radius: 8px;
z-index: 2000;
opacity: 0;
transition: opacity 0.5s ease-in-out;
}

.feedback-copiar.show {
opacity: 1;
}