/* Минималистичные стили для плагина учебника */

.book-tutorial-main,
.book-tutorial-chapter {
    padding: 40px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: transparent;
    color: inherit;
    min-height: auto;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Заголовок учебника */
.book-header {
    margin-bottom: 25px;
}

.book-title {
    text-decoration-color: var(--color-primary, #31358A);
    color: var(--color-frost-1000);
    font-size: 22px;
    line-height: 28px;
    margin-bottom: 24px;
    font-weight: bold;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* .book-description {
    display: none;
} */

/* Разделы */
.book-sections {
    display: block;
}

.book-section {
    margin-bottom: 25px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: inherit;
    margin-bottom: 20px;
    border: none;
    background: none;
    padding: 0;
}

/* Список глав - три колонки */
.section-chapters {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-left: 0;
}

.chapter-column {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.chapter-item {
    display: flex;
    align-items: flex-start;
    line-height: 1.5;
    margin-bottom: 8px;
}

.chapter-number {
    opacity: 0.6;
    font-weight: 500;
    min-width: 35px;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.chapter-link {
    color: var(--color-primary, #31358A);
    text-decoration: none;
    font-size: 0.9rem;
    margin-left: 8px;
    transition: color 0.2s ease;
    line-height: 1.4;
}

.chapter-link:hover {
    color: var(--color-primary-300, #6f73cc);
    text-decoration: underline;
}

/* Сообщения об отсутствии контента */
.no-chapters,
.no-sections {
    color: inherit;
    opacity: 0.6;
    font-style: italic;
    margin: 20px 0;
    width: 100%;
}

/* Стили для страницы главы */

/* External Sidebar Toggle Button (when sidebar is hidden) */
.sidebar-toggle-external {
    position: fixed;
    /* top: 20px; */
    left: 20px;
    z-index: 1002;
    background: var(--color-primary, #31358A);
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 3px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-external:hover {
    background: var(--color-primary-300, #6f73cc);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Internal Sidebar Toggle Button (inside sidebar) */
.sidebar-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1001;
    background: var(--color-primary, #31358A);
    border: none;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    display: none; /* Hidden on mobile by default */
    flex-direction: column;
    gap: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
    background: var(--color-primary-300, #6f73cc);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hamburger-line {
    display: block;
    width: 14px;
    height: 2px;
    background: white;
    transition: all 0.3s ease;
    border-radius: 1px;
}

.sidebar-toggle.toggle-active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.sidebar-toggle.toggle-active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle.toggle-active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Chapter Layout */
.chapter-layout {
    position: relative;
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* Chapter Sidebar */
.chapter-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--color-frost-0);
    border: 1px solid var(--color-frost-200);
    border-radius: 8px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    transition: all 0.3s ease;
    display: none; /* Hidden on mobile by default */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.chapter-sidebar.sidebar-hidden {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    width: 0;
    padding: 0;
    margin: 0;
}

.sidebar-header {
    margin-bottom: 0;
    padding: 15px;
    border-bottom: 1px solid var(--color-frost-200);
    background: var(--color-frost-50);
    border-radius: 8px 8px 0 0;
}

.sidebar-title {
    font: 14px / 20px BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-frost-800);
    margin: 0;
    font-weight: 600;
}

.sidebar-nav {
    padding: 15px;
}

/* TOC Styles */
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 4px;
}

.toc-link {
    display: block;
    padding: 6px 12px;
    color: var(--color-frost-600);
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.toc-link:hover {
    background: var(--color-frost-100);
    color: var(--color-primary);
    text-decoration: none;
}

.toc-link.toc-active {
    background: var(--color-primary);
    color: var(--color-frost-0);
}

/* TOC Level Indentation */
.toc-level-1 .toc-link { padding-left: 12px; font-weight: 600; }
.toc-level-2 .toc-link { padding-left: 24px; }
.toc-level-3 .toc-link { padding-left: 36px; }
.toc-level-4 .toc-link { padding-left: 48px; }
.toc-level-5 .toc-link { padding-left: 60px; }
.toc-level-6 .toc-link { padding-left: 72px; }

.no-headings {
    color: var(--color-frost-500);
    font-style: italic;
    margin: 0;
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

/* Main Content */
.chapter-main {
    flex: 1;
    min-width: 0;
    transition: all 0.3s ease;
}

/* Breadcrumbs */
.book-breadcrumbs {
    margin-bottom: 30px;
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    margin: 0 8px;
    color: #9ca3af;
}

.breadcrumb-item a {
    color: var(--color-primary, #31358A);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb-item a:hover {
    color: var(--color-primary-300, #6f73cc);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #9ca3af;
}

/* Заголовок главы */
.chapter-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #374151;
}

.chapter-title {
    font: 700 32px / 40px BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: inherit;
    margin-bottom: 15px;
    line-height: 1.3;
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 0.9rem;
    color: #9ca3af;
}

.chapter-date,
.chapter-section {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-icon,
.section-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

/* Контент главы */
.chapter-content {
    margin-bottom: 40px;
}

.chapter-article {
    line-height: 1.7;
    color: inherit;
}

.chapter-article h1,
.chapter-article h2,
.chapter-article h3,
.chapter-article h4,
.chapter-article h5,
.chapter-article h6 {
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: 600;
    color: inherit;
}

.chapter-article h1 { font-size: 1.6rem; }
.chapter-article h2 { 
    font-family: BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    font-size: 24px;
    line-height: 32px;
    margin: 24px 0 12px; 
}
.chapter-article h3 { font-size: 1.2rem; }
.chapter-article h4 { font-size: 1.1rem; }

.chapter-article p {
    margin-bottom: 15px;
    font: 14px / 20px BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.chapter-article ul,
.chapter-article ol {
    margin-bottom: 15px;
    padding-left: 30px;
}

.chapter-article li {
    margin-bottom: 5px;
}

.chapter-article blockquote {
    margin: 20px 0;
    padding: 15px 20px;
    border-left: 4px solid var(--color-primary, #31358A);
    background-color: #374151;
    font-style: italic;
    color: #d1d5db;
}

.chapter-article code {
    background-color: #374151;
    color: #f9fafb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.chapter-article pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #374151;
}

.chapter-article pre code {
    background: none;
    padding: 0;
}

/* Навигация по главам */
.chapter-navigation {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #374151;
}

.nav-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.nav-link {
    display: block;
    padding: 20px;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 8px;
    text-decoration: none;
    color: #f9fafb;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: #4b5563;
    text-decoration: none;
    color: #f9fafb;
    transform: translateY(-2px);
    border-color: var(--color-primary, #31358A);
}

.nav-prev {
    text-align: left;
}

.nav-next {
    text-align: right;
}

.nav-direction {
    display: block;
    font-size: 0.9rem;
    color: #9ca3af;
    margin-bottom: 5px;
}

.nav-title {
    display: block;
    font-weight: 600;
    color: #f9fafb;
    line-height: 1.3;
}

/* Desktop styles - show sidebar and toggle */
@media (min-width: 769px) {
    .chapter-sidebar {
        display: block; /* Show sidebar on desktop */
    }
    
    .sidebar-toggle {
        display: flex; /* Show internal toggle button on desktop */
    }
    
    .sidebar-toggle-external {
        display: none; /* Hide external button when sidebar is visible */
    }
    
    .chapter-sidebar.sidebar-hidden + .chapter-main ~ .sidebar-toggle-external,
    .sidebar-toggle-external.show {
        display: flex; /* Show external button when sidebar is hidden */
    }
}

/* Адаптивность */
@media (max-width: 900px) {
    .section-chapters {
        gap: 25px;
    }
    
    .chapter-column {
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .book-title {
        font-size: 1.75rem;
    }
    
    .chapter-title {
        font-size: 1.5rem;
    }
    
    .chapter-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-links {
        grid-template-columns: 1fr;
    }
    
    .nav-next {
        text-align: left;
    }
    
    .breadcrumb-list {
        font-size: 0.8rem;
    }
    
    .section-chapters {
        flex-direction: column;
        gap: 15px;
    }
    
    .chapter-column {
        min-width: auto;
        width: 100%;
    }
    
    .chapter-number {
        min-width: 35px;
    }
    
    /* Chapter page mobile adaptations */
    .chapter-layout {
        flex-direction: column;
        gap: 0;
    }
    
    .chapter-main {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .book-tutorial-main,
    .book-tutorial-chapter {
        padding: 20px 0;
    }
    
    .book-title {
        font-size: 1.5rem;
    }
    
    .chapter-title {
        font-size: 1.3rem;
    }
    
    .chapter-number {
        min-width: 30px;
        font-size: 0.85rem;
    }
    
    .chapter-link {
        font-size: 0.85rem;
    }
}
