/* Reset i układ główny */
* { box-sizing: border-box; }

html {
    scroll-behavior: smooth; /* Włącza natywną, płynną animację scrollowania dla całej strony */
}

/* Usunięcie przycisków/strzałek ze zwojów pasków przewijania */
*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

/* Właściwy wygląd paska */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: #121124;
}

*::-webkit-scrollbar-thumb {
  background: #4f46e5;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #6366f1;
}

/* Układ główny */
.docs-wrapper {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    min-height: calc(100vh - 60px);
    margin: 0;
    padding: 0;
    position: relative;
}

/* Sidebar - całkowicie unieruchomiony (FIXED + szerokość + zablokowany margin) */
/* Sidebar - lewa strona (sztywne ramy i własny scroll) */
.docs-sidebar {
    flex: 0 0 250px;
    width: 250px;
    padding: 15px 5px 5px 5px;
    border-right: 1px solid #30363d;
    background: #0d1117;
    user-select: none;
    
    position: fixed;
    top: 65px;
    left: 0;
    bottom: 0;
    max-height: calc(100vh - 150px); /* Blokuje wysokość dokładnie do wysokości ekranu pod headerem */
    overflow-y: auto;                /* Cały sidebar staje się przewijalny, jeśli zawartości jest za dużo */
    overflow-x: hidden;
    z-index: 10;
}

/* Content - margines, żeby treść nie nachodziła na fixed sidebar */
.docs-content {
    flex: 1;
    min-width: 250px;
    margin-left: 250px;
    padding: 40px;
    color: #c9d1d9;
}

/* Responsywność - dla telefonów/tabletów */
@media (max-width: 768px) {
    .docs-wrapper { flex-direction: column; }
    
    .docs-sidebar {
        flex: 0 0 auto;
        width: 100%;
        position: relative;
        top: 0;
        bottom: auto;
        max-height: none;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #30363d;
    }

    .docs-content {
        width: 100%;
        margin-left: 0;
        padding: 20px;
    }
}

/* Menu główne – tutaj zdejmujemy dodatkowe ograniczenia, bo scrolluje się teraz cały sidebar */
.docs-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Stylizacja paska przewijania dla sidebara */
.docs-sidebar::-webkit-scrollbar-button {
    display: none !important;
    height: 0 !important;
    width: 0 !important;
}

.docs-sidebar::-webkit-scrollbar {
    width: 4px !important;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: #121124 !important;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: #3d3c4b !important;
    border-radius: 4px !important;
}

.docs-sidebar::-webkit-scrollbar-thumb:hover {
    background: #6366f1 !important;
}

.docs-folder-header {
    cursor: pointer;
    padding: 8px;
    color: #c9d1d9;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.arrow {
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.3s ease;
}

/* Rozwinięcie folderu - obrót strzałki */
.expanded > .docs-folder-header .arrow { transform: rotate(90deg); }

/* Kontener dzieci - animacja wysokości obsługiwana przez JS */
.docs-children {
    display: block;
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition: height 0.35s ease-in-out, opacity 0.3s ease;
    margin-left: 15px;
    padding-left: 10px;
    border-left: 1px solid #30363d;
}

.expanded > .docs-children {
    opacity: 1;
    margin-top: 5px;
}

/* Pliki - obsługa długich nazw */
.docs-file-item a {
    display: block;
    padding: 6px 15px;
    color: #8b949e;
    text-decoration: none;
    font-size: 0.9em;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.docs-file-item a:hover { background: #1f242c; }
.docs-file-item a.active {
    background: #1f2937;
    color: #58a6ff;
    border-left: 2px solid #58a6ff;
}

.doc-nav-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #30363d;
    user-select: none;
}

.nav-card {
    background: #0d1117;
    border: 1px solid #30363d;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.nav-card:hover {
    border-color: #58a6ff;
    background: #161b22;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.nav-label {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.nav-path {
    font-size: 0.85rem;
    color: #58a6ff;
    font-family: monospace;
    opacity: 0.8;
}

.nav-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e6edf3;
    margin-top: 4px;
}

.nav-label i {
    font-size: 0.8em;
    margin-right: 8px; /* Odstęp dla lewej ikony */
}

.next .nav-label i {
    margin-right: 0;
    margin-left: 8px; /* Odstęp dla prawej ikony */
}

/* Upewnienie się, że etykieta "Next" jest po prawej stronie */
.nav-card.next {
    text-align: right;
    align-items: flex-end; /* Wyrównanie treści do prawej dla karty Next */
}

/* Stylizacja pustego miejsca (dla plików bez poprzednika/następnika) */
.nav-spacer {
    flex: 1;
}

/* Responsywność */
@media (max-width: 600px) {
    .doc-nav-wrapper { grid-template-columns: 1fr; }
}

/* 1. Ścieżka nawigacyjna (Breadcrumbs) */
.doc-breadcrumb {
    font-size: 0.85rem;
    color: #8b949e;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px; /* Odstęp między elementami */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Ikona strzałki */
.doc-breadcrumb i {
    font-size: 0.7rem;
    margin: 0 8px; /* Zwiększony margines, żeby strzałka nie "dotykała" folderów */
    color: #444;   /* Lekko przyciemniony kolor strzałki */
}

/* Ostatni element (nazwa pliku w ścieżce) */
.doc-breadcrumb strong {
    color: #58a6ff;
    font-weight: 500;
}

/* 2. Główny tytuł (Nazwa pliku) */
.doc-title {
    font-size: 2.2rem;
    color: #e6edf3;
    margin-top: 0;
    margin-bottom: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.docs-toc {
    padding: 20px 24px 20px 12px; /* Zwiększamy prawy padding, żeby nie kleiło się do krawędzi ekranu */
    position: sticky;
    top: 80px;
    height: fit-content;
    width: 220px; /* Stała szerokość, żeby kontener trzymał stabilną pozycję */
    box-sizing: border-box;
}

.toc-header {
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 0.9em;
    color: #e6edf3;
}

#toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

/* Szara linia bazowa - teraz idealnie za tekstem */
#toc-list::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0px;
    width: 2px;
    background: #30363d;
    border-radius: 2px;
}

/* Płynnie przesuwający się niebieski wskaźnik (kreska) */
.toc-indicator {
    position: absolute;
    left: 0px;
    width: 2px;
    height: 20px; /* Wysokość aktywnego paska */
    background: #58a6ff;
    border-radius: 2px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); /* Płynna animacja ruchu */
    pointer-events: none;
    top: 0;
}

.toc-item {
    position: relative;
    padding-left: 12px; /* Odstęp tekstu od linii */
}

.toc-item a {
    text-decoration: none;
    color: #848d97;
    font-size: 0.85em;
    display: block;
    padding: 4px 0;
    transition: color 0.15s ease;
}

.toc-item a:hover {
    color: #c9d1d9;
}

.toc-item a.active {
    color: #58a6ff !important;
}

.toc-item.toc-h3 { 
    padding-left: 20px; 
}

[id] {
    scroll-margin-top: 80px; 
}







/* Styl pola wyszukiwania na górze sidebara */
.docs-search-container {
    padding: 0 5px 12px 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid #30363d;
}

.docs-search-wrapper {
    display: flex;
    align-items: center;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0 10px;
}

.docs-search-wrapper i {
    color: #8b949e;
    font-size: 0.85em;
    margin-right: 8px;
}

#docs-search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #e6edf3;
    padding: 7px 0;
    font-size: 0.85em;
    outline: none;
}

#docs-search-input::placeholder {
    color: #8b949e;
}

/* Styl wyskakującego okna (modalu) z Overextended */
.search-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
}

.search-modal-backdrop.active {
    display: flex;
}

.search-modal-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-modal-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #30363d;
    gap: 12px;
    color: #8b949e;
}

.search-modal-header input {
    background: transparent;
    border: none;
    color: #e6edf3;
    font-size: 1em;
    width: 100%;
    outline: none;
}

.search-esc {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75em;
    color: #8b949e;
    cursor: pointer;
}

.search-modal-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.search-placeholder {
    padding: 20px;
    text-align: center;
    color: #8b949e;
    font-size: 0.9em;
}

/* Styl pojedynczego elementu wyniku wyszukiwania w stylu Overextended */
.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background 0.15s ease;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Ścieżka dokumentacji na górze wyniku */
.search-result-path {
    font-size: 12px;
    color: #8b949e;
    font-family: inherit;
}

/* Podgląd zawartości sekcji (HTML) */
.search-result-content-preview {
    font-size: 13px;
    color: #c9d1d9;
    line-height: 1.5;
}

/* Dostosowanie elementów wewnątrz podglądu, żeby pasowały do okna wyszukiwania */
.search-result-content-preview h1,
.search-result-content-preview h2,
.search-result-content-preview h3 {
    font-size: 14px;
    margin: 4px 0;
    color: #ffffff;
}

.search-result-content-preview code,
.search-result-content-preview pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}