/* Paleta de Colores y Variables (Estilo Evangeliario) */
:root {
    --bg-main: #fbf8f1;
    --bg-panel: rgba(251, 248, 241, 0.9);
    --bg-panel-solid: #f4eee1;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --accent-red: #a31f1f;
    --accent-red-hover: #7a1515;
    --border-color: rgba(163, 31, 31, 0.2);
    --glass-blur: blur(12px);
}

/* Reset Básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'EB Garamond', serif;
    height: 100vh;
    overflow: hidden;
    line-height: 1.7;
}

/* Layout Principal */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Barra Lateral de Libros */
.sidebar {
    width: 320px;
    background: var(--bg-panel-solid);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 0v20M0 10h20" stroke="%23a31f1f" stroke-width="0.5" fill="none" opacity="0.1"/></svg>');
}

.sidebar-header h1 {
    font-family: 'Cinzel', serif;
    color: var(--accent-red);
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar-header p {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-style: italic;
}

.book-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* Categorías y Libros */
.category-title {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--accent-red);
    padding: 1.5rem 1.5rem 0.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: color 0.2s;
}

.category-title:hover {
    color: var(--accent-red-hover);
}

.category-icon {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.category-title.collapsed .category-icon {
    transform: rotate(-90deg);
}

.category-books {
    overflow: hidden;
}

.category-books.collapsed {
    display: none;
}

.book-item {
    padding: 0.75rem 1.5rem 0.75rem 2.5rem;
    cursor: pointer;
    font-size: 1.15rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    color: #333;
}

.book-item:hover {
    background-color: rgba(163, 31, 31, 0.05);
    color: var(--accent-red);
}

.book-item.active {
    background-color: rgba(163, 31, 31, 0.08);
    border-left: 3px solid var(--accent-red);
    color: var(--accent-red);
    font-weight: 600;
}

/* Área de Lectura Central */
.reader-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    position: relative;
}

.reader-header {
    padding: 2rem 3rem;
    text-align: center;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}

.reader-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.2em;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.audio-controls {
    margin-top: 15px;
}

.audio-controls button {
    background-color: var(--bg-main);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    padding: 0.5rem 1rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    cursor: pointer;
    margin: 0 5px;
    border-radius: 4px;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.audio-controls button:hover {
    background-color: var(--accent-red);
    color: white;
}

.reader-content {
    flex: 1;
    padding: 3rem 12%;
    overflow-y: auto;
    font-size: 1.35em;
    scroll-behavior: smooth;
    text-align: justify;
}

.placeholder-text {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 20%;
    font-size: 1.2em;
}

/* Formato del texto dentro del lector */
.chapter-heading {
    font-family: 'Cinzel', serif;
    color: var(--accent-red);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.8em;
    text-align: center;
    border-bottom: 1px solid rgba(139, 0, 0, 0.2);
    padding-bottom: 0.5rem;
    letter-spacing: 2px;
}

.reader-content h3 {
    /* Mantenemos fallback para otros h3 por si acaso */
    font-family: 'Cinzel', serif;
    color: var(--accent-red);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.4em;
    text-align: center;
}

.reader-content p {
    margin-bottom: 1.5rem;
}

.verse-line {
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

/* Numeración de versículos */
.verse-number {
    color: var(--accent-red);
    font-weight: bold;
    margin-right: 3px;
    font-family: 'Cinzel', serif;
}

/* Panel Derecho de Búsqueda */
.search-panel {
    width: 350px;
    background: var(--bg-panel-solid);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.05);
}

.search-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.search-header h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-red);
    font-size: 1.3em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.search-header p {
    font-size: 1em;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.3rem;
}

.search-input-container {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: var(--bg-panel-solid);
}

.search-input-container input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    font-family: 'EB Garamond', serif;
    font-size: 1.1em;
}

.search-input-container input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 5px rgba(163, 31, 31, 0.2);
}

.search-input-container button {
    background-color: var(--bg-main);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    padding: 0.75rem;
    font-family: 'Cinzel', serif;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.search-input-container button:hover {
    background-color: var(--accent-red);
    color: white;
}

.search-results {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-red);
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: rgba(163, 31, 31, 0.05);
}

.search-result-title {
    font-family: 'Cinzel', serif;
    color: var(--accent-red);
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.search-result-snippet {
    font-size: 0.95em;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbars personalizadas */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel-solid);
}

::-webkit-scrollbar-thumb {
    background: rgba(163, 31, 31, 0.3);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(163, 31, 31, 0.6);
}

/* =========================================================================
   Responsive Design (Adaptación a Móvil / iPhone)
   ========================================================================= */
.mobile-only {
    display: none;
}

#close-sidebar-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--accent-red);
    cursor: pointer;
}

.reader-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

#mobile-menu-btn {
    position: absolute;
    left: 0;
    background: var(--bg-panel-solid);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: 0.85em;
    cursor: pointer;
    z-index: 10;
}

@media (max-width: 850px) {
    .mobile-only {
        display: block;
    }

    body {
        overflow: hidden;
        height: 100vh;
    }
    
    .app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* La barra de libros se convierte en un Menú Off-Canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        max-height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 5px 0 20px rgba(0,0,0,0.3);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-header {
        position: relative;
        padding: 2rem 1rem;
    }
    
    .sidebar-header h1 {
        font-size: 1.5rem;
    }

    /* El lector central ocupa el resto naturalmente */
    .reader-area {
        width: 100%;
        height: 100%;
        flex: 1;
        overflow: hidden;
    }
    
    .reader-header {
        padding: 1rem;
        background: var(--bg-main);
        z-index: 4;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }
    
    .reader-header h2 {
        font-size: 1.3em;
        margin: 0;
        padding: 0 60px; /* Espacio para el boton */
    }
    
    .reader-content {
        padding: 1.5rem 1rem 3rem 1rem;
        font-size: 1.25em; 
        height: calc(100vh - 80px);
        overflow-y: auto;
    }
    
    .chapter-heading {
        font-size: 1.5em;
        margin-top: 1rem;
    }

    /* Ocultamos el panel de búsqueda lateral en móvil por ahora para mantener limpia la lectura */
    .search-panel {
        display: none;
    }
}
