/* =========================================================
   COURSE TOPIC PAGE - PREMIUM LEARNING UI
   Web + Mobile | Dark + Light | SEO/AdSense Friendly
========================================================= */

.page-with-navbar {
    background:
            radial-gradient(circle at top left, rgba(56,189,248,.12), transparent 30%),
            radial-gradient(circle at top right, rgba(14,165,233,.08), transparent 30%),
            var(--bg);
    min-height: 100vh;
}

body.light .page-with-navbar {
    background:
            radial-gradient(circle at top left, rgba(2,132,199,.10), transparent 32%),
            #f8fafc;
}

/* Reading Progress */
.progress-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 10000;
    background: transparent;
}

#readingProgressBar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #38bdf8, #0ea5e9);
}

/* Main Layout */
.container-fluid.section {
    max-width: 1540px;
    margin: 0 auto;
    padding: 28px 18px 60px !important;
}

.course-page-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 250px;
    gap: 24px;
    align-items: start;
}

/* Cards */
.card-glass,
.main-content-card,
.sidebar,
.toc-box,
.related-topics,
.popular-topics {
    background:
            radial-gradient(circle at top right, rgba(56,189,248,.10), transparent 38%),
            var(--card);
    border: 1px solid var(--navbar-border);
    border-radius: 28px;
    box-shadow: 0 18px 45px rgba(15,23,42,.12);
}

body.light .card-glass,
body.light .main-content-card,
body.light .sidebar,
body.light .toc-box,
body.light .related-topics,
body.light .popular-topics {
    background: #ffffff;
    border-color: rgba(2,132,199,.14);
    box-shadow: 0 14px 34px rgba(15,23,42,.08);
}

/* Left Sidebar */
.course-left-sidebar {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 110px;
    padding: 22px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
}

.sidebar h4 {
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 950;
    margin-bottom: 12px;
}

.topic-count span {
    display: inline-flex;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(56,189,248,.12);
    border: 1px solid rgba(56,189,248,.20);
    color: var(--primary);
    font-size: .78rem;
    font-weight: 900;
}

.custom-topic-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text) !important;
    background: rgba(255,255,255,.04);
    border: 1px solid transparent;
    font-size: .86rem;
    font-weight: 800;
    line-height: 1.35;
    transition: .22s ease;
}

body.light .topic-row {
    background: rgba(2,132,199,.05);
}

.topic-row:hover,
.topic-row.active {
    color: var(--primary) !important;
    border-color: rgba(56,189,248,.24);
    background: rgba(56,189,248,.10);
    transform: translateX(3px);
}

.topic-index {
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(56,189,248,.14);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 950;
}

/* Main Card */
.course-main-area {
    min-width: 0;
}

.main-content-card {
    padding: 30px;
    overflow: hidden;
}

/* Breadcrumb */
.breadcrumb-wrap {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .86rem;
    font-weight: 800;
}

.breadcrumb-wrap a {
    color: var(--primary) !important;
    text-decoration: none;
}

.breadcrumb-wrap span {
    color: var(--text);
    opacity: .72;
}

/* Search */
.input-group {
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15,23,42,.08);
}

.input-group .form-control {
    min-height: 54px;
    border: 1px solid var(--navbar-border);
    background: rgba(255,255,255,.96);
    color: #0f172a;
    font-size: .96rem;
    padding: 0 18px;
}

.input-group .btn {
    min-width: 110px;
    border-radius: 0;
    font-weight: 900;
}

/* Article Content */
.course-content {
    color: var(--text);
    font-size: 1.03rem;
    line-height: 1.9;
}

.course-content h1 {
    font-size: clamp(2.1rem, 5vw, 3.6rem);
    line-height: 1.08;
    font-weight: 950;
    letter-spacing: -.7px;
    margin: 18px 0 28px;
    color: var(--text);
}

.course-content h2 {
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    font-weight: 950;
    margin: 34px 0 14px;
    color: var(--text);
}

.course-content h3 {
    font-size: 1.35rem;
    font-weight: 950;
    margin: 28px 0 12px;
    color: var(--text);
}

.course-content p {
    margin-bottom: 18px;
    color: var(--text);
    opacity: .9;
}

.course-content strong {
    color: var(--text);
    font-weight: 950;
}

.course-content em {
    opacity: .9;
}

.course-content ul,
.course-content ol {
    padding-left: 24px;
    margin-bottom: 22px;
}

.course-content li {
    margin-bottom: 8px;
    line-height: 1.8;
    opacity: .92;
}

.course-content a {
    color: var(--primary) !important;
    font-weight: 850;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.course-content blockquote {
    margin: 28px 0;
    padding: 20px 22px;
    border-left: 5px solid var(--primary);
    border-radius: 18px;
    background: rgba(56,189,248,.08);
    color: var(--text);
}

.course-content table {
    width: 100%;
    margin: 24px 0;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--navbar-border);
}

.course-content th,
.course-content td {
    padding: 14px;
    border-bottom: 1px solid var(--navbar-border);
    color: var(--text);
}

.course-content th {
    background: rgba(56,189,248,.12);
    font-weight: 950;
}

/* Code Blocks */
.course-content pre {
    position: relative;
    margin: 26px 0;
    padding: 22px;
    border-radius: 22px;
    background: #020617 !important;
    border: 1px solid rgba(125,211,252,.18);
    overflow-x: auto;
}

.course-content code {
    font-family: "JetBrains Mono", monospace;
    font-size: .92rem;
}

.code-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    border: 1px solid rgba(125,211,252,.25);
    background: rgba(15,23,42,.92);
    color: #e0f2fe;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: .72rem;
    font-weight: 900;
}

/* Navigation Buttons */
.navigation-box {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding-top: 24px;
    border-top: 1px solid var(--navbar-border);
}

.nav-btn {
    min-height: 44px;
    border-radius: 999px !important;
    padding: 10px 18px !important;
    font-weight: 900 !important;
}

/* Right TOC */
.course-right-toc {
    min-width: 0;
}

.toc-box {
    position: sticky;
    top: 110px;
    padding: 20px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
}

.toc-box h6 {
    color: var(--text);
    font-weight: 950;
}

.toc-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-links a {
    padding: 9px 11px;
    border-radius: 14px;
    color: var(--text) !important;
    opacity: .75;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.35;
}

.toc-links a:hover,
.toc-links a.active {
    color: var(--primary) !important;
    opacity: 1;
    background: rgba(56,189,248,.10);
}

/* Related / Popular */
.related-topics,
.popular-topics {
    padding: 26px;
}

.related-topics h3,
.popular-topics h3 {
    color: var(--text);
    font-weight: 950;
    margin-bottom: 16px;
}

.related-grid,
.popular-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.related-card,
.popular-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 15px;
    border-radius: 18px;
    color: var(--text) !important;
    text-decoration: none;
    background: rgba(56,189,248,.07);
    border: 1px solid rgba(56,189,248,.13);
    font-weight: 900;
    transition: .22s ease;
}

.related-card:hover,
.popular-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    color: var(--primary) !important;
}

.popular-card small {
    opacity: .65;
    font-size: .75rem;
}

/* Scroll Top */
#scrollTopBtn {
    position: fixed;
    right: 18px;
    bottom: 20px;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid rgba(56,189,248,.24);
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #06111f;
    font-weight: 950;
    z-index: 999;
    box-shadow: 0 14px 32px rgba(15,23,42,.18);
}

/* Tablet */
@media (max-width: 1200px) {
    .course-page-layout {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .course-right-toc {
        display: none;
    }
}

/* Mobile */
@media (max-width: 991px) {
    .container-fluid.section {
        padding: 14px 10px 38px !important;
    }

    .course-page-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .course-left-sidebar {
        display: none;
    }

    .main-content-card {
        padding: 22px 16px;
        border-radius: 24px;
    }

    .course-content {
        font-size: .96rem;
        line-height: 1.75;
    }

    .course-content h1 {
        font-size: 2.15rem;
        margin-top: 14px;
    }

    .course-content h2 {
        font-size: 1.55rem;
    }

    .course-content h3 {
        font-size: 1.2rem;
    }

    .related-grid,
    .popular-grid {
        grid-template-columns: 1fr;
    }

    .navigation-box {
        flex-direction: column;
    }

    .nav-btn {
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 576px) {
    .container-fluid.section {
        padding: 10px 8px 32px !important;
    }

    .main-content-card {
        padding: 18px 14px;
        border-radius: 22px;
    }

    .breadcrumb-wrap {
        font-size: .74rem;
    }

    .input-group {
        flex-direction: column;
        border-radius: 18px;
    }

    .input-group .form-control,
    .input-group .btn {
        width: 100%;
        min-height: 48px;
        border-radius: 14px !important;
    }

    .course-content {
        font-size: .92rem;
    }

    .course-content h1 {
        font-size: 1.85rem;
    }

    .course-content h2 {
        font-size: 1.38rem;
    }

    .course-content pre {
        padding: 18px 14px;
        border-radius: 18px;
    }

    .related-topics,
    .popular-topics {
        padding: 18px 14px;
        border-radius: 22px;
    }
}