/* ============================================================
   POLINOMIAL VS EXPONENCIAL — SIMULADOR INTERATIVO
   Análise de Algoritmos • Aula 7 (Slide 16) • UNICAP
   Autor: Prof. Pedro Ximenes
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&family=Outfit:wght@600;700;800&display=swap');

:root {
  --warsaw-dark: #001730;
  --warsaw-primary: #002b5b;
  --warsaw-secondary: #0f4c81;
  --warsaw-light: #e8f0fe;
  --warsaw-gold: #f59e0b;

  --bg-body: #090e17;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-canvas-box: #0a0f1d;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(59, 130, 246, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Cores das Curvas (Idênticas ao Slide 16) */
  --c-exp: #ef4444;      /* 2^n (Vermelho) */
  --c-cube: #10b981;     /* n^3 (Verde) */
  --c-quad: #3b82f6;     /* n^2 (Azul) */
  --c-lin: #a855f7;      /* n (Roxo) */
  --c-quartic: #f59e0b;  /* n^4 (Âmbar) */

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.2);
}

body.theme-light {
  --bg-body: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-canvas-box: #ffffff;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-active: rgba(37, 99, 235, 0.35);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

/* ============================================================
   CABEÇALHO WARSAW BEAMER
   ============================================================ */
#warsaw-header {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.warsaw-section-bar {
  background: linear-gradient(90deg, var(--warsaw-dark) 0%, var(--warsaw-primary) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.warsaw-left-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.warsaw-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
}

.warsaw-nav-back:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateX(-2px);
}

.warsaw-tag {
  background: var(--warsaw-gold);
  color: #000;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.warsaw-header-title {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.3px;
}

.warsaw-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.warsaw-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.warsaw-tool-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
}

.warsaw-tool-btn.primary-btn {
  background: #2563eb;
  border-color: #3b82f6;
}

.warsaw-tool-btn.primary-btn:hover {
  background: #1d4ed8;
}

.warsaw-subsection-bar {
  background: var(--warsaw-secondary);
  color: rgba(255, 255, 255, 0.9);
  padding: 6px 24px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-container {
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* Top Intro Banner */
.intro-banner {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
}

.intro-text h1 {
  font-size: 22px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.intro-text p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  max-width: 820px;
  line-height: 1.5;
}

/* Grid Principal: Gráfico + Painel Lateral */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PAINEL DO GRÁFICO (CANVAS)
   ============================================================ */
.graph-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.graph-top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Pills de Escala (Linear vs Log) */
.scale-toggle-group {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.scale-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scale-btn.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.scale-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* Filtros de Funções (Chips) */
.curve-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.curve-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.curve-chip:hover {
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.curve-chip.active {
  color: #fff;
}

.curve-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.curve-chip[data-fn="exp"].active {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--c-exp);
}
.curve-chip[data-fn="cube"].active {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--c-cube);
}
.curve-chip[data-fn="quad"].active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--c-quad);
}
.curve-chip[data-fn="lin"].active {
  background: rgba(168, 85, 247, 0.18);
  border-color: var(--c-lin);
}
.curve-chip[data-fn="quartic"].active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--c-quartic);
}

/* Área de Canvas */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  background: var(--bg-canvas-box);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tooltip flutuante no Canvas */
#canvasTooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #f8fafc;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 50;
  transition: opacity 0.15s ease;
}

/* Régua / Barra de Controle do n */
.n-control-bar {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.n-label-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 130px;
}

.n-label-group .n-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.n-label-group .n-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 800;
  color: #38bdf8;
}

.slider-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #334155;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #38bdf8;
  border: 3px solid #0f172a;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.n-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.play-btn {
  background: #10b981;
  border: 1px solid #059669;
  color: #fff;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.play-btn:hover {
  background: #059669;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* ============================================================
   PAINEL LATERAL (TELEMETRIA E CENÁRIOS DE AULA)
   ============================================================ */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Card: Valores em Tempo Real para n atual */
.telemetry-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.val-items-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.val-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border-left: 4px solid var(--border-subtle);
  transition: transform 0.15s ease;
}

.val-item:hover {
  transform: translateX(3px);
}

.val-item.exp { border-left-color: var(--c-exp); }
.val-item.cube { border-left-color: var(--c-cube); }
.val-item.quad { border-left-color: var(--c-quad); }
.val-item.lin { border-left-color: var(--c-lin); }
.val-item.quartic { border-left-color: var(--c-quartic); }

.val-meta {
  display: flex;
  flex-direction: column;
}

.val-fn-name {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
}

.val-fn-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.val-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
}

.val-time-sub {
  font-size: 11px;
  color: #38bdf8;
  font-weight: 600;
  display: block;
}

/* Ratio Callout */
.ratio-callout {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #fca5a5;
}

.ratio-callout strong {
  color: #fee2e2;
}

/* Card: Cenários de Aula (Prescrições Prontas para Mostrar aos Alunos) */
.scenarios-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.scenario-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-btn {
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.scenario-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.scenario-icon {
  font-size: 18px;
  line-height: 1;
  padding-top: 2px;
}

.scenario-content {
  flex: 1;
}

.scenario-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.scenario-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

/* ============================================================
   SEÇÃO INFERIOR: TESTE DA REALIDADE & RESUMO PEDAGÓGICO
   ============================================================ */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

.pedagogy-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.pedagogy-card h2 {
  font-size: 16px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reality-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.reality-table th,
.reality-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.reality-table th {
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
}

.reality-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.table-time-fast {
  color: #34d399;
  font-weight: 600;
}

.table-time-danger {
  color: #f87171;
  font-weight: 700;
}

/* Bullet points pedagógicos */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.insight-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.insight-icon {
  color: var(--warsaw-gold);
  font-weight: 800;
  font-size: 15px;
}

.insight-item strong {
  color: var(--text-primary);
}

/* ============================================================
   RODAPÉ WARSAW
   ============================================================ */
#warsaw-footline {
  background: var(--warsaw-dark);
  color: rgba(255, 255, 255, 0.7);
  font-size: 11.5px;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

#warsaw-footline kbd {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: inherit;
  color: #fff;
}
