/**
 * VN Simple Table of Contents - CSS
 */

/* Main container */
.vn-toc-container {
    position: sticky;
    top: 20px;
    width: 280px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    font-size: 14px;
    z-index: 10;
    transition: all 0.3s ease;
}

/* Header */
.vn-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.vn-toc-header h4 {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Toggle button */
.vn-toc-toggle {
    background: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
}

.vn-toc-toggle:hover {
    background-color: #f0f0f0;
    border-color: #ccc;
}

.vn-toc-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 1px #ddd;
}

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

.vn-toc-sublist {
    padding-left: 15px;
    margin: 5px 0;
}

.vn-toc-item {
    margin: 8px 0;
    line-height: 1.4;
}

/* Links */
.vn-toc-link {
    text-decoration: none;
    color: #333;
    display: block;
    border-left: 2px solid transparent;
    padding: 4px 0 4px 10px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.vn-toc-link:hover {
    color: #ff6600;
    text-decoration: none;
}

.vn-toc-link.vn-toc-active {
    font-weight: bold;
    border-left: 2px solid #ff6600;
    color: #ff6600;
}

/* Heading level specific styles */
.vn-toc-h1 > .vn-toc-link {
    font-size: 15px;
    font-weight: 500;
}

.vn-toc-h2 > .vn-toc-link {
    font-size: 14px;
}

.vn-toc-h3 > .vn-toc-link {
    font-size: 13px;
}

.vn-toc-h4 > .vn-toc-link {
    font-size: 12px;
}


/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Print styles */
@media print {
    .vn-toc-container {
        display: none;
    }
}
/* Style cho highlighted target */
.vn-toc-target-highlight {
    background-color: rgba(255, 102, 0, 0.1) !important;
    transition: background-color 0.5s ease;
    padding: 5px 0;
    border-radius: 3px;
}

/* Hiệu ứng hover tốt hơn */
.vn-toc-link {
    transition: all 0.2s ease;
    display: block;
    padding: 5px 10px 5px 15px !important;
    margin: 2px 0;
    border-radius: 3px;
    border-left: 2px solid transparent !important;
}

.vn-toc-link:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.vn-toc-active {
    font-weight: bold !important;
    color: #ff6600 !important;
    border-left: 2px solid #ff6600 !important;
    background-color: rgba(255, 102, 0, 0.05);
}

/* Cải thiện kiểu dáng danh sách */
.vn-toc-list, .vn-toc-sublist {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

.vn-toc-sublist {
    padding-left: 15px !important;
    margin-left: 10px !important;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.vn-toc-item {
    margin: 5px 0 !important;
    line-height: 1.4 !important;
}

/* Cải thiện header */
.vn-toc-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    padding-bottom: 10px !important;
}

.vn-toc-header h4 {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}

/* Nút toggle tốt hơn */
.vn-toc-toggle {
    cursor: pointer !important;
    background: none !important;
    border: 1px solid #ddd !important;
    border-radius: 3px !important;
    width: 24px;
    height: 24px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    transition: all 0.2s ease !important;
    min-height: auto;
    margin: 0;
}

.vn-toc-toggle:hover {
    background-color: #f0f0f0 !important;
}

/* Fix cho việc heading bị nhảy khi cuộn tới */
h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
    scroll-margin-top: 80px; /* Điều chỉnh giá trị này bằng chiều cao menu fixed + 10px */
}


/* Responsive styles */
@media (max-width: 768px) {
    .vn-toc-container {
        position: relative;
        width: 100% !important;
        top: 0;
        margin-bottom: 30px;
    }

    .vn-toc-mobile {
        max-height: none;
    }
    
    .vn-toc-container {
        position: relative !important;
        top: 0 !important;
        width: 100% !important;
        margin-bottom: 30px;
    }
    .vn-toc-link{
    padding: 5px 10px 5px 0 !important;
}
}