 /* ==========================================================================
   Configuración General (Normas APA 7ma Edición - Optimizado Web)
   ========================================================================== */

/* Configuración de impresión para los márgenes de 1 pulgada (2.54 cm) */
@page {
    size: auto;
    margin: 1in;
}

body {
    /* Fuentes permitidas: Times New Roman 16px */
    font-family: "Times New Roman", Times, serif;
    font-size: 16px;
    /* Interlineado doble en todo el documento */
    line-height: 2;
    /* Alineación a la izquierda, sin justificar */
    text-align: left;
    /* Color de texto estándar */
    color: #000;
    /* Márgenes base para la web (simulando la hoja) */
    max-width: 8.5in;
    margin: 0 auto;
    padding: 1in;
    background-color: white;
}

/* ==========================================================================
   Párrafos y Sangrías
   ========================================================================== */

p {
    /* Sangría de primera línea de 0.5 pulgadas (1.27 cm) */
    text-indent: 0.5in;
    /* Sin espacio adicional entre párrafos */
    margin-top: 0;
    margin-bottom: 0;
}

/* ==========================================================================
   Jerarquía de Títulos (Headings)
   ========================================================================== */

h1, h2, h3, h4, h5 {
    text-indent: 0;
    line-height: 2;
    margin-top: 0;
    margin-bottom: 0;
    color: #000;
}

/* Nivel 1: Centrado, Negrita, Mayúsculas y Minúsculas */
h1 {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 24pt; /* Espacio adicional después del título principal */
}

/* Nivel 2: Alineado a la izquierda, Negrita, Mayúsculas y Minúsculas */
h2 {
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    margin-top: 24pt;   /* Separación antes de cada sección principal */
}

/* Nivel 3: Alineado a la izquierda, Negrita, Cursiva, Mayúsculas y Minúsculas */
h3 {
    font-size: 16px;
    font-weight: bold;
    font-style: italic;
    text-align: left;
    margin-top: 16px;
}

/* ==========================================================================
   Citas en Bloque (Blockquotes - más de 40 palabras)
   ========================================================================== */

blockquote {
    /* Sangría en todo el bloque de 0.5 pulgadas desde el margen izquierdo */
    margin-left: 0.5in;
    margin-right: 0;
    margin-top: 16px;
    margin-bottom: 16px;
    text-indent: 0;
    line-height: 2;
    /* Modificación adaptativa: Contraste gris amigable */
    background-color: #f9f9f9;
    border-left: 3.5px solid #333333;
    padding: 6px 16px;
}

/* Si la cita en bloque tiene más de un párrafo, el segundo en adelante lleva sangría */
blockquote p + p {
    text-indent: 0.5in;
}

blockquote p {
    text-indent: 0; /* Asegura que el primer párrafo de la cita no herede sangría errónea */
}

/* ==========================================================================
   Citas cortas (q) y Elementos de Citación
   ========================================================================== */
q {
    font-style: normal;
    quotes: "“" "”" "‘" "’";
}

cite {
    font-style: italic;
}

/* ==========================================================================
   Referencias (Sangría Francesa)
   ========================================================================== */

.lista-referencias {
    /* Título de Referencias centrado y en negrita (como un h1) */
    text-align: left;
    text-indent: 0;
    margin-bottom: 16px;
    page-break-before: always; /* Inicia en una nueva página al imprimir */
    list-style: none;
    padding-left: 0;
}

.referencia {
    /* Sangría francesa (Hanging indent) de 0.5 pulgadas */
    padding-left: 0.5in;
    text-indent: -0.5in;
    margin-top: 0;
    margin-bottom: 0;
    list-style-type: none;
}

.titulo-fuente {
    font-style: italic;
}

/* ==========================================================================
   Tablas (Normas APA 7ma Edición)
   ========================================================================== */

.apa-table-container {
    margin-top: 24pt;
    margin-bottom: 24pt;
    text-align: left;
}

.apa-table-number {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 0;
    margin-top: 0;
    text-indent: 0;
    line-height: 2;
}

.apa-table-title {
    font-style: italic;
    font-size: 16px;
    margin-top: 0;
    margin-bottom: 16px;
    text-indent: 0;
    line-height: 2;
}

table.apa-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    line-height: 1.5;
    font-size: 11pt; /* Ligera reducción para mejor ajuste, manteniendo legibilidad */
}

table.apa-table th,
table.apa-table td {
    border: none;
    padding: 4px 8px;
    text-align: left;
    vertical-align: top;
}

/* Líneas horizontales de los encabezados (Arriba y abajo del thead) */
table.apa-table thead th {
    border-top: 1.5px solid #000;
    border-bottom: 1px solid #000;
    font-weight: normal;
    text-align: left;
    vertical-align: bottom;
}

/* Línea horizontal final de la tabla */
table.apa-table tbody tr:last-child td {
    border-bottom: 1.5px solid #000;
}

.apa-table-note {
    font-size: 16px;
    line-height: 2;
    margin-top: 0;
    margin-bottom: 0;
    text-indent: 0;
    text-align: left;
}

/* Ajuste para que los títulos de las tablas no lleven sangría */
.apa-table-container p,
.apa-table-number,
.apa-table-title {
    text-indent: 0;
}

/* Estilo para encabezados de sección dentro de artículos */
article h4 {
    font-weight: bold;
    font-style: normal;
    margin-top: 16px;
    text-indent: 0;
}

/* ==========================================================================
   BARRA DE NAVEGACIÓN (JavaScript DOM)
   ========================================================================== */
html {
    scroll-behavior: smooth;
}

/* Compensar la barra fija */
body {
    padding-top: calc(1in + 50px);
}

#barra-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #111111;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    z-index: 9999;
    box-sizing: border-box;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    font-family: Arial, Helvetica, sans-serif;
}

#nav-izquierda {
    display: flex;
    align-items: center;
    gap: 12px;
}

#titulo-nav {
    color: #aaaaaa;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.btn-nav {
    background-color: #252525;
    color: #cccccc;
    border: 1px solid #3a3a3a;
    padding: 5px 12px;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    border-radius: 3px;
}

.btn-nav:hover {
    background-color: #363636;
    color: #ffffff;
}

#nav-derecha {
    display: flex;
    align-items: center;
    gap: 6px;
}

#indicador-fuente {
    color: #777777;
    font-size: 10px;
    min-width: 30px;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
}

/* Panel desplegable del índice */
#panel-contenido {
    display: none;
    position: fixed;
    top: 42px;
    left: 0;
    width: 290px;
    background-color: #191919;
    border-right: 1px solid #2e2e2e;
    border-bottom: 1px solid #2e2e2e;
    z-index: 9998;
    padding: 10px 0;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.6);
    font-family: Arial, Helvetica, sans-serif;
    max-height: calc(100vh - 42px);
    overflow-y: auto;
}

#panel-contenido ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#panel-contenido li {
    padding: 0;
    text-indent: 0;
    margin: 0;
    list-style-type: none;
}

#panel-contenido > ul > li > a {
    display: block;
    padding: 8px 18px;
    color: #cccccc;
    text-decoration: none;
    font-size: 12px;
    font-weight: bold;
    border-left: 3px solid transparent;
}

#panel-contenido > ul > li > a:hover {
    background-color: #262626;
    color: #ffffff;
    border-left-color: #555555;
}

#panel-contenido ul ul {
    padding: 0;
    margin: 0;
    border-left: 1px solid #2a2a2a;
    margin-left: 18px;
}

#panel-contenido ul ul li a {
    display: block;
    padding: 5px 14px 5px 14px;
    color: #888888;
    text-decoration: none;
    font-size: 11px;
    border-left: 3px solid transparent;
}

#panel-contenido ul ul li a:hover {
    background-color: #262626;
    color: #cccccc;
    border-left-color: #444444;
}

@media print {
    #barra-nav,
    #panel-contenido {
        display: none !important;
    }
    body {
        padding-top: 1in !important;
    }
}