/* ============================================
   ПЛАВАЮЩЕЕ СОДЕРЖАНИЕ СТАТЬИ
   Используем собственные классы, не конфликтующие с article_detail.css
   ============================================ */

.floating-toc {
    position: fixed;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.floating-toc.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   КНОПКА-ПЕРЕКЛЮЧАТЕЛЬ
   ============================================ */

.floating-toc__toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.35rem;
    background: linear-gradient(135deg, #6b46c1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.floating-toc__toggle:hover {
    transform: translateX(5px);
    box-shadow: 0 6px 20px rgba(107, 70, 193, 0.4);
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}

.floating-toc__toggle svg {
    flex-shrink: 0;
}

.floating-toc__toggle span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* ============================================
   ОВЕРЛЕЙ
   ============================================ */

.floating-toc__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 998;
    backdrop-filter: blur(2px);
}

.floating-toc.is-open .floating-toc__overlay {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   ПАНЕЛЬ СОДЕРЖАНИЯ
   ============================================ */

.floating-toc__panel {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translate(-120%, -50%); /* Объединяем в один transform */
    width: 480px;
    max-width: 90vw;
    height: 80vh; /* 80% высоты экрана вместо фиксированных 400px */
    max-height: 600px;
    background: #ffffff;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.floating-toc.is-open .floating-toc__panel {
    transform: translate(0, -50%); /* При открытии только центрируем по вертикали */
}

/* ============================================
   ЗАГОЛОВОК ПАНЕЛИ
   ============================================ */

.floating-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    background: linear-gradient(135deg, #6b46c1 0%, #8b5cf6 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.floating-toc__header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.floating-toc__close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.floating-toc__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ============================================
   КОНТЕНТ ПАНЕЛИ - НАШИ СОБСТВЕННЫЕ КЛАССЫ
   ============================================ */

.floating-toc__content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

/* Стилизация скроллбара */
.floating-toc__content::-webkit-scrollbar {
    width: 6px;
}

.floating-toc__content::-webkit-scrollbar-track {
    background: rgba(107, 70, 193, 0.05);
}

.floating-toc__content::-webkit-scrollbar-thumb {
    background: #6b46c1;
    border-radius: 10px;
}

.floating-toc__content::-webkit-scrollbar-thumb:hover {
    background: #8b5cf6;
}

/* Для Firefox */
.floating-toc__content {
    scrollbar-width: thin;
    scrollbar-color: #6b46c1 rgba(107, 70, 193, 0.05);
}

/* ============================================
   СПИСОК СОДЕРЖАНИЯ - СОБСТВЕННЫЕ КЛАССЫ
   ============================================ */

.floating-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.floating-toc-item {
    position: relative;
    padding: 0.85rem 0 0.85rem 1.5rem;
    margin: 0;
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.floating-toc-item:last-child {
    border-bottom: none;
}

.floating-toc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #6b46c1;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.floating-toc-item:hover {
    background: rgba(107, 70, 193, 0.05);
    padding-left: 2rem;
}

.floating-toc-item:hover::before {
    background: #8b5cf6;
    transform: translateY(-50%) scale(1.3);
}

.floating-toc-link {
    color: #4b5563;
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.6;
    transition: all 0.3s ease;
    display: block;
    font-weight: 500;
}

.floating-toc-item:hover .floating-toc-link {
    color: #6b46c1;
}

/* ============================================
   АНИМАЦИЯ ПОЯВЛЕНИЯ ЭЛЕМЕНТОВ
   ============================================ */

.floating-toc.is-open .floating-toc-item {
    animation: slideInLeft 0.3s ease forwards;
    opacity: 0;
}

.floating-toc.is-open .floating-toc-item:nth-child(1) { animation-delay: 0.05s; }
.floating-toc.is-open .floating-toc-item:nth-child(2) { animation-delay: 0.1s; }
.floating-toc.is-open .floating-toc-item:nth-child(3) { animation-delay: 0.15s; }
.floating-toc.is-open .floating-toc-item:nth-child(4) { animation-delay: 0.2s; }
.floating-toc.is-open .floating-toc-item:nth-child(5) { animation-delay: 0.25s; }
.floating-toc.is-open .floating-toc-item:nth-child(n+6) { animation-delay: 0.3s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

/* Планшеты */
@media (max-width: 1024px) {
    .floating-toc {
        left: 15px;
    }
    
    .floating-toc__panel {
        width: 420px;
        height: 350px;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .floating-toc {
        left: 10px;
    }
    
    .floating-toc__toggle {
        padding: 0.75rem 0.5rem;
        font-size: 0.7rem;
        gap: 0.4rem;
    }
    
    .floating-toc__toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .floating-toc__panel {
        width: 380px;
        height: 350px;
    }
    
    .floating-toc__header {
        padding: 1.25rem;
    }
    
    .floating-toc__header h3 {
        font-size: 1.1rem;
    }
    
    .floating-toc__content {
        padding: 1.25rem;
    }
    
    .floating-toc-link {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .floating-toc {
        left: 5px;
    }
    
    .floating-toc__toggle {
        padding: 0.6rem 0.4rem;
        border-radius: 10px;
    }
    
    .floating-toc__toggle svg {
        width: 18px;
        height: 18px;
    }
    
    .floating-toc__panel {
        width: 340px;
        height: 300px;
    }
    
    .floating-toc__header {
        padding: 1rem;
    }
    
    .floating-toc__header h3 {
        font-size: 1rem;
    }
    
    .floating-toc__close {
        width: 32px;
        height: 32px;
    }
    
    .floating-toc__content {
        padding: 1rem;
    }
    
    .floating-toc-item {
        padding: 0.65rem 0 0.65rem 1.25rem;
    }
    
    .floating-toc-link {
        font-size: 0.85rem;
    }
}

/* Скрываем текст на очень маленьких экранах */
@media (max-width: 360px) {
    .floating-toc__toggle span {
        display: none;
    }
    
    .floating-toc__toggle {
        padding: 0.75rem;
    }
}