:root {
  --bg: #000000;
  --panel: #000000;
  --text: #ffffff;
  --border: #222222;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Share Tech Mono', monospace;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.menu-toggle {
  display: none;
}

.sidebar {
  width: 290px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ascii {
  font-size: 12px;
  white-space: pre;
  line-height: 1.2;
  text-align: center;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px;
  cursor: pointer;
  text-align: left;
}

.menu button:hover,
.menu button.active {
  background: #111111;
}

.main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  /* Previne overflow horizontal */
  overflow-x: hidden;
}

.content {
  max-width: 900px;
  margin: 0 auto;
  /* Garante que o conteúdo não ultrapasse */
  width: 100%;
}

h1, h2, h3 {
  color: var(--text);
}

a {
  color: var(--text);
  text-decoration: underline;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-item {
  padding: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.doc-item:hover {
  background: #111111;
}

pre {
  background: #000000;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
}

code {
  color: #ffffff;
}

footer {
  margin-top: 60px;
  font-size: 12px;
  opacity: 0.7;
  text-align: center;
}

/* Container principal para todo conteúdo markdown */
#content {
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Estilo para imagens renderizadas pelo marked.js */
#content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 32px auto;
  
  /* Centralização garantida */
  margin-left: auto !important;
  margin-right: auto !important;
  
  /* Limites responsivos inteligentes */
  max-width: min(1000px, 95%);
  max-height: 70vh; /* Limita altura máxima */
  
  /* Mantém proporção e evita distorção */
  object-fit: contain;
  
  /* Estilos visuais */
  border: 1px solid #333;
  background-color: #0a0a0a;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.1);
  
  /* Smooth scaling */
  transition: max-width 0.3s ease;
}

/* Imagens dentro de parágrafos */
#content p img {
  margin-top: 20px;
  margin-bottom: 20px;
}

/* Para imagens que devem ocupar mais largura */
#content img.large {
  max-width: min(900px, 98%);
}

/* Para imagens muito pequenas (não distorcer) */
#content img.small {
  max-width: 300px;
}

/* Contêiner para imagens com legenda (se usado) */
#content figure {
  margin: 32px 0;
  text-align: center;
  width: 100%;
}

#content figure img {
  margin: 0 auto;
}

#content figcaption {
  font-size: 0.85em;
  color: #888;
  margin-top: 8px;
  font-style: italic;
}

/* Previne que tabelas e outros elementos causem overflow */
#content table {
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

/* Estilos para blocos de código */
pre {
    background: #1e1e1e;
    border-radius: 2px;
    padding: 0.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid #333;
    position: relative;
}

pre code {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
}

/* Adiciona um indicador da linguagem no bloco de código */
pre::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    right: 1rem;
    background: #333;
    color: #fff;
    padding: 0.2rem 0.8rem;
    font-size: 12px;
    border-radius: 0 0 8px 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Estilo para blocos de código bash específicos */
code.language-bash,
code.language-sh {
    color: #89e051;
}

/* Destaque para comandos */
.language-bash .hljs-built_in {
    color: #e6c07b;
}

/* Estilo para erros/mensagens */
.error {
    background: #2d2d2d;
    border-left: 4px solid #ff6b6b;
    padding: 1rem;
    border-radius: 4px;
    color: #ff6b6b;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  /* Sidebar vira topo */
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }

  .ascii {
    display: none;
  }

  /* Menu toggle para mobile */
  .menu-toggle {
    display: block;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    margin-bottom: 10px;
  }

  .menu {
    display: none;
    margin-top: 10px;
  }

  .menu.open {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .main {
    padding: 16px;
    overflow-x: hidden;
  }

  .content {
    max-width: 100%;
    padding: 0 4px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  h3 {
    font-size: 16px;
  }

  p, li {
    font-size: 14px;
    line-height: 1.6;
  }

  pre {
    font-size: 12px;
    padding: 12px;
    max-width: 100%;
    overflow-x: auto;
  }

  footer {
    font-size: 11px;
    margin-top: 40px;
  }

  /* Ajustes específicos para imagens no mobile */
  #content img {
    max-width: 100%;
    max-height: 60vh;
    margin: 20px auto;
  }

  #content p img {
    margin-top: 20px;
    margin-bottom: 20px;
  }
  
  /* Força o redimensionamento em telas muito pequenas */
  #content * {
    max-width: 100%;
  }
}

/* Para celulares muito pequenos */
@media (max-width: 480px) {
  .menu.open {
    grid-template-columns: 1fr;
  }
  
  #content img {
    max-height: 50vh;
    margin: 16px auto;
    border-width: 1px;
  }
  
  .main {
    padding: 12px;
  }
}

/* Para garantir que imagens nunca saiam da tela */
@media (max-width: 320px) {
  #content img {
    max-height: 40vh;
  }
}

/* ===== ESTILOS ADICIONAIS PARA CONTEÚDO DINÂMICO ===== */

/* Garante que links com imagens não quebrem layout */
#content a img {
  display: inline-block;
}

/* Previne que imagens em listas quebrem layout */
#content li img {
  vertical-align: middle;
  margin: 8px 0;
}

/* ===== ESTILOS PARA TABELAS MARKDOWN ===== */

/* Container para tabelas com scroll horizontal */
#content table {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1.5rem auto;
    font-size: 14px;
    line-height: 1.5;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #333 #000;
    min-width: 50%;
}

#content table.full-width {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Estilização da scrollbar para webkit (Chrome, Safari, Edge) */
#content table::-webkit-scrollbar {
    height: 8px;
    background: #1a1a1a;
}

#content table::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

#content table::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Células da tabela */
#content th,
#content td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    min-width: 120px;
}

/* Cabeçalho da tabela */
#content th {
    background: #0a0a0a;
    font-weight: bold;
    color: #00ff00; /* Verde característico */
    border-bottom: 2px solid #00ff00;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* Linhas alternadas (zebrado) */
#content tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

#content tbody tr:hover {
    background: rgba(0, 255, 0, 0.05);
    transition: background 0.2s ease;
}

/* Primeira coluna em destaque (opcional) */
#content td:first-child,
#content th:first-child {
    padding-left: 20px;
    border-left: 2px solid transparent;
}

#content tr:hover td:first-child {
    border-left-color: #00ff00;
}

/* Células com alinhamento especial */
#content td.center,
#content th.center {
    text-align: center;
}

#content td.right,
#content th.right {
    text-align: right;
}

/* Tabelas com bordas mais suaves (alternativo) */
#content table.clean {
    border: none;
}

#content table.clean th,
#content table.clean td {
    border: none;
    border-bottom: 1px solid var(--border);
}

/* Responsividade para telas médias */
@media (max-width: 768px) {
    #content table {
        font-size: 13px;
        margin: 1rem 0;
    }
    
    #content th,
    #content td {
        padding: 8px 12px;
        min-width: 100px;
    }
    
    #content th {
        font-size: 12px;
    }
}

/* Para telas muito pequenas, mantém scroll horizontal */
@media (max-width: 480px) {
    #content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    #content th,
    #content td {
        min-width: 90px;
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    /* Permite quebra de texto em células específicas */
    #content td.break,
    #content th.break {
        white-space: normal;
        min-width: 150px;
    }
}

/* Tabelas dentro de blocos de código? Nunca! */
#content pre table,
#content code table {
    display: none;
}

/* Bordas arredondadas para tabelas (opcional) */
#content table:not(.clean) {
    border-radius: 4px;
    overflow: hidden;
}

/* Cabeçalho fixo visualmente */
#content thead {
    position: sticky;
    top: 0;
    background: #000;
    z-index: 1;
}

#content thead th {
    position: sticky;
    top: 0;
    background: #0a0a0a;
    box-shadow: 0 2px 2px -1px rgba(0, 255, 0, 0.1);
}

/* Linhas de totais ou destaques */
#content tfoot td {
    background: #0a0a0a;
    border-top: 2px solid #00ff00;
    font-weight: bold;
}

/* Células com valores especiais */
#content td.highlight {
    background: rgba(0, 255, 0, 0.1);
    color: #00ff00;
    font-weight: bold;
}

#content td.warning {
    background: rgba(255, 100, 100, 0.1);
    color: #ff6b6b;
}

#content td.success {
    background: rgba(0, 255, 0, 0.1);
    color: #00ff00;
}

#content td.info {
    background: rgba(100, 150, 255, 0.1);
    color: #6b9fff;
}

/* Tabelas muito largas */
#content table.wide {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* Para tabelas que devem quebrar linhas */
#content table.wrap {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#content table.wrap td,
#content table.wrap th {
    white-space: normal;
    word-wrap: break-word;
}

/* Títulos de tabela (se houver caption) */
#content table caption {
    text-align: left;
    margin-bottom: 8px;
    color: #888;
    font-style: italic;
    font-size: 13px;
}

/* Linhas de separação quando não há bordas */
#content table.separator tbody tr:not(:last-child) {
    border-bottom: 1px dashed #333;
}

/* Animações suaves */
#content table {
    transition: all 0.2s ease;
}

/* Suporte a tabelas com primeiro cabeçalho fixo */
#content table.fixed-first th:first-child,
#content table.fixed-first td:first-child {
    position: sticky;
    left: 0;
    background: #000;
    z-index: 2;
}

#content table.fixed-first th:first-child {
    background: #0a0a0a;
    z-index: 3;
}

/* Efeito de brilho no hover das células */
#content td:hover {
    background: rgba(0, 255, 0, 0.08);
    transition: background 0.1s ease;
}

/* Alinhamento para números */
#content td.number,
#content td.numeric {
    text-align: right;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.5px;
}

/* Células de código dentro de tabelas */
#content td code {
    background: #1a1a1a;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    border: 1px solid #333;
}