/* Custom styles for Markdown Documentation Viewer */

/* Ensure proper overflow behavior */
html, body {
    height: 100%;
    overflow: hidden;
}

.vh-100 {
    height: 100vh !important;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    z-index: 1050;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: none;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle i {
    font-size: 1.4rem;
}

/* Toggle button position - Desktop */
@media (min-width: 768px) {
    /* When sidebar is OPEN - button floats at the right edge of sidebar */
    .sidebar-toggle {
        top: 1rem;
        left: calc(25% - 60px); /* Position inside sidebar, near right edge */
        background-color: rgba(13, 110, 253, 0.9);
    }
    
    /* When sidebar is COLLAPSED - button at left edge of screen */
    .sidebar.collapsed ~ .main-content .sidebar-toggle {
        top: 50px;
        left: 1rem;
        background-color: #0d6efd;
    }
}

@media (min-width: 992px) {
    .sidebar-toggle {
        top: 7px;
        left: calc(16.666667% - 60px); /* Adjust for lg breakpoint */
    }
}

/* Toggle button position - Mobile */
@media (max-width: 767.98px) {
    .sidebar-toggle {
        top: 2px;
        right: 0.2rem;
    }
    
    /* Hide toggle button when sidebar is open on mobile */
    .sidebar.show ~ .main-content .sidebar-toggle {
        opacity: 0;
        pointer-events: none;
    }
}

/* Sidebar Responsive Styles */
.sidebar {
    transition: all 0.3s ease;
}

/* Mobile: Sidebar overlay */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1040;
        transform: translateX(-100%);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    /* Backdrop for mobile */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1030;
        display: none;
    }
    
    .sidebar-backdrop.show {
        display: block;
    }
}

/* Desktop: Toggle sidebar */
@media (min-width: 768px) {
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 25%;
        max-width: 280px;
        z-index: 1000;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 25%;
        width: 75%;
        max-width: 75%;
        flex: 0 0 75%;
        transition: all 0.3s ease;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
}

@media (min-width: 992px) {
    .sidebar {
        width: 16.666667%;
        max-width: none;
    }
    
    .main-content {
        margin-left: 16.666667%;
        width: 83.333333%;
        max-width: 83.333333%;
        flex: 0 0 83.333333%;
    }
}

/* Sidebar Customization */
.folder-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.file-link {
    color: #e2e8f0;
    transition: all 0.2s;
}

.file-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding-left: 1rem !important;
}

.file-link.active {
    background-color: #0d6efd !important;
    color: #fff !important;
    font-weight: 600;
}

.file-link.active i {
    color: #fff !important;
}

/* Search Results */
.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.2s;
    color: #212529;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    color: #0d6efd;
    margin-bottom: 0.25rem;
}

.search-result-context {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: #6c757d;
}

/* Markdown Body Styles */
.markdown-body {
    max-width: 900px;
    margin: 0 auto;
}

.markdown-body h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

.markdown-body h2 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.markdown-body h3 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.markdown-body p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: #d63384;
}

.markdown-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.9rem;
}

.markdown-body blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #6c757d;
    font-style: italic;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.markdown-body table th,
.markdown-body table td {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    text-align: left;
}

.markdown-body table th {
    background: #f8f9fa;
    font-weight: 600;
}

.markdown-body a {
    color: #0d6efd;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

/* Error Message */
.error {
    color: #dc3545;
    background: #f8d7da;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #dc3545;
}

/* Copy Button for Code Blocks */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.25rem;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Custom Scrollbar */
.overflow-auto::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.overflow-auto::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-auto::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.overflow-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.bg-dark .overflow-auto::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.bg-dark .overflow-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Breadcrumb area responsive padding */
@media (max-width: 767.98px) {
    .bg-light.border-bottom {
        padding-top: .7rem !important;
        padding-bottom: .7rem !important;
    }
}
