/* ==========================================================================
   Shared styles for all topic pages (OS, DBMS, DSA, OOPS, CN, Full Stack)
   Dark theme, consistent with CSS/index.css
   ========================================================================== */

:root {
    --bg: #000;
    --bg-panel: #0d0d0d;
    --bg-code: #111417;
    --border: #2a2a2a;
    --text: #f2f2f2;
    --text-dim: #a8a8a8;
    --accent: #4fd1c5;
    --accent-dim: #2c7a72;
    --warn: #e0b34d;
    --danger: #e05f5f;
    --basic: #4fd17e;
    --intermediate: #e0b34d;
    --advanced: #e05f5f;
}

/* === Topic header bar === */
.topic-header {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.topic-header .home-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: bold;
}

.topic-header .home-link .logo {
    height: 1.6rem;
}

.topic-header .topic-title-tag {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: bold;
}

.topic-header .topic-nav-links {
    display: flex;
    gap: 1.2rem;
    font-size: 0.95rem;
}

.topic-header .topic-nav-links a {
    color: var(--text-dim);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.topic-header .topic-nav-links a:hover,
.topic-header .topic-nav-links a.current {
    color: var(--accent);
    background: rgba(79, 209, 197, 0.08);
}

.topic-header .hamburger-icon {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.topic-header .hamburger-icon span {
    display: block;
    width: 22px;
    height: 3px;
    background: #fff;
    margin: 3px 0;
    border-radius: 3px;
}

/* === Shell layout: sidebar + main === */
.topic-shell {
    display: flex;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* === TOC Sidebar === */
.toc-sidebar {
    position: sticky;
    top: 60px;
    width: 290px;
    flex-shrink: 0;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 1.2rem 1rem 3rem 0.5rem;
    scrollbar-width: thin;
}

.toc-sidebar::-webkit-scrollbar {
    width: 6px;
}
.toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.toc-search {
    width: 100%;
    padding: 0.55rem 0.8rem;
    margin-bottom: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.toc-search:focus {
    outline: none;
    border-color: var(--accent);
}

.toc-nav {
    list-style: none;
}

.toc-nav .toc-h2 {
    margin-top: 0.9rem;
}

.toc-nav .toc-h2 > a {
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--text);
}

.toc-nav .toc-h3-list {
    list-style: none;
    margin-left: 0.9rem;
    border-left: 1px solid var(--border);
}

.toc-nav .toc-h3-list li a {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.toc-nav a {
    display: block;
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    line-height: 1.3;
}

.toc-nav a:hover {
    color: var(--accent);
    background: rgba(79, 209, 197, 0.06);
}

.toc-nav a.active {
    color: var(--accent);
    background: rgba(79, 209, 197, 0.12);
    border-left: 2px solid var(--accent);
}

.toc-nav li.hidden {
    display: none;
}

/* === Main content === */
.topic-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1rem 6rem 2rem;
    border-left: 1px solid var(--border);
    line-height: 1.7;
    font-size: 1rem;
}

.topic-main h1 {
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
}

.topic-intro {
    color: var(--text-dim);
    max-width: 860px;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.topic-main section {
    margin-top: 3rem;
    padding-top: 0.5rem;
    scroll-margin-top: 70px;
    max-width: 900px;
}

.topic-main h2 {
    font-size: 1.7rem;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    scroll-margin-top: 70px;
}

.topic-main h3 {
    font-size: 1.3rem;
    margin-top: 1.8rem;
    margin-bottom: 0.7rem;
    scroll-margin-top: 70px;
}

.topic-main h4 {
    font-size: 1.05rem;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.topic-main p {
    margin-bottom: 0.9rem;
    max-width: 900px;
}

.topic-main ul,
.topic-main ol {
    margin: 0 0 1rem 1.4rem;
}

.topic-main li {
    margin-bottom: 0.4rem;
}

.topic-main strong {
    color: #fff;
}

.topic-main code {
    background: var(--bg-code);
    border: 1px solid var(--border);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 0.88em;
    color: #9fe6dc;
}

/* === Difficulty badges === */
.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.badge-basic { background: rgba(79, 209, 126, 0.15); color: var(--basic); border: 1px solid var(--basic); }
.badge-intermediate { background: rgba(224, 179, 77, 0.15); color: var(--intermediate); border: 1px solid var(--intermediate); }
.badge-advanced { background: rgba(224, 95, 95, 0.15); color: var(--advanced); border: 1px solid var(--advanced); }

/* === Callout boxes === */
.callout {
    border-left: 4px solid var(--accent);
    background: var(--bg-panel);
    padding: 0.9rem 1.1rem;
    border-radius: 0 8px 8px 0;
    margin: 1.2rem 0;
    max-width: 860px;
}

.callout-title {
    font-weight: bold;
    margin-bottom: 0.3rem;
    display: block;
}

.callout-tip { border-color: var(--accent); }
.callout-tip .callout-title { color: var(--accent); }

.callout-pitfall { border-color: var(--danger); }
.callout-pitfall .callout-title { color: var(--danger); }

.callout-warning { border-color: var(--warn); }
.callout-warning .callout-title { color: var(--warn); }

/* === Code blocks === */
.code-block {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0 1.4rem;
    overflow: hidden;
    max-width: 900px;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: #171a1d;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-dim);
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.copy-btn.copied {
    color: var(--basic);
    border-color: var(--basic);
}

.code-block pre {
    margin: 0;
    padding: 1rem 1.2rem;
    overflow-x: auto;
}

.code-block code {
    background: none;
    border: none;
    padding: 0;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 0.87rem;
    line-height: 1.55;
    color: #d4d4d4;
    white-space: pre;
}

/* === Tables === */
.table-wrap {
    overflow-x: auto;
    margin: 1rem 0 1.4rem;
    max-width: 900px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.8rem;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: var(--bg-panel);
    color: var(--accent);
}

.data-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* === Interview Q&A collapsibles === */
.qa {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.7rem;
    background: var(--bg-panel);
    max-width: 900px;
    overflow: hidden;
}

.qa summary.qa-question {
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.qa summary.qa-question::-webkit-details-marker { display: none; }

.qa summary.qa-question::before {
    content: "▸";
    color: var(--accent);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.qa[open] summary.qa-question::before {
    transform: rotate(90deg);
}

.qa-answer {
    padding: 0 1rem 1rem 2.4rem;
    color: var(--text-dim);
}

.qa-answer p:last-child { margin-bottom: 0; }

/* === References list === */
.references-list li {
    margin-bottom: 0.5rem;
}

.references-list a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* === Back to top === */
.back-to-top {
    position: fixed;
    bottom: 1.6rem;
    right: 1.6rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 400;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.back-to-top.show { display: flex; }

/* === Mobile TOC toggle === */
.toc-toggle-btn {
    display: none;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

/* === Responsive === */
@media screen and (max-width: 900px) {
    .topic-shell {
        flex-direction: column;
    }

    .topic-header .topic-nav-links {
        display: none;
    }

    .topic-header .hamburger-icon {
        display: flex;
    }

    .toc-toggle-btn {
        display: inline-block;
        margin: 1rem 0 0 1rem;
    }

    .toc-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 82%;
        max-width: 320px;
        height: 100%;
        background: #050505;
        z-index: 900;
        padding: 4rem 1rem 2rem 1rem;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        border-right: 1px solid var(--border);
    }

    .toc-sidebar.open {
        transform: translateX(0);
    }

    .topic-main {
        border-left: none;
        padding: 0.5rem 1rem 6rem;
    }
}
