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

html,
body {
  width: 100%;
  height: auto;
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: #08080c;
  color: #ededf5;
}

#container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* PAINÉIS */
.painel-esquerda,
.painel-direita {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #7c3aed;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #ededf5;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #ededf5;
}

.pergunta {
  font-size: 0.95rem;
  color: #9a9ab0;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* ENTRADA */
.secao-entrada {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.secao-entrada label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #ededf5;
}

#textarea-entrada {
  min-height: 200px;
  padding: 1rem;
  background: #101018;
  border: 1px solid #26263a;
  border-radius: 10px;
  color: #ededf5;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#textarea-entrada:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.dica-pequena {
  font-size: 0.75rem;
  color: #9a9ab0;
  margin-top: 0.25rem;
}

/* AÇÕES */
.acoes {
  display: flex;
  gap: 1rem;
}

button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.botao-primario {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ededf5;
  flex: 1;
}

.botao-primario:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.botao-primario:active {
  transform: translateY(0);
}

.botao-primario:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

.botao-secundario {
  background: rgba(154, 154, 176, 0.1);
  border: 1px solid #26263a;
  color: #ededf5;
  flex: 1;
}

.botao-secundario:hover {
  background: rgba(154, 154, 176, 0.2);
  border-color: #9a9ab0;
}

.botao-secundario:focus-visible {
  outline: 2px solid #9a9ab0;
  outline-offset: 2px;
}

/* MÉTRICAS */
.metricas {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  padding: 1rem;
  background: rgba(124, 58, 237, 0.05);
  border: 1px solid rgba(124, 58, 237, 0.1);
  border-radius: 10px;
}

.metrica {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.metrica .label {
  font-size: 0.7rem;
  color: #9a9ab0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.metrica .valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: #7c3aed;
  font-family: 'Cascadia Code', Consolas, monospace;
}

/* CUSTO */
.secao-custo {
  padding: 1rem;
  background: #101018;
  border: 1px solid #26263a;
  border-radius: 10px;
}

.secao-custo h3 {
  margin-bottom: 1rem;
}

.campo-grupo {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.campo-grupo label {
  font-size: 0.875rem;
  color: #ededf5;
}

.campo-preco {
  display: flex;
  align-items: center;
  background: #0a0a10;
  border: 1px solid #26263a;
  border-radius: 8px;
  overflow: hidden;
}

.prefixo {
  padding: 0.75rem;
  color: #9a9ab0;
  font-weight: 600;
}

#preco-input {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  color: #ededf5;
  font-size: 1rem;
  font-family: 'Cascadia Code', Consolas, monospace;
}

#preco-input:focus {
  outline: none;
}

.custo-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.custo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: rgba(124, 58, 237, 0.05);
  border: 1px solid rgba(124, 58, 237, 0.1);
  border-radius: 8px;
}

.custo-item .label {
  font-size: 0.75rem;
  color: #9a9ab0;
}

.custo-item .valor {
  font-size: 1rem;
  font-weight: 700;
  color: #7c3aed;
  font-family: 'Cascadia Code', Consolas, monospace;
}

/* VISUALIZAÇÃO DE TOKENS */
.tokens-container {
  flex: 1;
  min-height: 300px;
  padding: 1.5rem;
  background: #101018;
  border: 1px solid #26263a;
  border-radius: 10px;
  overflow-y: auto;
}

.tokens-visualizacao {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  background: #1a1a26;
  border: 1px solid #26263a;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: 'Cascadia Code', Consolas, monospace;
  color: #ededf5;
  cursor: help;
  transition: all 0.15s ease;
  white-space: nowrap;
  word-break: break-all;
  max-width: 100px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-chip:hover {
  background: #26263a;
  border-color: #7c3aed;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
}

.token-chip.continuacao {
  opacity: 0.7;
  font-style: italic;
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
}

/* TOOLTIP DOS TOKENS */
.token-chip[title] {
  position: relative;
}

@media (prefers-reduced-motion: no-preference) {
  .token-chip[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a26;
    color: #ededf5;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.7rem;
    border: 1px solid #26263a;
    z-index: 10;
    margin-bottom: 0.5rem;
    pointer-events: none;
  }
}

/* MODAL DE COMPARAÇÃO */
.modal-comparacao {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 1;
  pointer-events: auto;
  animation: fadeIn 0.2s ease;
}

.modal-comparacao.oculto {
  display: none;
}

.modal-conteudo {
  background: #101018;
  border: 1px solid #26263a;
  border-radius: 12px;
  padding: 2rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.btn-fechar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(154, 154, 176, 0.1);
  border: 1px solid #26263a;
  color: #ededf5;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.5rem;
  border-radius: 6px;
}

.btn-fechar:hover {
  background: rgba(154, 154, 176, 0.2);
}

.comparacao-tabela {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 1.5rem 0;
}

.comparacao-coluna {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comparacao-coluna h3 {
  color: #7c3aed;
}

.comparacao-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 100px;
  padding: 1rem;
  background: #0a0a10;
  border: 1px solid #26263a;
  border-radius: 8px;
}

.comparacao-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comparacao-stats .stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 0.5rem;
  background: rgba(124, 58, 237, 0.05);
  border-radius: 6px;
}

.comparacao-stats .label {
  color: #9a9ab0;
}

.comparacao-stats span:last-child {
  color: #7c3aed;
  font-weight: 600;
  font-family: 'Cascadia Code', Consolas, monospace;
}

.comparacao-resultado {
  padding: 1.5rem;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  text-align: center;
}

.comparacao-resultado p {
  line-height: 1.6;
  color: #ededf5;
}

.comparacao-resultado strong {
  color: #10b981;
  font-weight: 700;
}

.comparacao-resultado .explicacao {
  font-size: 0.875rem;
  color: #9a9ab0;
  margin-top: 0.75rem;
}

/* BLOCO DE LIÇÃO */
.licao-bloco {
  padding: 1.5rem;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-left: 3px solid #10b981;
  border-radius: 10px;
}

.licao-bloco h3 {
  color: #10b981;
  margin-bottom: 0.75rem;
}

.licao-bloco p {
  font-size: 0.875rem;
  color: #ededf5;
  line-height: 1.6;
}

/* RESPONSIVIDADE */
@media (max-width: 1024px) {
  #container {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }

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

  .custo-items {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #container {
    padding: 1rem;
    gap: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1rem;
  }

  .metricas {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .metrica .valor {
    font-size: 1rem;
  }

  .acoes {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .tokens-container {
    min-height: 200px;
    padding: 1rem;
  }

  .token-chip {
    max-width: 80px;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
  }

  .comparacao-tabela {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal-conteudo {
    padding: 1.5rem;
  }
}

@media (max-width: 360px) {
  #container {
    padding: 0.75rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .metricas {
    grid-template-columns: 1fr;
  }

  .token-chip {
    max-width: 60px;
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
  }
}

/* MODO DE MOVIMENTO REDUZIDO */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ANIMAÇÕES */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
