/* =====================================================
   Tabla Periódica de Unicode — hoja de estilos
   Paleta: Negro asfalto, Gris pizarra, Púrpura intenso, Lila ceniza
   ===================================================== */

:root {
  --bg-color: #121214;
  --surface-color: #1c1c20;
  --surface-color-alt: #202027;
  --steel: #4A4D57;
  --purple: #5A189A;
  --lavender: #9D8EC1;
  --text-main: #f2f1f5;
  --text-muted: #b9b7c2;

  /* Color activo: lo sobreescribe script.js según la categoría seleccionada */
  --active-color: #5A189A;

  --panel-width: 340px;
  --header-height: auto;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Encabezado ---------- */

.app-header {
  padding: 1.25rem 2rem 1rem;
  background: linear-gradient(180deg, #17171b 0%, var(--bg-color) 100%);
  border-bottom: 1px solid var(--steel);
}

.header-top h1 {
  margin: 0 0 0.15rem;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
}

.header-top h1 .accent {
  color: var(--lavender);
}

.subtitle {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.category-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.category-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--steel);
  background-color: var(--surface-color);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.category-btn:hover {
  border-color: var(--lavender);
  transform: translateY(-1px);
}

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

/* ---------- Contenido principal ---------- */

.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.grid-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.25rem 2rem;
}

.grid-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  color: var(--active-color);
  transition: color 0.2s ease;
}

.grid-header p {
  margin: 0 0 0.2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 70ch;
}

.grid-range {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.78rem;
  color: var(--steel);
}

/* Cuadrícula estilo tabla periódica: se desplaza internamente si no cabe */
.character-grid {
  margin-top: 1rem;
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  align-content: start;
  padding-right: 0.5rem;
}

.char-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--steel);
  border-radius: 8px;
  background-color: var(--surface-color);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.char-cell:hover {
  background-color: var(--active-color);
  border-color: var(--active-color);
  transform: scale(1.06);
  z-index: 1;
}

.char-cell.selected {
  outline: 2px solid var(--lavender);
  outline-offset: -2px;
}

.char-cell .char-symbol {
  font-size: 1.5rem;
  line-height: 1;
}

.char-cell .char-code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.6rem;
  color: var(--text-muted);
}

.char-cell.unassigned {
  cursor: not-allowed;
  opacity: 0.35;
  border-style: dashed;
}

.char-cell.unassigned:hover {
  background-color: var(--surface-color);
  transform: none;
}

/* ---------- Panel de detalles ---------- */

.detail-panel {
  width: var(--panel-width);
  flex-shrink: 0;
  background-color: var(--surface-color-alt);
  border-left: 1px solid var(--steel);
  padding: 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.detail-panel.open {
  transform: translateX(0);
}

.close-btn {
  background: none;
  border: 1px solid var(--steel);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  float: right;
}

.close-btn:hover {
  border-color: var(--lavender);
  color: var(--lavender);
}

.detail-body {
  clear: both;
  padding-top: 0.5rem;
}

.detail-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2rem;
  text-align: center;
}

.detail-symbol {
  font-size: 4rem;
  text-align: center;
  margin: 0.5rem 0 1.25rem;
}

.detail-list {
  display: grid;
  grid-template-columns: auto;
  row-gap: 1rem;
}

.detail-list dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lavender);
  margin-bottom: 0.15rem;
}

.detail-list dd {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-main);
  font-family: "Consolas", "Courier New", monospace;
}

.detail-list dd.text-name {
  font-family: inherit;
}

/* ---------- Pie de página ---------- */

.app-footer {
  padding: 0.6rem 2rem;
  border-top: 1px solid var(--steel);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }

  .detail-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 10;
    border-left: none;
    transform: translateY(100%);
  }

  .detail-panel.open {
    transform: translateY(0);
  }
}

@media (max-width: 560px) {
  .app-header {
    padding: 1rem 1rem 0.85rem;
  }

  .grid-section {
    padding: 1rem;
  }

  .header-top h1 {
    font-size: 1.35rem;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  }
}
