/* AUTOR GEMINI */
/* No se CSS */

/* ==========================================================================
   1. Variables Globales (Valores en px y pocos colores)
   ========================================================================== */

:root {
  /* Tamaños de texto en px */
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-lg: 18px;

  /* Márgenes y espaciados reusables en px */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;

  --font-size-h5: 16px;
  --font-size-h4: 18px;
  --font-size-h3: 20px;
  --font-size-h2: 24px;
  --font-size-h1: 28px;

  /* Espaciados verticales reducidos para encabezados y párrafos */
  --space-paragraph-bottom: 12px;
  --space-heading-top: 20px;
  --space-heading-bottom: 8px;

  /* Tema Claro (Paleta de colores reducida) */
  --bg-color: #ffffff;
  --surface-color: #f8f9fa;
  --text-color: #212529;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --accent-color: #0d6efd;
  --error-bg: #f8d7da;
  --error-text: #842029;
  --success-bg: #d1e7dd;
  --success-text: #0f5132;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Tema Oscuro */
    color-scheme: light dark;
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --border-color: #333333;
    --accent-color: #bb86fc;
    --error-bg: #842029;
    --error-text: #ea868f;
    --success-bg: #133e29;
    --success-text: #75b798;
  }
}

/* ==========================================================================
   2. Normalización y Reset Básico
   ========================================================================== */

html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.5;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0 auto;
  max-width: 1000px;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: var(--font-size-base);
}

main {
  padding: var(--space-sm) var(--space-md);
}

/* ==========================================================================
   3. Estilos Nativos Preservados
   ========================================================================== */

/* Mantiene el aspecto e interacción nativa del navegador */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 1em;
  line-height: inherit;
  appearance: auto;
  -webkit-appearance: auto;
  margin: 0;
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: var(--space-xs);
  vertical-align: middle;
}

a {
  color: var(--accent-color);
  text-decoration: underline;
}

/* ==========================================================================
   4. Componentes Específicos (.header y .table)
   ========================================================================== */

/* Navbar */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-md);
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-left {
  margin-right: auto;
}

/* Alineación específica para elementos e inputs dentro del nav (.header) */
.header ul {
  align-items: center; /* Alinea verticalmente los <li> dentro de las listas */
}

.header li {
  display: flex;
  align-items: center; /* Alinea el texto <span> o enlaces dentro de cada <li> */
}

/* Anula la disposición en columna global para formularios inline dentro del nav */
form.form-inline {
  display: inline-flex;
  margin: 0;
  gap: 0;
}

form.form-inline input[type="submit"] {
  margin-top: 0; /* Remueve el margin-top de botones de formulario */
  align-self: center;
}

/* Tabla */
.table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: var(--font-size-base);
  background-color: var(--surface-color);
}

th, td {
  text-align: left;
}

.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-color);
}

/* ==========================================================================
   5. Párrafos con <math> y <code>
   ========================================================================== */

code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: var(--font-size-sm);
  color: var(--text-color);
  padding: 0;
  vertical-align: baseline;
}

p code {
  background-color: var(--surface-color);
}

math {
  display: inline-math;
  font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', serif;
  font-size: var(--font-size-lg);
  vertical-align: baseline;
  line-height: normal;
}

/* ==========================================================================
   6. Django Nativo: Formularios, Mensajes y Paginación
   ========================================================================== */

/* Agrupaciones y Fieldsets */
fieldset {
  max-width: 600px;
  margin: var(--space-md) auto;
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  background-color: var(--surface-color);
}

legend {
  font-size: var(--font-size-lg);
  font-weight: bold;
  padding: 0 var(--space-xs);
  color: var(--text-color);
}

/* Disposición de bloques en formularios (divs internos y form.as_p) */
form div,
form p {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-md);
  gap: var(--space-xs);
}

form label {
  font-weight: 600;
  color: var(--text-color);
}

form small,
.helptext {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

/* Botón de envío nativo */
form input[type="submit"],
form button[type="submit"] {
  align-self: flex-start;
  margin-top: var(--space-sm);
  padding: 0 var(--space-sm);
}

/* Mensajes de Django (django.contrib.messages) */
ul.messages {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0;
}

.messages li {
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

.messages li.success {
  background-color: var(--success-bg);
  color: var(--success-text);
}

.messages li.error,
.messages li.warning,
.messages li.info {
  background-color: var(--error-bg);
  color: var(--error-text);
}

/* Errores de formulario de Django (ul.errorlist) */
ul.errorlist {
  color: var(--error-text);
  background-color: var(--error-bg);
  list-style: none;
  padding: var(--space-xs) var(--space-sm);
  margin: var(--space-xs) 0 0 0;
  font-size: var(--font-size-sm);
}

ul.errorlist li {
  margin: 2px 0;
}

/* Paginación de Django */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin: var(--space-lg) 0;
  list-style: none;
  padding: 0;
}

.pagination .current,
.pagination .disabled {
  color: var(--text-muted);
  padding: var(--space-xs) var(--space-sm);
}

svg.bi,
.bi {
  display: inline;
  width: 1.25em;
  height: 1.25em;
  vertical-align: center;
  fill: currentColor;
  flex-shrink: 0;
}

/* Normalización de márgenes para todos los textos */
h1, h2, h3, h4, h5, h6, p, ul, ol, figure {
  margin-top: 0;
  margin-bottom: var(--space-paragraph-bottom);
}

/* Encabezados (H1 - H5) */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25; /* Line-height ajustado para títulos */
  color: var(--text-color);
  /* Agrega espacio superior solo cuando el encabezado sigue a otro elemento */
  margin-top: var(--space-heading-top);
  margin-bottom: var(--space-heading-bottom);
}


/* Si un encabezado va inmediatamente después de otro, reduce el espacio entre ellos */
h1 + h2, h2 + h3, h3 + h4, h4 + h5 {
  margin-top: var(--space-heading-bottom);
}

/* Tamaños de fuente exactos */
h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }
h5 { font-size: var(--font-size-h5); }
h6 { font-size: var(--font-size-base); font-weight: 600; }

/* Párrafos */
p {
  font-size: var(--font-size-base);
  line-height: 1.5;
  margin-bottom: var(--space-paragraph-bottom);
}

/* Contenedor principal */
.sample-test {
  margin-bottom: var(--space-md);
  font-family: inherit;
}

button[type="button"] {
  font-size: 1em;
  padding: 0 var(--space-sm);
}

.sample-test button {
  font-size: var(--font-size-sm);
}

/* Encabezado (Entrada / Salida) */
.sample-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-bottom: none;
  padding: 0.25rem 0.5rem;
  font-size: var(--font-size-base);
  color: var(--text-color);
}

/* Bloque de código */
.sample-content {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  line-height: 1;
}

.sample-content pre {
  margin: 0;
  font-family: monospace;
  color: var(--text-color);
}