/* Estilos específicos para la vista del libro */

/* Animaciones suaves */
.libro-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Efectos hover mejorados */
.articulo-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.articulo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Sidebar móvil mejorado */
.mobile-sidebar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Scrollbar personalizado */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Efectos de carga */
.loading-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Badges mejorados */
.badge-complejo {
    position: relative;
    overflow: hidden;
}

.badge-complejo::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.badge-complejo:hover::before {
    left: 100%;
}

/* Tooltips personalizados */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Efectos de texto */
.text-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Botones con efectos */
.btn-modern {
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.btn-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-modern:hover::before {
    left: 100%;
}

/* Cards con bordes animados */
.card-animated {
    position: relative;
    overflow: hidden;
}

.card-animated::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.card-animated:hover::before {
    transform: scaleX(1);
}

/* Navegación jerárquica mejorada */
.nav-item {
    position: relative;
    transition: all 0.2s;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #3b82f6;
    transform: scaleY(0);
    transition: transform 0.2s;
}

.nav-item:hover::before,
.nav-item.active::before {
    transform: scaleY(1);
}

/* Efectos de impresión */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-break {
        page-break-before: always;
    }
    
    .print-avoid-break {
        page-break-inside: avoid;
    }
}

/* Responsive mejorado */
@media (max-width: 640px) {
    .mobile-optimized {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
    
    .mobile-card {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .mobile-sidebar {
        width: 100vw;
        max-width: 320px;
    }
}

/* Efectos de focus mejorados */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

/* Estados de carga */
.loading-state {
    opacity: 0.6;
    pointer-events: none;
}

.loading-state::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Efectos de profundidad */
.depth-1 {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.depth-2 {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.depth-3 {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.depth-4 {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Transiciones suaves para todos los elementos */
* {
    transition: color 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* Estilos específicos para la vista de lectura */
.reading-content {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    color: #1e293b;
}

.reading-content article {
    page-break-inside: avoid;
}

.reading-content h2 {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1.5rem;
}

.reading-content .prose {
    font-size: 1.125rem;
    line-height: 1.75;
    color: #1e293b;
}

.reading-content .prose p {
    margin-bottom: 1.25rem;
    text-align: justify;
    hyphens: auto;
    color: #1e293b;
}

/* Configuraciones de lectura */
.reading-content.text-sm .prose,
.reading-content .prose.text-sm {
    font-size: 0.875rem;
}

.reading-content.text-lg .prose,
.reading-content .prose.text-lg {
    font-size: 1.25rem;
}

.reading-content.text-xl .prose,
.reading-content .prose.text-xl {
    font-size: 1.5rem;
}

.reading-content.leading-tight .prose,
.reading-content .prose.leading-tight {
    line-height: 1.4;
}

.reading-content.leading-relaxed .prose,
.reading-content .prose.leading-relaxed {
    line-height: 1.8;
}

.reading-content.leading-loose .prose,
.reading-content .prose.leading-loose {
    line-height: 2;
}

/* Anchos máximos */
.reading-content.max-w-2xl {
    max-width: 42rem;
}

.reading-content.max-w-4xl {
    max-width: 56rem;
}

.reading-content.max-w-6xl {
    max-width: 72rem;
}

/* Efectos de hover para botones de acción */
.reading-content button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Separadores estilizados */
.reading-content .separator {
    position: relative;
    height: 1px;
    background: linear-gradient(90deg, transparent, #cbd5e1, transparent);
}

/* Badges mejorados */
.reading-content .badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.reading-content .badge:hover {
    transform: scale(1.05);
}

/* Animaciones de entrada */
.reading-content article {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos para impresión */
@media print {
    .reading-content {
        font-size: 12pt;
        line-height: 1.6;
    }
    
    .reading-content article {
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }
    
    .reading-content .badge {
        border: 1px solid #000;
        background: white !important;
        color: black !important;
    }
    
    .reading-content button {
        display: none !important;
    }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .reading-content {
        padding: 1rem 1.5rem;
    }
    
    .reading-content .prose {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .reading-content h2 {
        font-size: 1.5rem;
    }
    
    /* Sidebars móviles mejorados */
    #filtersSidebar,
    #structureSidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    #filtersSidebar:not(.hidden),
    #structureSidebar:not(.hidden) {
        transform: translateX(0);
    }
    
    /* Overlay para sidebars móviles */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Controles táctiles mejorados */
    .theme-btn {
        min-height: 60px;
        touch-action: manipulation;
    }
    
    select, input, button {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Navegación táctil */
    .nav-item {
        min-height: 48px;
        touch-action: manipulation;
    }
}

/* Temas de color */
.theme-light {
    background: #ffffff;
    color: #1a202c;
}

.theme-light .reading-content {
    background: #ffffff;
    color: #1a202c;
    padding: 2rem 3rem;
}

.theme-light .reading-content h2 {
    color: #0f172a;
}

.theme-light .reading-content .prose {
    color: #1a202c;
}

.theme-light .reading-content .prose p {
    color: #1a202c;
}

.theme-light .reading-content .metadatos {
    color: #718096;
    background: #f7fafc;
    border-left-color: #e2e8f0;
}

/* Asegurar que los filtros mantengan su color original */
.theme-light #filtersSidebar,
.theme-light #structureSidebar {
    color: #1a202c;
}

.theme-light #filtersSidebar label,
.theme-light #structureSidebar label {
    color: #374151;
}

.theme-light #filtersSidebar select,
.theme-light #filtersSidebar input,
.theme-light #structureSidebar select,
.theme-light #structureSidebar input {
    color: #1a202c;
    background: #ffffff;
}

.theme-dark {
    background: #1a202c;
    color: #f7fafc;
}

.theme-dark .reading-content {
    background: #2d3748;
    color: #f7fafc;
    padding: 2rem 3rem;
}

.theme-dark .reading-content h2 {
    color: #e2e8f0;
}

.theme-dark .reading-content .prose {
    color: #e2e8f0;
}

.theme-dark .reading-content .prose p {
    color: #e2e8f0;
}

.theme-dark .reading-content .metadatos {
    color: #a0aec0;
    background: #4a5568;
    border-left-color: #718096;
}

/* Asegurar que los filtros mantengan su color original en tema oscuro */
.theme-dark #filtersSidebar,
.theme-dark #structureSidebar {
    color: #1a202c;
    background: #ffffff;
}

.theme-dark #filtersSidebar label,
.theme-dark #structureSidebar label {
    color: #374151;
}

.theme-dark #filtersSidebar select,
.theme-dark #filtersSidebar input,
.theme-dark #structureSidebar select,
.theme-dark #structureSidebar input {
    color: #1a202c;
    background: #ffffff;
}

.theme-sepia {
    background: #faf8f3;
    color: #2d3748;
}

.theme-sepia .reading-content {
    background: #fefcf7;
    color: #2d3748;
    padding: 2rem 3rem;
}

.theme-sepia .reading-content h2 {
    color: #1a202c;
}

.theme-sepia .reading-content .prose {
    color: #4a5568;
}

.theme-sepia .reading-content .prose p {
    color: #4a5568;
}

.theme-sepia .reading-content .metadatos {
    color: #718096;
    background: #f7fafc;
    border-left-color: #e2e8f0;
}

/* Asegurar que los filtros mantengan su color original en tema sepia */
.theme-sepia #filtersSidebar,
.theme-sepia #structureSidebar {
    color: #1a202c;
    background: #ffffff;
}

.theme-sepia #filtersSidebar label,
.theme-sepia #structureSidebar label {
    color: #374151;
}

.theme-sepia #filtersSidebar select,
.theme-sepia #filtersSidebar input,
.theme-sepia #structureSidebar select,
.theme-sepia #structureSidebar input {
    color: #1a202c;
    background: #ffffff;
}

/* Modo Zen - Solo texto */
.zen-mode {
    background: #fafafa !important;
}

.zen-mode .reading-content {
    max-width: 65ch !important;
    margin: 0 auto !important;
    padding: 2rem 3rem !important;
    font-family: 'Lora', 'Georgia', serif !important;
    font-size: 1.25rem !important;
    line-height: 1.8 !important;
    color: #2d3748 !important;
    background: #fafafa !important;
}

.zen-mode .reading-content article {
    margin-bottom: 3rem !important;
}

.zen-mode .reading-content h2 {
    font-size: 2rem !important;
    font-weight: 700 !important;
    color: #1a202c !important;
    margin-bottom: 2rem !important;
}

.zen-mode .reading-content .prose {
    font-size: 1.25rem !important;
    line-height: 1.8 !important;
    text-align: justify !important;
    color: #2d3748 !important;
}

.zen-mode .reading-content .prose p {
    margin-bottom: 1.5rem !important;
    text-indent: 2rem !important;
    color: #2d3748 !important;
}

.zen-mode .reading-content .metadatos {
    color: #718096 !important;
    background: #f7fafc !important;
    border-left-color: #e2e8f0 !important;
}

/* Modo Zen con tema oscuro */
.zen-mode.theme-dark {
    background: #1a202c !important;
}

.zen-mode.theme-dark .reading-content {
    background: #1a202c !important;
    color: #f7fafc !important;
    padding: 2rem 3rem !important;
}

.zen-mode.theme-dark .reading-content h2 {
    color: #e2e8f0 !important;
}

.zen-mode.theme-dark .reading-content .prose {
    color: #f7fafc !important;
}

.zen-mode.theme-dark .reading-content .prose p {
    color: #f7fafc !important;
}

.zen-mode.theme-dark .reading-content .metadatos {
    color: #a0aec0 !important;
    background: #4a5568 !important;
    border-left-color: #718096 !important;
}

/* Modo Zen con tema sepia */
.zen-mode.theme-sepia {
    background: #faf8f3 !important;
}

.zen-mode.theme-sepia .reading-content {
    background: #faf8f3 !important;
    color: #2d3748 !important;
    padding: 2rem 3rem !important;
}

.zen-mode.theme-sepia .reading-content h2 {
    color: #1a202c !important;
}

.zen-mode.theme-sepia .reading-content .prose {
    color: #4a5568 !important;
}

.zen-mode.theme-sepia .reading-content .prose p {
    color: #4a5568 !important;
}

.zen-mode.theme-sepia .reading-content .metadatos {
    color: #718096 !important;
    background: #f7fafc !important;
    border-left-color: #e2e8f0 !important;
}

/* Ocultar elementos en modo Zen */
.zen-mode .bg-white,
.zen-mode .border,
.zen-mode button:not(.zen-toggle),
.zen-mode .badge,
.zen-mode .separator {
    display: none !important;
}

/* Botón flotante para salir del modo Zen */
#zenExitButton {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    transition: all 0.3s ease;
}

#zenExitButton button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

#zenExitButton button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Asegurar que el botón sea visible en modo Zen */
.zen-mode #zenExitButton {
    display: block !important;
}

/* Tipografía mejorada para textos legales */
.reading-content {
    font-family: 'Lora', 'Georgia', serif;
}

.reading-content .prose {
    font-size: 1.125rem;
    line-height: 1.75;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    color: #1e293b;
}

.reading-content .prose p {
    margin-bottom: 1.5rem;
    text-indent: 1.5rem;
    color: #1e293b;
}

/* Jerarquía visual mejorada */
.reading-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 2rem;
    line-height: 1.2;
}

.reading-content .articulo-numero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Metadatos estilizados */
.reading-content .metadatos {
    font-size: 0.875rem;
    color: #718096;
    font-style: italic;
    margin-top: 1rem;
    padding: 1rem;
    background: #f7fafc;
    border-left: 4px solid #e2e8f0;
    border-radius: 0.5rem;
}

/* Separadores mejorados */
.reading-content .separator {
    margin: 3rem 0;
    text-align: center;
    position: relative;
}

.reading-content .separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #cbd5e1, transparent);
}

.reading-content .separator .separator-content {
    background: white;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
    color: #a0aec0;
    font-size: 0.875rem;
}

/* Animaciones de entrada mejoradas */
.reading-content article {
    animation: fadeInUp 0.8s ease-out;
    animation-fill-mode: both;
}

.reading-content article:nth-child(1) { animation-delay: 0.1s; }
.reading-content article:nth-child(2) { animation-delay: 0.2s; }
.reading-content article:nth-child(3) { animation-delay: 0.3s; }
.reading-content article:nth-child(4) { animation-delay: 0.4s; }
.reading-content article:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll spy para navegación */
.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-item.active::before {
    background: white !important;
}

/* Indicadores de filtros activos */
.filters-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.filters-indicator .filter-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin: 0.25rem;
    display: inline-block;
}

/* Botón de cargar más */
.load-more-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.load-more-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Estilos específicos para sidebars - siempre mantienen su apariencia */
#filtersSidebar,
#structureSidebar {
    background: #ffffff !important;
    color: #1a202c !important;
    border-left: 1px solid #e5e7eb !important;
}

#filtersSidebar h3,
#structureSidebar h3 {
    color: #111827 !important;
}

#filtersSidebar label,
#structureSidebar label {
    color: #374151 !important;
    font-weight: 500 !important;
}

#filtersSidebar select,
#filtersSidebar input,
#structureSidebar select,
#structureSidebar input {
    color: #1a202c !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
}

#filtersSidebar button,
#structureSidebar button {
    color: #ffffff !important;
    background: #3b82f6 !important;
}

#filtersSidebar button:hover,
#structureSidebar button:hover {
    background: #2563eb !important;
}

/* Asegurar que los botones de tema mantengan su apariencia */
.theme-btn {
    border: 2px solid #e5e7eb !important;
    background: #ffffff !important;
    color: #374151 !important;
}

.theme-btn.active,
.theme-btn.border-blue-500 {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
}

/* Radio buttons para fuente */
input[type="radio"] {
    accent-color: #3b82f6 !important;
}

/* Asegurar que los textos de los filtros sean legibles */
#filtersSidebar .text-sm,
#structureSidebar .text-sm {
    color: #6b7280 !important;
}

#filtersSidebar .font-medium,
#structureSidebar .font-medium {
    color: #374151 !important;
}
