/* =============================================================
   Sistemas Inteligentes - Simuladores interactivos
   Autor: Marc Hernández Montesinos (MaHerMo)
   ============================================================= */

:root {
  --bg: #16171b;
  --bg-elevated: #1e1f24;
  --bg-card: #22242a;
  --border: #33353d;
  --border-strong: #4a4c55;
  --text: #e6e6e8;
  --text-secondary: #a1a3ab;
  --text-tertiary: #70737c;
  --accent: #599ce7;
  --accent-hover: #6aabe9;
  --accent-soft: rgba(89, 156, 231, 0.12);
  --success: #3fa266;
  --warning: #e0a862;
  --danger: #d17466;
  --info: #7baee9;
  --violet: #9386f2;
  --pink: #b48ead;
  --yellow: #f1b467;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
  --sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* -------- Layout -------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(22, 23, 27, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.nav-brand:hover {
  text-decoration: none;
}
.nav-logo {
  height: 34px;
  width: auto;
  display: block;
  transition: transform 0.2s ease;
}
.nav-brand:hover .nav-logo {
  transform: scale(1.04);
}
.nav-brand-text {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  line-height: 1;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-link {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* -------- Typography -------- */
h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
h1 {
  font-size: 30px;
  line-height: 1.2;
}
h2 {
  font-size: 20px;
  line-height: 1.3;
}
h3 {
  font-size: 16px;
  line-height: 1.4;
}
p,
li {
  color: var(--text);
}
.muted {
  color: var(--text-secondary);
}
.faint {
  color: var(--text-tertiary);
}
.small {
  font-size: 12px;
}
code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--accent);
}

.stack {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.grid {
  display: grid;
}
.gap-4 {
  gap: 4px;
}
.gap-6 {
  gap: 6px;
}
.gap-8 {
  gap: 8px;
}
.gap-12 {
  gap: 12px;
}
.gap-16 {
  gap: 16px;
}
.gap-20 {
  gap: 20px;
}
.gap-24 {
  gap: 24px;
}
.spacer {
  flex: 1;
}

/* -------- Cards -------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body {
  padding: 14px;
}
.callout {
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}
.callout-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.callout.success {
  border-left-color: var(--success);
}
.callout.warning {
  border-left-color: var(--warning);
}
.callout.danger {
  border-left-color: var(--danger);
}
.callout.info {
  border-left-color: var(--info);
}

/* -------- Buttons / Pills -------- */
.btn {
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f1220;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn.ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-elevated);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.pill.active {
  background: var(--accent-soft);
  border-color: rgba(89, 156, 231, 0.35);
  color: var(--accent);
}

/* -------- Stat -------- */
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 90px;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}
.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.stat.info .stat-value {
  color: var(--info);
}
.stat.warning .stat-value {
  color: var(--warning);
}
.stat.success .stat-value {
  color: var(--success);
}
.stat.danger .stat-value {
  color: var(--danger);
}

/* -------- Tables -------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* -------- Legend dots -------- */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
}

/* -------- A* board -------- */
.board {
  display: grid;
  gap: 3px;
  user-select: none;
}
.cell {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.15;
  transition:
    background 0.12s,
    transform 0.12s;
  color: var(--text);
}
.cell:hover {
  transform: scale(0.97);
}
.cell.wall {
  background: #2a2c33;
  color: var(--text-tertiary);
  border-color: #2a2c33;
}
.cell.start {
  background: var(--success);
  color: #0e1a13;
  border-color: var(--success);
  font-weight: 700;
}
.cell.end {
  background: var(--pink);
  color: #1c0e19;
  border-color: var(--pink);
  font-weight: 700;
}
.cell.frontier {
  background: rgba(241, 180, 103, 0.35);
  border-color: rgba(241, 180, 103, 0.7);
}
.cell.interior {
  background: rgba(123, 174, 233, 0.28);
  border-color: rgba(123, 174, 233, 0.5);
}
.cell.expanding {
  background: var(--accent);
  color: #0f1220;
  border-color: var(--accent);
  font-weight: 700;
}
.cell.path {
  background: var(--success);
  color: #0e1a13;
  border-color: var(--success);
  font-weight: 700;
}

/* -------- Tree SVG -------- */
.tree-svg {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  height: auto;
}

/* -------- Quiz -------- */
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  transition: all 0.15s;
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-card);
}
.quiz-option:disabled {
  cursor: default;
}
.quiz-option.correct {
  background: rgba(63, 162, 102, 0.2);
  border-color: var(--success);
}
.quiz-option.wrong {
  background: rgba(209, 116, 102, 0.2);
  border-color: var(--danger);
}
.quiz-option.dim {
  opacity: 0.5;
}
.quiz-option .letter {
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

/* -------- Footer -------- */
.footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* -------- Home page tiles -------- */
.tile {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition:
    border-color 0.15s,
    transform 0.15s;
  color: var(--text);
  text-decoration: none;
}
.tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.tile h3 {
  color: var(--text);
  margin-bottom: 6px;
}
.tile p {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
}
.tile-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* -------- Utilities -------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.center {
  text-align: center;
}

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 60px;
  }
  .nav-inner {
    padding: 10px 16px;
    gap: 12px;
  }
  .nav-logo {
    height: 28px;
  }
  .nav-brand-text {
    display: none;
  }
  h1 {
    font-size: 24px;
  }
  h2 {
    font-size: 17px;
  }
}
