/* Professional Table of Contents Styles */

/* TOC Hero Section */
.toc-container-hero {
    position: relative;
}

.toc-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 12px 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    justify-content: space-between;
}

.toc-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.toc-preview {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 15px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.toc-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Professional TOC Widget */
.toc-widget {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.toc-widget:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 15px 50px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

/* Widget Header */
.widget-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.widget-title {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.widget-icon {
    font-size: 1.2rem;
}

/* Progress Circle */
.toc-progress-circle {
    position: relative;
    width: 30px;
    height: 30px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-dasharray: 75.4;
    stroke-dashoffset: 75.4;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

/* TOC List */
.toc-list-professional {
    padding: 0;
    margin: 0;
    list-style: none;
}

.toc-item {
    position: relative;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.toc-item:hover {
    background: rgba(59, 130, 246, 0.05);
}

.toc-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary-color);
}

.toc-item.active .toc-progress-indicator {
    width: 100%;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.toc-link:hover {
    color: white;
    transform: translateX(5px);
}

.toc-item.active .toc-link {
    color: white;
    font-weight: 600;
}

.toc-number {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.toc-item.active .toc-number {
    background: var(--primary-color);
    color: white;
}

.toc-text {
    flex: 1;
    line-height: 1.4;
    font-size: 0.9rem;
}

.toc-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.toc-progress-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    z-index: 1;
}

/* TOC Levels */
.toc-level-1 .toc-link {
    font-weight: 600;
    font-size: 1rem;
}

.toc-level-1 .toc-number {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.toc-level-2 .toc-link {
    padding-right: 2.5rem;
    font-size: 0.9rem;
}

.toc-level-2 .toc-number {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
}

.toc-level-3 .toc-link {
    padding-right: 3.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.toc-level-3 .toc-number {
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    background: rgba(147, 51, 234, 0.2);
    color: var(--secondary-color);
}

/* Reading Progress */
.toc-stats {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.progress-bar-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 10px 10px 0;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.progress-info {
    margin-top: 0.5rem;
}

.progress-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 500;
}

.progress-percentage {
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Mobile TOC Overlay */
.mobile-toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-toc-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-toc-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(145deg, rgba(13, 16, 25, 0.95), rgba(26, 26, 46, 0.95));
    backdrop-filter: blur(20px);
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    max-height: 70vh;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-toc-overlay.active .mobile-toc-content {
    transform: translateY(0);
}

.mobile-toc-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-toc-title {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.mobile-toc-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-toc-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.mobile-toc-body {
    padding: 1.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.mobile-toc-item {
    margin-bottom: 0.75rem;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.mobile-toc-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.mobile-toc-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--primary-color);
}

.mobile-toc-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-toc-link:hover {
    color: white;
}

.mobile-toc-item.active .mobile-toc-link {
    color: white;
    font-weight: 600;
}

.mobile-toc-number {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.mobile-toc-item.active .mobile-toc-number {
    background: var(--primary-color);
    color: white;
}

.mobile-toc-text {
    flex: 1;
    line-height: 1.4;
    font-size: 0.95rem;
}

/* Empty State */
.toc-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: rgba(255, 255, 255, 0.6);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* Scroll Animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toc-item {
    animation: slideInRight 0.3s ease-out;
}

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

/* Responsive Design */
@media (max-width: 991px) {
    .toc-widget {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-toc-content {
        max-height: 80vh;
    }
    
    .mobile-toc-body {
        max-height: 60vh;
    }
    
    .toc-toggle-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }
}

/* High Performance */
.toc-widget,
.mobile-toc-overlay {
    will-change: transform, opacity;
}

.toc-link,
.mobile-toc-link {
    will-change: transform, color;
}

/* Accessibility */
.toc-link:focus,
.mobile-toc-link:focus,
.toc-toggle-btn:focus,
.mobile-toc-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .toc-item,
    .mobile-toc-overlay,
    .mobile-toc-content,
    .toc-link,
    .mobile-toc-link,
    .progress-bar {
        animation: none;
        transition: none;
    }
}

/* Print Styles */
@media print {
    .toc-widget,
    .mobile-toc-overlay {
        display: none !important;
    }
}