/* ===== STRUCTURE PAGE LAYOUT ===== */
.structure-page { width: 100%; }

.structure-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .structure-layout { grid-template-columns: 1fr; }
}

/* ===== CONTROLS PANEL ===== */
.controls-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.control-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  font-weight: 600;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.op-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ===== ANIMATION CONTROLS ===== */
.anim-controls {
  display: flex;
  gap: 0.4rem;
}

.speed-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ===== STEP LOG ===== */
.log-section { flex: 1; }

.step-log {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}

.step-log::-webkit-scrollbar        { width: 6px; }
.step-log::-webkit-scrollbar-track  { background: var(--color-bg); border-radius: 3px; }
.step-log::-webkit-scrollbar-thumb  { background: var(--color-border); border-radius: 3px; }
.step-log::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

.log-hint {
  color: var(--color-text-muted);
  font-style: italic;
  font-family: var(--font-mono);
}

.log-step {
  padding: 2px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.log-step--active {
  color: var(--color-text);
  font-weight: 600;
}

.log-step-num {
  color: var(--color-primary);
  margin-right: 0.4rem;
}

/* ===== VIZ PANEL ===== */
.viz-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.viz-area {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem 1rem;
  min-height: 300px;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Scrollbar estilizada para combinar com o tema */
.viz-area::-webkit-scrollbar        { height: 6px; }
.viz-area::-webkit-scrollbar-track  { background: var(--color-bg); border-radius: 3px; }
.viz-area::-webkit-scrollbar-thumb  { background: var(--color-border); border-radius: 3px; }
.viz-area::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

#viz-svg {
  display: block;
  width: 100%;
  min-width: 100%;
  min-height: 240px;
  overflow: visible;
  flex-shrink: 0;
}

/* Empty state */
.viz-empty {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ===== MEMORY PANEL ===== */
.memory-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.memory-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.6rem;
}

.memory-panel-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.memory-panel-badge-sim {
  font-size: 0.65rem;
  background: var(--color-border);
  color: var(--color-text-muted);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.5px;
}

.memory-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

.mem-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mem-metric-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
}

.mem-metric-value {
  font-size: 0.83rem;
  color: var(--color-text);
}

.mem-metric-value--mono {
  font-family: var(--font-mono);
}

/* Cache hit / miss badge */
.mem-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  color: var(--color-text-muted);
}

.mem-badge--hit {
  background: rgba(65, 179, 110, 0.15);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.mem-badge--miss {
  background: rgba(224, 92, 92, 0.15);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* Hit-rate row */
.mem-stats-row {
  padding: 0.55rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.mem-hitrate {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}

.mem-hitrate-bar-wrap {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  width: 100%;
  overflow: hidden;
}

.mem-hitrate-bar {
  height: 100%;
  background: var(--color-success);
  border-radius: 2px;
  transition: width 0.35s, background 0.35s;
  width: 0%;
}

.mem-hitrate-bar--low { background: var(--color-danger); }
.mem-hitrate-bar--mid { background: var(--color-warning); }

/* Access row: cache + cycles + note */
.memory-access-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1.25rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.mem-note {
  flex: 1 1 100%;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
  line-height: 1.4;
  min-height: 1.1em;
}

/* Memory layout (chunks) */
.memory-layout-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mem-layout-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
}

.mem-layout-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}

.mem-layout-scroll::-webkit-scrollbar        { height: 6px; }
.mem-layout-scroll::-webkit-scrollbar-track  { background: var(--color-bg); border-radius: 3px; }
.mem-layout-scroll::-webkit-scrollbar-thumb  { background: var(--color-border); border-radius: 3px; }
.mem-layout-scroll::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

.mem-layout-blocks {
  display: flex;
  align-items: flex-end;
  gap: 0;
  min-height: 54px;
}

.mem-block-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mem-block {
  width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.mem-block--active {
  background: #1a3a6b;
  border-color: var(--color-primary);
  color: var(--color-text);
}

.mem-block-addr {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--color-text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

/* Cache line separator (array only) */
.mem-line-sep {
  width: 2px;
  height: 36px;
  background: var(--color-border);
  margin: 0 3px;
  align-self: center;
  border-radius: 1px;
  opacity: 0.6;
}

/* Gap between linked-list nodes (fragmentation indicator) */
.mem-gap {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  opacity: 0.6;
  padding: 0 2px;
  align-self: center;
  letter-spacing: 1px;
  padding-bottom: 18px;
}

/* ===== INFO BLOCKS (details/summary) ===== */
.info-sections {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.info-block-title {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.info-block-title::-webkit-details-marker { display: none; }

.info-block-title::after {
  content: '+';
  color: var(--color-text-muted);
  font-size: 1.1rem;
  transition: transform 0.2s;
}

details[open] > .info-block-title::after {
  content: '−';
}

.info-block-body {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

/* ===== COMPLEXITY TABLE ===== */
.complexity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.complexity-table th,
.complexity-table td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.complexity-table th {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.complexity-table td:first-child { color: var(--color-text-muted); }
.complexity-table td:not(:first-child) { font-family: var(--font-mono); }

.complexity-table tr:last-child td { border-bottom: none; }

.loading-cell {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  padding: 1rem !important;
}

.space-complexity {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.space-complexity span {
  font-family: var(--font-mono);
  color: var(--color-warning);
}

/* ===== USE CASES ===== */
.use-cases-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.use-col--full { grid-column: 1 / -1; }

.use-col-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text-muted);
}

.use-col-title--yes { color: var(--color-success); }
.use-col-title--no  { color: var(--color-danger); }

.use-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.use-list li {
  font-size: 0.84rem;
  color: var(--color-text-muted);
  padding-left: 1.1rem;
  position: relative;
}

.use-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--color-border);
}

.use-list--examples li::before { color: var(--color-primary); }

/* ===== CODE SNIPPETS ===== */
.code-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover { border-color: var(--color-primary); color: var(--color-text); }

.tab-btn--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.code-snippet {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 0;
}

.code-snippet code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--color-text);
  white-space: pre;
}

/* ===== SYNTAX HIGHLIGHT — step log e descrições ===== */
/* Inspirado no tema Dark+ do VS Code                   */
.hl-kw       { color: var(--color-primary);  font-weight: 600; }  /* HEAD, TAIL, next, prev  */
.hl-null     { color: #8baac8;               font-weight: 600; }  /* null                   */
.hl-num      { color: var(--color-warning);                    }  /* literais numéricos     */
.hl-addr     { color: #4ec9b0; font-family: var(--font-mono);  }  /* 0x endereços           */
.hl-hit      { color: var(--color-success);  font-weight: 700; }  /* HIT                    */
.hl-miss     { color: var(--color-danger);   font-weight: 700; }  /* MISS                   */
.hl-found    { color: var(--color-success);  font-weight: 700; }  /* ENCONTRADO!            */
.hl-bigO     { color: #c586c0;                                 }  /* O(n), O(1), O(log n)   */
.hl-circular { color: var(--color-primary);                    }  /* ↺                      */
.hl-arrow    { color: var(--color-accent);                     }  /* → ←                    */
.hl-type     { color: #4ec9b0; font-style: italic;             }  /* int32, node*, tipos    */

/* ===== SVG NODE STYLES ===== */
.node-rect {
  rx: 6;
  ry: 6;
  stroke-width: 2;
}

/* Estados dos nós — fills escuros derivados da paleta do logo */
.node-rect--neutral  { fill: var(--color-surface); stroke: var(--color-border); }
.node-rect--visiting { fill: #122540; stroke: var(--color-primary); }
.node-rect--success  { fill: #0e2a1a; stroke: var(--color-success); }
.node-rect--danger   { fill: #2a1010; stroke: var(--color-danger); }
.node-rect--warning  { fill: #2a1e08; stroke: var(--color-warning); }

.node-text {
  font-family: var(--font-mono);
  font-size: 14px;
  fill: var(--color-text);
  dominant-baseline: middle;
  text-anchor: middle;
  pointer-events: none;
}

/* Valores numéricos nos nós — cor de literal numérico (estilo editor) */
.node-value {
  fill: #e0a03e;  /* equivalente ao --color-warning com leve warm shift */
}

.node-index {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--color-text-muted);
  dominant-baseline: auto;
  text-anchor: middle;
  pointer-events: none;
}

/* Anotação de tipo nos nós (int32, node*) — estilo type annotation */
.node-type-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: #4ec9b0;
  dominant-baseline: auto;
  text-anchor: middle;
  pointer-events: none;
  opacity: 0.75;
  font-style: italic;
}

.pointer-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--color-primary);
  font-weight: 600;
  dominant-baseline: middle;
  text-anchor: middle;
  font-style: italic;   /* variáveis de ponteiro em itálico, estilo editor */
}

.arrow-line {
  stroke: var(--color-text-muted);
  stroke-width: 1.5;
  fill: none;
  marker-end: url(#arrowhead);
}

.arrow-line--circular {
  stroke: var(--color-primary);
  stroke-dasharray: 5 3;
  opacity: 0.65;
}

.arrow-line--null {
  stroke: var(--color-border);
  stroke-dasharray: 4 3;
}

.arrow-line--prev {
  stroke: var(--color-warning);
  marker-end: url(#arrowhead-prev);
}

/* ===== ADA IA — WIDGET FLUTUANTE ===== */

/* Contentor posicionado no canto inferior direito */
#ada-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

/* Botão flutuante */
.ada-float-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(61, 143, 212, 0.45);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.3px;
}

.ada-float-btn:hover {
  background: var(--color-accent);
  box-shadow: 0 6px 24px rgba(61, 143, 212, 0.6);
  transform: translateY(-2px);
}

.ada-float-btn:active { transform: translateY(0); }

.ada-float-btn-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  /* A imagem tem o mesmo azul do botão — seamless */
  filter: brightness(1.08);
  transition: filter 0.15s;
}

.ada-float-btn:hover .ada-float-btn-img {
  filter: brightness(1.2);
}

/* Painel de chat — oculto por padrão */
.ada-float-panel {
  width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Animação de entrada/saída */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ada-float-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Cabeçalho do painel */
.ada-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.ada-float-title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ada-float-brand {
  color: var(--color-accent);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.4px;
}

.ada-float-sub {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.ada-float-link {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.ada-float-link:hover { color: var(--color-text); }

.ada-float-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.ada-float-close:hover {
  color: var(--color-text);
  background: var(--color-border);
}

/* Corpo do painel */
.ada-float-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}

.ada-float-body::-webkit-scrollbar        { width: 6px; }
.ada-float-body::-webkit-scrollbar-track  { background: var(--color-bg); border-radius: 3px; }
.ada-float-body::-webkit-scrollbar-thumb  { background: var(--color-border); border-radius: 3px; }
.ada-float-body::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

.ada-float-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Textarea e elementos compartilhados com o painel antigo */
.ada-panel-textarea {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.55;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  min-height: 68px;
  transition: border-color 0.15s;
}

.ada-panel-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.ada-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ada-panel-shortcut {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.ada-panel-status {
  font-size: 0.8rem;
  min-height: 1.1em;
}

.ada-panel-status--error { color: var(--color-danger); }
.ada-panel-status--rate  { color: var(--color-warning); }

/* Loader de três pontos */
.ada-panel-status--loading {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.ada-loader-label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin-left: 0.2rem;
}

.ada-loader-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  display: inline-block;
  animation: ada-bounce 1.2s infinite ease-in-out;
}

.ada-loader-dot:nth-child(1) { animation-delay: 0s; }
.ada-loader-dot:nth-child(2) { animation-delay: 0.2s; }
.ada-loader-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ada-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

.ada-panel-answer {
  display: none;
  font-size: 0.83rem;
  line-height: 1.75;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ada-panel-answer:not(:empty) { display: block; }

/* Responsivo: painel menor em telas pequenas */
@media (max-width: 480px) {
  .ada-float-panel { width: calc(100vw - 2rem); }
  #ada-widget { right: 1rem; bottom: 1.5rem; }
}
