/* Wiki-specific styles with light backgrounds */
.wiki-container {
    margin-top: 2rem;
}

.wiki-header {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%) !important;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.wiki-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.05);
    pointer-events: none;
}

.wiki-header .container {
    position: relative;
    z-index: 1;
}

.wiki-header h1 {
    color: var(--primary-color) !important;
    font-weight: 700;
    text-shadow: none;
}

.wiki-header .lead {
    color: var(--text-color) !important;
    font-weight: 400;
}

.wiki-header .badge {
    background: var(--primary-color) !important;
    color: white !important;
    border: 1px solid var(--primary-color);
}

.wiki-sidebar {
    /* ENHANCED: Better positioning calculation with additional buffer */
    top: calc(var(--navbar-height, 80px) + 2rem);
    z-index: 999; /* Ensure it stays below the navbar */
    /* ADDED: Max height to prevent overflow with larger buffer */
    max-height: calc(100vh - var(--navbar-height, 80px) - 4rem);
    overflow-y: auto;
}

.wiki-sidebar .card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    background: white;
    overflow: hidden;
}

.wiki-sidebar .card-header {
    background: white !important;
    border-bottom: 2px solid var(--border-color);
    color: var(--dark-color) !important;
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    /* ADDED: Sticky header within the sidebar */
    position: sticky;
    top: 0;
    z-index: 10;
}

.wiki-sidebar .list-group-item {
    border: none;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    padding: 1rem 1.5rem;
    transition: var(--transition);
    background: white;
    color: var(--text-color);
    font-weight: 500;
}

.wiki-sidebar .list-group-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(8px);
    color: var(--primary-color);
}

.wiki-sidebar .list-group-item.active {
    background: var(--primary-color) !important;
    color: white !important;
/*    border-left: 4px solid var(--primary-dark); */
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

/* ADDED: Hierarchical navigation styles */
.installation-section {
    position: relative;
}

.wiki-sidebar .list-group-item.subsection {
    padding: 0.75rem 1rem 0.75rem 2rem;
    font-size: 0.9rem;
    border-left: 2px solid var(--border-color);
    background: #f8fafc;
    margin-left: 1rem;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.wiki-sidebar .list-group-item.subsection:hover {
    background: rgba(102, 126, 234, 0.08);
    border-left-color: var(--primary-color);
    transform: translateX(4px);
}

.wiki-sidebar .list-group-item.subsection.active {
    background: rgba(102, 126, 234, 0.15) !important;
    color: var(--primary-color) !important;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.toggle-icon {
    transition: var(--transition);
    font-size: 0.8rem;
}

.wiki-sidebar .list-group-item i {
    width: 24px;
    opacity: 0.8;
    transition: var(--transition);
}

.wiki-sidebar .list-group-item:hover i,
.wiki-sidebar .list-group-item.active i {
    opacity: 1;
    transform: scale(1.1);
}

.wiki-sidebar .bg-light {
    background: #f8fafc !important;
    color: var(--text-light) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    padding: 0.75rem 1.5rem;
}

.wiki-content {
    padding-left: 2rem;
}

.wiki-section {
    /* ENHANCED: Increased scroll margin with larger buffer */
    scroll-margin-top: calc(var(--navbar-height, 80px) + 3rem);
    margin-bottom: 2rem;
    /* ADDED: Smoother scroll behavior */
    scroll-behavior: smooth;
}

/* ADDED: Subsection styling */
.wiki-section.subsection .card {
    border-left: 4px solid var(--primary-color);
    margin-left: 1rem;
}

.wiki-section.subsection .card-header {
    background: rgba(102, 126, 234, 0.05) !important;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.wiki-section .card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    background: white;
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.wiki-section .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

.wiki-section .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.wiki-section .card-header {
    background: white !important;
    border-bottom: 3px solid rgba(102, 126, 234, 0.1);
    padding: 1.5rem 2rem;
    position: relative;
}

.wiki-section .card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 2rem;
    right: 2rem;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

.wiki-section .card-header h2 {
    color: var(--dark-color) !important;
    font-weight: 700;
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

.wiki-section .card-header h3 {
    color: var(--dark-color) !important;
    font-weight: 600;
    margin-bottom: 0;
    letter-spacing: -0.01em;
}

.wiki-section .card-header i {
    color: var(--primary-color) !important;
    margin-right: 0.75rem;
    font-size: 1.5rem;
}

.wiki-section .card-body {
    padding: 2rem;
    line-height: 1.7;
    background: white;
}

/* ADDED: Breadcrumb styling */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb-item a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-light);
    font-weight: 500;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--text-light);
    font-weight: 600;
}

.wiki-section h5 {
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    position: relative;
    padding-left: 1rem;
}

.wiki-section h5::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 4px;
    height: 1rem;
    background: var(--primary-color);
    border-radius: 2px;
}

.wiki-section h6 {
    color: var(--text-color);
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.wiki-section pre {
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-left: 6px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.wiki-section code {
    background: #f1f5f9;
    color: var(--primary-dark);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.api-endpoint {
    background: rgba(16, 185, 129, 0.05);
    border: 2px solid rgba(16, 185, 129, 0.2);
    border-left: 6px solid var(--success-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.api-endpoint:hover {
    transform: translateX(4px);
    border-color: var(--success-color);
    box-shadow: var(--shadow-md);
    background: rgba(16, 185, 129, 0.1);
}

.api-endpoint h6 {
    margin-bottom: 0.75rem;
    color: var(--success-color);
    font-weight: 700;
}

.api-endpoint .badge {
    font-size: 0.75rem;
    margin-right: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    letter-spacing: 0.025em;
}

.api-endpoint pre {
    margin-top: 1rem;
    margin-bottom: 0;
}

.wiki-section table {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin: 1.5rem 0;
}

.wiki-section table thead th {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 600;
    padding: 1rem;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-size: 0.875rem;
}

.wiki-section table tbody tr {
    transition: var(--transition);
    background: white;
}

.wiki-section table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.wiki-section table tbody td {
    padding: 1rem;
    border-color: var(--border-color);
    vertical-align: middle;
    background: white;
}

.checklist {
    background: rgba(102, 126, 234, 0.05);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    position: relative;
}

.checklist::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.checklist .form-check {
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.checklist .form-check:hover {
    transform: translateX(4px);
}

.checklist .form-check-input {
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    background: white;
}

.checklist .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checklist .form-check-label {
    font-weight: 500;
    color: var(--text-color);
    margin-left: 0.5rem;
}

.wiki-section .alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    position: relative;
    overflow: hidden;
    background: white;
}

.wiki-section .alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.wiki-section .alert-info {
    background: rgba(6, 182, 212, 0.05);
}

.wiki-section .alert-info::before {
    background: var(--info-color);
}

.wiki-section .alert-success {
    background: rgba(16, 185, 129, 0.05);
}

.wiki-section .alert-success::before {
    background: var(--success-color);
}

.wiki-section .alert-warning {
    background: rgba(245, 158, 11, 0.05);
}

.wiki-section .alert-warning::before {
    background: var(--warning-color);
}

.wiki-section .alert-primary {
    background: rgba(102, 126, 234, 0.05);
}

.wiki-section .alert-primary::before {
    background: var(--primary-color);
}

.accordion {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.accordion-item {
    border: none;
    background: white;
}

.accordion-header .accordion-button {
    background: white !important;
    color: var(--dark-color) !important;
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    border: none;
    transition: var(--transition);
}

.accordion-button:hover {
    background: rgba(102, 126, 234, 0.05) !important;
}

.accordion-button:not(.collapsed) {
    background: var(--primary-color) !important;
    color: white !important;
    box-shadow: none;
}

.accordion-body {
    padding: 1.5rem;
    background: white;
}

.wiki-section {
    animation: fadeInUp 0.6s ease-out;
}

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

/* ADDED: Next Steps Cards */
.card.border-primary,
.card.border-info,
.card.border-success,
.card.border-warning {
    transition: var(--transition);
    background: white;
}

.card.border-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card.border-info:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card.border-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card.border-warning:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ADDED: Collapse transition enhancement */
.collapse {
    transition: height 0.35s ease;
}

/* ADDED: Installation submenu specific styling */
#installationSubmenu .list-group {
    background: white;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

#installationSubmenu .list-group-item:first-child {
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

#installationSubmenu .list-group-item:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

@media (max-width: 991.98px) {
    .wiki-sidebar {
        position: static !important;
        margin-bottom: 2rem;
        top: auto; /* Reset top positioning on mobile */
        max-height: none; /* Remove height restrictions on mobile */
        overflow-y: visible;
    }
    
    .wiki-content {
        padding-left: 0;
    }
    
    .wiki-section .card-body {
        padding: 1.5rem;
    }
    
    .wiki-section .card-header {
        padding: 1.25rem 1.5rem;
    }

    .wiki-section {
        /* Reset scroll margin on mobile since sidebar is not sticky */
        scroll-margin-top: calc(var(--navbar-height, 70px) + 2rem);
    }

    .wiki-section.subsection .card {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .wiki-container {
        margin-top: 1rem;
    }
    
    .wiki-header h1 {
        font-size: 1.75rem;
    }
    
    .wiki-section .card-body {
        padding: 1rem;
    }
    
    .wiki-section .card-header {
        padding: 1rem;
    }
    
    .wiki-section .card-header::after {
        left: 1rem;
        right: 1rem;
    }
    
    .wiki-section h5 {
        font-size: 1.125rem;
    }
    
    .checklist,
    .api-endpoint {
        padding: 1rem;
    }
    
    .wiki-section pre {
        padding: 1rem;
        font-size: 0.8rem;
    }

    .wiki-section {
        scroll-margin-top: calc(var(--navbar-height, 70px) + 1.5rem);
    }

    .breadcrumb {
        font-size: 0.8rem;
    }

    .wiki-sidebar .list-group-item.subsection {
        padding: 0.5rem 0.75rem 0.5rem 1.5rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    .wiki-sidebar .list-group-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .wiki-sidebar .list-group-item.subsection {
        padding: 0.5rem 0.75rem 0.5rem 1.25rem;
        font-size: 0.8rem;
    }
    
    .wiki-section .card-header i {
        font-size: 1.25rem;
    }
    
    .wiki-section h5::before {
        width: 3px;
        height: 0.875rem;
        top: 0.375rem;
    }

    .wiki-section {
        scroll-margin-top: calc(var(--navbar-height, 65px) + 1.5rem);
    }

    .toggle-icon {
        font-size: 0.7rem;
    }
}

@media print {
    .wiki-sidebar {
        display: none;
    }
    
    .wiki-content {
        padding-left: 0;
    }
    
    .wiki-section .card {
        box-shadow: none !important;
        border: 1px solid var(--border-color) !important;
        break-inside: avoid;
        background: white !important;
    }
    
    .wiki-section .card::before {
        display: none;
    }
    
    .wiki-section .card-header {
        background: white !important;
        color: var(--dark-color) !important;
    }
    
    .wiki-section .card-header::after {
        display: none;
    }
    
    .btn, .dropdown, .modal {
        display: none !important;
    }

    .breadcrumb {
        display: block;
    }

    .installation-section .collapse {
        display: block !important;
        height: auto !important;
    }
}

html {
    scroll-behavior: smooth;
}

.wiki-sidebar .list-group-item:focus,
.wiki-section h2:target {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ENHANCED: Better section targeting and highlighting */
.wiki-section:target {
    /* Additional highlighting when section is targeted via URL */
    animation: highlightSection 2s ease-out;
}

@keyframes highlightSection {
    0% {
        background: rgba(102, 126, 234, 0.1);
        border-radius: var(--border-radius);
    }
    100% {
        background: transparent;
    }
}

/* ADDED: Enhanced smooth scrolling for sidebar links */
.wiki-sidebar a[href^="#"] {
    scroll-behavior: smooth;
}

/* ADDED: Better visual feedback for active navigation */
.wiki-sidebar .list-group-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-dark);
    z-index: 1;
}

/* ADDED: Dynamic positioning adjustment class for JavaScript */
.wiki-sidebar-adjusted {
    top: var(--dynamic-navbar-height, calc(var(--navbar-height, 80px) + 2rem)) !important;
}

.wiki-section-adjusted {
    scroll-margin-top: var(--dynamic-scroll-margin, calc(var(--navbar-height, 80px) + 3rem)) !important;
}

/* ADDED: Enhanced animations for hierarchical sections */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wiki-section.subsection {
    animation: fadeInRight 0.4s ease-out;
}

/* ADDED: Hover effects for installation submenu toggle */
.installation-section .list-group-item[data-bs-toggle="collapse"]:hover .toggle-icon {
    transform: scale(1.1);
    color: var(--primary-color);
}

/* ADDED: Focus states for accessibility */
.wiki-sidebar .list-group-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    z-index: 1;
}

.breadcrumb-item a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}