/* Documentation Page Styles */
/* Ensure all elements include padding in width calculations */
* {
    box-sizing: border-box;
}

/* Three-column Layout */
.doc-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "left"
        "content"
        "right";
    gap: 2rem;
    position: relative;
    max-width: 100%;
    width: 100%;
    align-items: start; /* Align all grid items to the top by default */
}

.doc-content {
    grid-area: content;
    align-self: start; /* Ensure it starts at the top of the grid area */
}

/* Tablet layout */
@media (min-width: 768px) {
    .doc-layout {
        grid-template-columns: 280px 1fr;
        grid-template-areas:
            "left content"
            "left content";
    }
}

/* Desktop layout */
@media (min-width: 1280px) {
    .doc-layout {
        grid-template-columns: 280px minmax(0, 1fr) 280px;
        grid-template-areas: "left content right";
        gap: 2rem;
    }
}

.doc-sidebar {
    position: sticky;
    top: 5rem; /* Account for header height */
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    scrollbar-width: thin;
}

.doc-sidebar::-webkit-scrollbar {
    width: 4px;
}

.doc-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.doc-sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.doc-section-link {
    position: relative;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.doc-section-link.active {
    border-left-color: #a890dd;
    padding-left: 1rem !important;
}

/* Ensure text is visible when gradient background is applied */
.doc-section-link.bg-gradient-to-tr {
    color: white !important;
}

/* Override hover styles for active links */
.doc-section-link.active:hover {
    background-color: transparent !important;
    color: white !important;
}

/* Content Area Styles */
.doc-content-container {
    min-height: 500px;
    overflow: hidden; /* Ensure proper containment of floated elements */
}

.doc-content-section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Right Sidebar TOC Styles */

#toc-sidebar {
    overflow-y: hidden;
}

.doc-toc-container {
    width: 100%;
    background-color: #ffffff; /* white */
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    position: relative;
}

.doc-toc {
    padding: 1.25rem;
    max-height: calc(100vh - 7.5rem); /* Account for sticky top and container padding */
    overflow-y: auto;
    scrollbar-width: thin;
}

.doc-toc::-webkit-scrollbar {
    width: 3px;
}

.doc-toc::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.doc-toc::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.doc-toc-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #374151; /* gray-700 */
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.doc-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-toc-item {
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.doc-toc-link {
    color: #6b7280; /* gray-500 */
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    display: block;
    border-left: 2px solid transparent;
    padding: 0.25rem 0 0.25rem 0.5rem;
    margin-left: -0.5rem;
}

/* Style different heading levels */
.doc-toc-link.toc-h1 {
    font-weight: 600;
    font-size: 0.95rem;
}

.doc-toc-link.toc-h2 {
    font-weight: 500;
    font-size: 0.875rem;
}

.doc-toc-link.toc-h3 {
    font-size: 0.85rem;
}

.doc-toc-link.toc-h4 {
    font-size: 0.8rem;
    color: #9CA3AF; /* gray-400 */
}

.doc-toc-link.toc-h5 {
    font-size: 0.775rem;
    color: #9CA3AF; /* gray-400 */
}

.doc-toc-link:hover {
    color: #7c3aed; /* purple-600 */
    font-weight: 500;
}

.doc-toc-link.active {
    color: #7c3aed; /* purple-600 */
    border-left-color: #a855f7; /* purple-500 */
    font-weight: 500;
}

/* Code Block Styles */
pre {
    position: relative;
    border-radius: 0.5rem;
    background-color: #1e1e1e !important;
    padding: 1.25rem !important;
    margin: 1.5rem 0 !important;
    overflow-x: auto;
}

pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.copy-button {
    position: absolute !important;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
    border: none;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Typography Enhancements */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    scroll-margin-top: 5rem; /* Add scroll margin for anchor links */
    position: relative;
}

.markdown-content h1 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: #111827; /* gray-900 */
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
    padding-bottom: 0.5rem;
}

.markdown-content h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #111827; /* gray-900 */
}

.markdown-content h3 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #111827; /* gray-900 */
}

.markdown-content h4 {
    font-size: 1.125rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151; /* gray-700 */
}

.markdown-content h5 {
    font-size: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #4b5563; /* gray-600 */
}

.markdown-content h6 {
    font-size: 1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #4b5563; /* gray-600 */
}

.markdown-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
    color: #374151; /* gray-700 */
}

.markdown-content ul, .markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: #374151; /* gray-700 */
}

.markdown-content ul {
    list-style-type: disc;
}

.markdown-content ol {
    list-style-type: decimal;
}

.markdown-content li {
    margin-bottom: 0.5rem;
    color: #374151; /* gray-700 */
    display: list-item; /* Ensure list items display properly */
}

.markdown-content a {
    color: #7c3aed; /* purple-600 */
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content blockquote {
    border-left: 4px solid #7c3aed; /* purple-600 */
    margin-left: 0;
    color: #6b7280; /* gray-500 */
    font-style: italic;
    background-color: #f3f4f6; /* gray-100 */
    padding: 0.5rem 1rem;
    border-radius: 0 0.25rem 0.25rem 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    color: #374151; /* gray-700 */
}

.markdown-content table th {
    background-color: #f9fafb; /* gray-50 */
    font-weight: 600;
    text-align: left;
    padding: 0.75rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    color: #111827; /* gray-900 */
}

.markdown-content table td {
    padding: 0.75rem;
    border: 1px solid #e5e7eb; /* gray-200 */
}

.markdown-content table tr:nth-child(even) {
    background-color: #f9fafb; /* gray-50 */
}

.markdown-content table tr:nth-child(odd) {
    background-color: #ffffff; /* white */
}

/* Callout Boxes */
.markdown-content .callout {
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.markdown-content .callout.info {
    background-color: #eff6ff; /* blue-50 */
    border-left-color: #3b82f6; /* blue-500 */
}

.markdown-content .callout.warning {
    background-color: #fffbeb; /* yellow-50 */
    border-left-color: #f59e0b; /* yellow-500 */
}

.markdown-content .callout.danger {
    background-color: #fee2e2; /* red-50 */
    border-left-color: #ef4444; /* red-500 */
}

.markdown-content .callout.success {
    background-color: #ecfdf5; /* green-50 */
    border-left-color: #10b981; /* green-500 */
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .doc-layout {
        width: 100%;
        overflow-x: hidden; /* Prevent horizontal scrolling */
        padding: 0; /* Remove padding to prevent overflow */
        gap: 1rem; /* Reduce gap on mobile */
    }

    .doc-sidebar {
        position: relative;
        top: 0;
        max-height: none;
        padding-top: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Adjust the inner sidebar container padding on mobile */
    .doc-sidebar > div {
        padding: 0.75rem;
    }

    .doc-toc-container {
        position: relative;
        top: 0;
        padding-top: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .doc-content {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .doc-content-container {
        padding: 0.75rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box; /* Ensure padding is included in width calculation */
    }

    .markdown-content h1 {
        font-size: 1.75rem;
    }

    .markdown-content h2 {
        font-size: 1.35rem;
    }

    .markdown-content h3 {
        font-size: 1.15rem;
    }
}

/* Heading Labels (Non-clickable) */
.doc-heading-label {
    opacity: 0.8;
    user-select: none;
    position: relative;
}

.doc-heading-label::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(128, 0, 255, 0.1) 50%, transparent 100%);
    border-radius: 0.375rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.doc-heading-label:hover::after {
    opacity: 1;
}

/* Ensure content links remain interactive */
.doc-section-link {
    position: relative;
    z-index: 1;
}
