/* Reader experience styles (Bootstrap-based). Admin uses MudBlazor. */

:root {
    --docs-sidebar-width: 280px;
    --docs-toc-width: 240px;
    --docs-accent: #1d4ed8;
}

/* ---- Top bar ---- */
.docs-topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.6rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.docs-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #0f172a;
    text-decoration: none;
    white-space: nowrap;
}

.docs-search {
    flex: 1;
    max-width: 520px;
}

.docs-search input {
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.docs-topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.docs-topbar-link {
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
}

.docs-topbar-link:hover {
    color: var(--docs-accent);
}

.docs-logout-form {
    display: inline;
}

.docs-link-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

/* ---- Shell ---- */
.docs-shell {
    display: grid;
    grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.docs-sidebar {
    position: sticky;
    top: 4rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}

.docs-sidebar-empty {
    color: #94a3b8;
    font-size: 0.85rem;
}

.area-block {
    margin-bottom: 1rem;
}

.area-block .area-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #0f172a;
    text-decoration: none;
    margin: 0.75rem 0 0.25rem;
}

.docs-sidebar a:not(.area-title) {
    display: block;
    padding: 0.25rem 0.6rem;
    border-radius: 0.3rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.88rem;
}

.docs-sidebar a:not(.area-title):hover {
    background: #f1f5f9;
}

.docs-sidebar a.active {
    background: #e0ecff;
    color: var(--docs-accent);
    font-weight: 600;
}

.docs-main {
    min-width: 0;
}

/* ---- Article (content + TOC) ---- */
.docs-article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--docs-toc-width);
    gap: 2.5rem;
    align-items: start;
}

.docs-content {
    min-width: 0;
    max-width: 820px;
    line-height: 1.65;
    color: #1f2937;
}

.docs-content h1,
.docs-article > article > h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.docs-content h2 {
    font-size: 1.45rem;
    margin-top: 2rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #eef2f7;
}

.docs-content h3 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
}

.docs-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

.docs-content pre {
    background: #f6f8fa;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.docs-content :not(pre) > code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.docs-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.docs-content table th,
.docs-content table td {
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.75rem;
}

.docs-content blockquote {
    border-left: 4px solid #cbd5e1;
    margin: 1rem 0;
    padding: 0.25rem 1rem;
    color: #475569;
}

.docs-meta {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
}

/* Admin-only "Edit" shortcut shown on reader pages (top-right of the title). */
.docs-edit-btn {
    float: right;
    margin: 0.2rem 0 0.5rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    color: var(--docs-accent);
    background: #fff;
    border: 1px solid var(--docs-accent);
    border-radius: 0.375rem;
    padding: 0.35rem 0.7rem;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.docs-edit-btn:hover {
    background: var(--docs-accent);
    color: #fff;
}

/* ---- TOC ---- */
.docs-toc {
    position: sticky;
    top: 4rem;
    font-size: 0.85rem;
}

.docs-toc .toc-title {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
}

.docs-toc a {
    display: block;
    padding: 0.15rem 0;
    color: #64748b;
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 0.6rem;
}

.docs-toc a.toc-h3 {
    padding-left: 1.5rem;
    font-size: 0.8rem;
}

.docs-toc a:hover,
.docs-toc a.active {
    color: var(--docs-accent);
    border-left-color: var(--docs-accent);
}

/* ---- Breadcrumbs ---- */
.docs-breadcrumbs {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.docs-breadcrumbs a {
    color: #64748b;
    text-decoration: none;
}

.docs-breadcrumbs a:hover {
    color: var(--docs-accent);
}

.docs-breadcrumbs .sep {
    margin: 0 0.4rem;
}

/* ---- Area cards (home) ---- */
.area-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.area-card {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.area-card:hover {
    border-color: var(--docs-accent);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.08);
}

.area-card h3 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
}

.area-card p {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0 0 0.6rem;
}

.area-card-count {
    font-size: 0.78rem;
    color: #94a3b8;
}

.section-list {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.section-list li {
    border-bottom: 1px solid #eef2f7;
}

.section-list a {
    display: block;
    padding: 0.6rem 0;
    color: var(--docs-accent);
    text-decoration: none;
}

/* ---- Search ---- */
.docs-search-input {
    width: 100%;
    max-width: 520px;
    padding: 0.5rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.95rem;
}

.search-results {
    list-style: none;
    padding: 0;
}

.search-results li {
    padding: 1rem 0;
    border-bottom: 1px solid #eef2f7;
}

.search-result-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--docs-accent);
    text-decoration: none;
}

.search-result-area {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 0.15rem 0;
}

.search-result-snippet {
    color: #475569;
    font-size: 0.9rem;
}

.search-result-snippet mark {
    background: #fef08a;
    padding: 0 0.1rem;
}

/* ---- Feedback widget ---- */
.docs-feedback {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eef2f7;
}

.docs-feedback button {
    margin-right: 0.5rem;
}

/* ---- Mobile navigation (hamburger + off-canvas sidebar) ---- */
.nav-toggle {
    display: none; /* shown on small screens via the media query below */
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 9px 8px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: #334155;
    border-radius: 2px;
}

.nav-backdrop {
    display: none;
}

/* Admin SectionEditor: editor + live-preview split. */
.editor-split {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ---- Responsive ---- */
/* Laptops: drop the on-page TOC so the article gets the full width. */
@media (max-width: 1200px) {
    .docs-article {
        grid-template-columns: 1fr;
    }

    .docs-toc {
        display: none;
    }
}

/* Tablets & phones: off-canvas sidebar, single-column content. */
@media (max-width: 992px) {
    .docs-shell {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 0;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 300px);
        max-height: 100vh;
        margin: 0;
        padding: 1rem 1rem 2rem;
        background: #fff;
        box-shadow: 2px 0 18px rgba(15, 23, 42, 0.18);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1100;
    }

    body.nav-open .docs-sidebar {
        transform: translateX(0);
    }

    body.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1050;
    }

    body.nav-open {
        overflow: hidden; /* lock background scroll while the drawer is open */
    }

    .docs-topbar {
        gap: 0.75rem;
        padding: 0.55rem 0.9rem;
    }

    .docs-content h1,
    .docs-article > article > h1 {
        font-size: 1.6rem;
    }

    /* Wide tables (e.g. settings grids) scroll instead of breaking the layout. */
    .docs-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Comfortable touch targets in the nav drawer. */
    .docs-sidebar a:not(.area-title) {
        padding: 0.5rem 0.6rem;
    }

    /* Stack the editor + preview panes. */
    .editor-split {
        grid-template-columns: 1fr;
    }

    /* Let MudBlazor toolbars (admin app bar, editor actions) scroll if cramped. */
    .mud-toolbar {
        overflow-x: auto;
    }

    .admin-title {
        display: none;
    }
}

/* Small phones: reclaim top-bar space. */
@media (max-width: 576px) {
    .docs-brand-text {
        display: none; /* keep the 📘 icon as the home link */
    }

    .docs-hide-sm {
        display: none; /* hide the username link; Log out stays */
    }
}

/* ---- Admin media library grid ---- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Version diff view ---- */
.diff-view {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-view .diff-ins { background: #e6ffed; color: #22863a; display: block; }
.diff-view .diff-del { background: #ffeef0; color: #b31d28; display: block; }
.diff-view .diff-mod { background: #fff5b1; display: block; }
.diff-view .diff-eq { color: #57606a; display: block; }
