/* Single Blog Page Styles - Scoped under .single-blog-page */
.single-blog-page {
    padding: 40px 0;
    background: #f8f9fa;
    min-height: calc(100vh - 200px);
}

.single-blog-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Blog Header with Horizontal Layout */
.single-blog-page .blog-header {
    background: white;
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    /* Ensure header stays in normal document flow */
    position: relative;
    top: auto;
    left: auto;
    z-index: auto;
}

.single-blog-page .blog-header.flex-container {
    display: flex;
    align-items: center;
    gap: 40px;
    /* Ensure flex container doesn't create positioning context issues */
    position: relative;
    overflow: visible;
}

.single-blog-page .blog-header-content {
    flex: 1;
}

.single-blog-page .blog-featured-image {
    flex: 0 0 400px;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    /* Ensure image does not move on scroll - stays within flex container */
    position: relative;
    top: auto;
    left: auto;
    will-change: auto; /* Prevent GPU layer issues */
}

.single-blog-page .blog-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.single-blog-page .blog-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #666;
    flex-wrap: wrap;
}

.single-blog-page .blog-author-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.single-blog-page .blog-author-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.single-blog-page .blog-author {
    font-weight: 500;
    color: #1976d2;
}

.single-blog-page .blog-date {
    color: #666;
}

.single-blog-page .blog-reading-time {
    color: #666;
}

.single-blog-page .blog-category {
    background: #e3f2fd;
    color: #1976d2;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Blog Layout Grid */
.single-blog-page .blog-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 10px;
    align-items: start;
}

/* Blog Content */
.single-blog-page .blog-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.single-blog-page .blog-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 40px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.single-blog-page .blog-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 30px 0 15px 0;
}

.single-blog-page .blog-content p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #333;
    margin-bottom: 20px;
}

.single-blog-page .blog-content ul,
.single-blog-page .blog-content ol {
    margin: 20px 0;
    padding-left: 30px;
}

.single-blog-page .blog-content li {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 10px;
}

.single-blog-page .blog-content a {
    color: #1976d2;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.single-blog-page .blog-content a:hover {
    border-bottom-color: #1976d2;
}

/* Code Blocks */
.single-blog-page .blog-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

.single-blog-page .blog-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.single-blog-page .blog-content pre code {
    background: none;
    padding: 0;
}

/* Table of Contents */
.single-blog-page .blog-toc {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 60px; /* Reduced top value for more space */
    align-self: flex-start; /* Ensures it sticks to the top of its grid area */
    z-index: 10; /* Ensure it stays above other content */
    min-height: 530px; /* Force minimum height */
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.single-blog-page .blog-toc::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.single-blog-page .blog-toc::-webkit-scrollbar-track {
    background: transparent;
}

.single-blog-page .blog-toc::-webkit-scrollbar-thumb {
    background: transparent;
    max-height: none; /* Explicitly remove max-height */
    height: auto; /* Allow natural height */
    overflow-y: auto; /* Add scroll if TOC is too long */
}

/* Mobile TOC Toggle */
.single-blog-page .toc-toggle {
    display: none;
    background: #1976d2;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 20px;
    width: 100%;
    text-align: left;
    transition: all 0.3s ease;
}

.single-blog-page .toc-toggle:hover {
    background: #1565c0;
}

.single-blog-page .toc-toggle.active {
    background: #1565c0;
}

/* TOC Close Button */
.single-blog-page .toc-close-btn {
    display: none;
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 15px;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
}

.single-blog-page .toc-close-btn:hover {
    background: #d32f2f;
}

/* Author Box */
.single-blog-page .author-box {
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    grid-column: 2; /* Position in main content column */
}

.single-blog-page .author-box-content {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.single-blog-page .author-box-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.single-blog-page .author-box-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.single-blog-page .author-box-info {
    flex: 1;
}

.single-blog-page .author-box-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 10px 0;
}

.single-blog-page .author-box-bio {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #666;
    margin: 0 0 15px 0;
}

.single-blog-page .author-box-social {
    display: flex;
    gap: 15px;
}

.single-blog-page .author-box-social .social-link {
    color: #1976d2;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 12px;
    border: 1px solid #1976d2;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.single-blog-page .author-box-social .social-link:hover {
    background: #1976d2;
    color: white;
}

.single-blog-page .author-box-social .social-link svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: all 0.3s ease;
}

.single-blog-page .author-box-social .social-link:hover svg {
    fill: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .single-blog-page .blog-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .single-blog-page .blog-toc {
        position: static;
        min-height: auto;
        margin-bottom: 20px;
        display: none; /* Hide by default on mobile */
        max-height: 400px; /* Set a reasonable height */
        overflow-y: auto; /* Add scroll if needed */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }
    
    .single-blog-page .blog-toc::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
    
    .single-blog-page .blog-toc::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .single-blog-page .blog-toc::-webkit-scrollbar-thumb {
        background: transparent;
        display: block; /* Show when toggled */
    }
    
    .single-blog-page .toc-toggle {
        display: block; /* Show toggle button on mobile */
    }
    
    .single-blog-page .toc-close-btn {
        display: block; /* Show close button on mobile */
    }
    
    .single-blog-page .blog-content {
        order: 2; /* Content comes after TOC on mobile */
    }
    
    .single-blog-page .blog-toc {
        order: 1; /* TOC comes first on mobile */
    }
    
    .single-blog-page .author-box {
        grid-column: 1; /* Full width on mobile */
        order: 3; /* After content on mobile */
        margin-top: 30px;
    }
    
    /* Ensure TOC list shows all items on mobile */
    .single-blog-page .toc-list {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .single-blog-page .toc-list div {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        text-indent: 0 !important;
        list-style: none !important;
        text-align: left !important;
    }
    
    .single-blog-page .toc-list a {
        display: block !important;
        width: 100% !important;
        color: #666 !important;
        text-decoration: none !important;
        font-size: 0.95rem !important;
        line-height: 1.4 !important;
        padding: 8px 12px !important;
        border-radius: 4px !important;
        text-align: left !important;
        text-indent: 0 !important;
        margin: 0 !important;
        font-weight: 500 !important;
        border-left: 3px solid transparent !important;
        box-sizing: border-box !important;
        position: static !important;
        float: none !important;
        clear: both !important;
    }
    
    /* Author Box Mobile Responsive */
    .single-blog-page .author-box-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .single-blog-page .author-box-image {
        margin-bottom: 15px;
    }
    
    .single-blog-page .author-box-social {
        justify-content: center;
    }
}

.single-blog-page .toc-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* Complete CSS reset for TOC */
.single-blog-page .toc-list,
.single-blog-page .toc-list *,
.single-blog-page .toc-list::before,
.single-blog-page .toc-list::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    text-indent: 0;
    list-style: none;
    text-align: left;
}

.single-blog-page .toc-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.single-blog-page .toc-list div {
    display: block;
    margin: 0;
    padding: 0;
    text-indent: 0;
    list-style: none;
    text-align: left;
}

.single-blog-page .toc-list a {
    color: #666;
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.4;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-align: left;
    text-indent: 0;
    margin: 0;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.single-blog-page .toc-list a:hover {
    color: #1976d2;
    background: #f8f9fa;
    border-left-color: #1976d2;
    padding-left: 16px;
}

.single-blog-page .toc-list a.active {
    color: #1976d2;
    background: #e3f2fd;
    border-left-color: #1976d2;
    padding-left: 16px;
    font-weight: 600;
}

/* H3 Sublist styling */
.single-blog-page .toc-h3-sublist {
    list-style: none;
    padding: 0;
    margin: 4px 0 8px 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: left; /* Ensure left alignment for H3 sublist */
}

.single-blog-page .toc-h3-sublist li {
    margin: 0;
    text-align: left; /* Ensure left alignment for H3 list items */
}

.single-blog-page .toc-h3-sublist a {
    font-size: 0.85rem;
    padding: 6px 12px 6px 24px; /* Indent H3 items */
    font-weight: 400;
    color: #777;
    border-left: 2px solid transparent;
    text-align: left !important; /* Force left alignment for H3 links */
}

.single-blog-page .toc-h3-sublist a:hover {
    color: #1976d2;
    background: #f8f9fa;
    border-left-color: #1976d2;
    padding-left: 28px;
}

.single-blog-page .toc-h3-sublist a.active {
    color: #1976d2;
    background: #e3f2fd;
    border-left-color: #1976d2;
    padding-left: 28px;
    font-weight: 500;
}

/* Fallback for standalone H3 items */
.single-blog-page .toc-list .toc-level-3 {
    margin-left: 0;
}

.single-blog-page .toc-list .toc-level-3 a {
    font-size: 0.85rem;
    padding: 6px 12px 6px 24px;
    font-weight: 400;
    color: #777;
    border-left: 2px solid transparent;
}

/* Callouts */
.single-blog-page .callout {
    background: #f0f8ff;
    border-left: 4px solid #1976d2;
    padding: 20px;
    margin: 30px 0;
    border-radius: 0 8px 8px 0;
}

.single-blog-page .callout.info {
    background: #f0f8ff;
    border-left-color: #1976d2;
}

.single-blog-page .callout.warning {
    background: #fff8e1;
    border-left-color: #f57c00;
}

.single-blog-page .callout.success {
    background: #f1f8e9;
    border-left-color: #689f38;
}

.single-blog-page .callout-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a1a1a;
}

/* Section Dividers */
.single-blog-page .section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin: 40px 0;
}

/* Responsive Design */
@media (max-width: 968px) {
    .single-blog-page .blog-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .single-blog-page .blog-toc {
        position: static;
        order: -1;
    }
    
    .single-blog-page .blog-header.flex-container {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }
    
    .single-blog-page .blog-featured-image {
        flex: 1;
        width: 100%;
        max-width: 500px;
        height: 300px;
    }
    
    .single-blog-page .blog-title {
        font-size: 2rem;
    }
    
    .single-blog-page .blog-header,
    .single-blog-page .blog-content {
        padding: 30px;
    }
}

@media (max-width: 768px) {
    .single-blog-page {
        padding: 20px 0;
    }
    
    .single-blog-page .container {
        padding: 0 15px;
    }
    
    .single-blog-page .blog-title {
        font-size: 1.75rem;
    }
    
    .single-blog-page .blog-header,
    .single-blog-page .blog-content {
        padding: 25px;
    }
    
    .single-blog-page .blog-meta {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .single-blog-page .blog-featured-image {
        height: 250px;
    }
    
    .single-blog-page .blog-content h2 {
        font-size: 1.5rem;
    }
    
    .single-blog-page .blog-content h3 {
        font-size: 1.25rem;
    }
    
    .single-blog-page .blog-content p,
    .single-blog-page .blog-content li {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .single-blog-page .blog-header,
    .single-blog-page .blog-content {
        padding: 20px;
    }
    
    .single-blog-page .blog-title {
        font-size: 1.5rem;
    }
    
    .single-blog-page .blog-featured-image {
        height: 200px;
    }
}
