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

:root {
    --sidebar-width: 300px;
    --header-height: 60px; /* Reducido de 80px a 60px */
    --primary-color: #007bff;
    --max-content-width: 1200px;
    --menu-bg: white;
    --content-bg: white;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.3; /* Reducido de 1.6 a 1.3 para disminuir el espacio vertical */
    color: #333;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ESTRUCTURA PRINCIPAL */
.container {
    width: 100%;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* CABECERA */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px; /* Reducido de 15px 20px a 10px 15px */
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: flex-start;
    min-height: var(--header-height);
    left: 0;
    transition: min-height 0.3s ease;
}

.header-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.logo-title-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    max-height: 30px; /* Reducido de 40px a 30px */
    width: auto;
}

.search-box {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.header-search {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
}

.button-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    display: none; /* Oculto por defecto, visible en móvil */
    align-self: flex-start;
    margin-right: 10px;
}

#search-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    font-size: 15px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

#search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#search-button {
    padding: 8px 15px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    white-space: nowrap;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#search-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.toggle-button {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    width: 33px;
    height: 33px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    flex-shrink: 0;
}

.toggle-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.toggle-button.flipped i {
    transform: rotate(180deg);
}

.toggle-button i {
    transition: transform 0.3s ease;
}

/* BLOQUE DE RESPUESTA */
#answer-container {
    padding: 15px 0;
    background-color: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    max-height: 300px;
    overflow-y: auto;
    transition: all 0.3s ease;
    opacity: 1;
    width: 100%;
    margin-top: 10px;
    position: relative;
    color: white;
    border-radius: 5px;
}

#answer-container.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
}

#answer {
    padding: 10px 20px;
    color: white; /* Ensure text is white */
}

#answer p, #answer li, #answer h1, #answer h2, #answer h3, #answer h4, #answer h5, #answer h6 {
    color: white; /* Force all text elements to be white */
}

/* Feedback form styling */
.feedback-container {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: white;
}

.feedback-container h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: white;
}

.feedback-input {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.feedback-input textarea, .feedback-input input[type="email"] {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    resize: none; /* Prevent textarea from being resizable */
}

.feedback-input textarea::placeholder, .feedback-input input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.submit-feedback-btn {
    padding: 8px 15px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    align-self: flex-end;
    transition: background-color 0.2s;
}

.submit-feedback-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.submit-feedback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feedback-success {
    color: #4caf50;
    font-weight: bold;
    text-align: center;
}

/* CONTENIDO PRINCIPAL */
main {
    margin-top: var(--header-height);
    flex: 1;
}

.docs-container {
    display: flex;
    width: 100%;
    margin: 0 auto;
    position: relative;
    overflow-x: hidden;
}

/* MENÚ LATERAL */
.docs-list {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--menu-bg);
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: transform 0.3s ease;
    z-index: 150;
}

/* CONTENIDO */
.content {
    flex: 1;
    background-color: var(--content-bg);
    padding: 20px;
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height));
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

/* Estilos para contenido Markdown */
.content > * {
    max-width: 800px;
    width: 100%;
}

/* Estilos para justificar el texto en markdown */
.content p, 
.content li, 
.content ul, 
.content ol {
    text-align: justify;
}

/* Reducir espacio entre párrafos (líneas en blanco) */
.content p {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.content p + p {
    margin-top: -0.1em; /* Margen negativo para acercar párrafos */
}

/* Reducir espacio entre listas */
.content ul,
.content ol {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Preservar espacios en blanco para fuentes monoespaciadas */
.content font[face="courier new"],
.content font[face="Courier New"],
.content font[face="courier"],
.content font[face="Courier"],
.content code,
.content pre {
    white-space: pre-wrap;
    font-family: "Courier New", Courier, monospace;
    line-height: 1.2; /* Reduce el espacio entre líneas para las fuentes monoespaciadas */
}

/* Aseguramos que el contenido se mantenga centrado cuando la ventana es más ancha que 800px */
@media (min-width: 800px) {
    .content {
        justify-content: center;
    }
}

/* En pantallas más pequeñas, aseguramos que el contenido se muestre correctamente */
@media (max-width: 799px) {
    .content > * {
        max-width: 100%;
    }
}

/* Estado del sidebar oculto */
.sidebar-hidden .docs-list {
    transform: translateX(-100%);
    visibility: hidden;
}

.sidebar-hidden .content {
    margin-left: 0;
    width: 100%;
}

/* Estilos de la lista de documentos */
#docs-list {
    list-style: none;
    margin-top: 10px;
}

#docs-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

#docs-list li:hover {
    color: var(--primary-color);
}

.folder-header {
    font-weight: bold;
    margin-top: 15px;
    color: #333;
    background-color: #f8f9fa;
    padding: 8px !important;
    border-radius: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer !important;
}

.folder-header:hover {
    background-color: #e9ecef;
}

.folder-header::after {
    content: "\25BC";
    font-size: 12px;
    transition: transform 0.3s ease;
}

.folder-header.collapsed::after {
    transform: rotate(-90deg);
}

.folder-content {
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease;
}

.folder-content.collapsed {
    max-height: 0;
}

.subfolder-item {
    padding-left: 15px !important;
    font-size: 0.95em;
}

#docs-content {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed #ccc;
}

/* FOOTER */
footer {
    text-align: center;
    margin-top: 20px;
    padding: 10px;
    color: #777;
}

/* UTILIDADES */
.hidden {
    display: none;
}

h1 {
    margin-bottom: 8px; /* Reducido de 10px a 8px */
    color: white;
    font-size: 18px; /* Reducido de 24px a 18px */
}

h2 {
    margin-bottom: 15px;
    color: #007bff;
}

/* Estilo para espaciado entre párrafos */
.paragraph-break {
    display: block;
    margin: 1em 0;
    height: 1px;
}

/* Estilos para imágenes en markdown */
.markdown-image {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* Estilos para la respuesta de la IA y documentos relacionados */
.ai-answer {
    background-color: rgba(255, 255, 255, 0.1);
    border-left: 4px solid rgba(255, 255, 255, 0.3);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    line-height: 1.6;
    color: white;
}

.ai-answer.error {
    border-left-color: #dc3545;
    background-color: rgba(255, 0, 0, 0.1);
}

.error {
    color: #dc3545;
    font-weight: bold;
}

.loading {
    color: white;
    font-style: italic;
    padding: 10px;
    text-align: center;
}

.related-docs {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.related-docs h3 {
    color: white;
    margin-bottom: 10px;
    font-size: 16px;
    opacity: 0.9;
}

.related-docs-list {
    list-style-type: none;
    padding: 0;
}

.related-docs-list li {
    margin-bottom: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.related-docs-list li:last-child {
    border-bottom: none;
}

.doc-link {
    color: #007bff;
    text-decoration: none;
    display: block;
    padding: 5px 0;
}

.doc-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Estilo para los botones de documentos */
.doc-button {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 5px 10px;
    text-align: left;
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    margin: 2px 0;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.doc-button:active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Estilos para el porcentaje de coincidencia */
.match-percentage {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    margin-left: 5px;
    font-weight: normal;
}

/* Estilos para el título del frontmatter */
.frontmatter-title {
    color: #333 !important;
    font-size: 1.5rem; /* Reducido de 2rem a 1.5rem */
    font-weight: bold;
    margin: 0 0 1rem 0; /* Reducido de 1.5rem a 1rem */
    padding-bottom: 0.5rem; /* Reducido de 0.75rem a 0.5rem */
    border-bottom: 1px solid var(--primary-color); /* Cambiado de 2px a 1px */
    text-align: center;
}

/* Asegurar que el título sea visible en el contenido del documento */
#content h1.frontmatter-title {
    color: #333 !important;
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Asegurar que el título sea visible en la respuesta */
#answer h1.frontmatter-title {
    color: #fff !important;
}

/* ===== MEDIA QUERIES ===== */

/* Para tablets */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 250px;
    }
}

/* Para dispositivos móviles (punto de quiebre donde el sidebar se oculta) */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    :root {
        --header-height: 150px;
    }
    
    header {
        padding: 10px 15px;
    }
    
    /* Permite que el header crezca cuando se muestra la respuesta */
    header.show-answer {
        min-height: 300px;
    }
    
    .header-content {
        gap: 8px;
    }
    
    .header-search {
        flex-wrap: wrap;
    }
    
    #search-input {
        flex: 1 1 100%;
        margin-bottom: 5px;
    }
    
    .button-group {
        width: 100%;
        justify-content: space-between;
    }
    
    #search-button {
        flex: 1;
        margin-right: 10px;
    }
    
    #answer-container {
        max-height: 200px;
    }
    
    /* Ajustar el sidebar para móviles */
    .docs-list {
        width: 85%;
        max-width: 300px;
    }
    
    /* Cuando se muestra el sidebar en móvil */
    .container:not(.sidebar-hidden) .docs-list {
        transform: translateX(0);
        visibility: visible;
    }
    
    /* El contenido siempre ocupa todo el ancho en móvil */
    .content {
        margin-left: 0;
        width: 100%;
    }
    
    /* Oscurecer el fondo cuando el menú está abierto */
    .container:not(.sidebar-hidden)::after {
        content: '';
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0,0,0,0.4);
        z-index: 140;
    }
}

/* Para móviles pequeños */
@media (max-width: 480px) {
    header h1 {
        font-size: 16px;
    }
    
    .logo-title-container {
        gap: 8px;
    }
    
    .header-logo {
        max-height: 30px;
    }
    
    .docs-list {
        width: 85%;
        max-width: 300px;
    }
    
    /* Asegurar que los botones no se apilen en móvil */
    .button-group {
        width: 100%;
        justify-content: space-between;
    }
    
    #search-button {
        max-width: calc(100% - 55px);
    }
    
    /* Ocultar completamente el contenido cuando el menú está abierto */
    .container:not(.sidebar-hidden) .content {
        opacity: 0.2;
        pointer-events: none;
    }
    
    /* Ajustar el overlay para que reciba clicks y cierre el menú */
    .container:not(.sidebar-hidden)::after {
        pointer-events: auto;
    }
}