/* ============================================================
   help-docs.css — Documentation page (Views/Help/Index.cshtml)
   ------------------------------------------------------------
   Responsive, theme-aware, glass-morphism (no gradients).
   Layout tiers:
     >= 1200px  sidebar | content | sticky TOC
     768-1199   sidebar | content
     < 768      sidebar is off-canvas drawer, content fills
   ============================================================ */

/* ---------- Tokens (local, theme-aware) ---------- */
.help-page-container {
    --help-sidebar-w: 280px;
    --help-toc-w: 240px;
    --help-topbar-h: 60px;
    --help-gap: clamp(0.75rem, 1.5vw, 1.5rem);
    --help-radius: 14px;
    --help-radius-sm: 10px;
    --help-card-bg: var(--bs-body-bg);
    --help-card-border: var(--bs-border-color);
    --help-subtle-bg: var(--bs-tertiary-bg);
    --help-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
    --help-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
    --help-ink: var(--bs-body-color);
    --help-ink-muted: var(--bs-secondary-color);
    --help-accent: var(--bs-primary);
    --help-accent-soft: color-mix(in srgb, var(--bs-primary) 10%, transparent);
    --help-accent-ring: color-mix(in srgb, var(--bs-primary) 35%, transparent);
}

[data-bs-theme="dark"] .help-page-container {
    --help-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --help-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ---------- Shell ---------- */
.help-page-container {
    display: grid;
    grid-template-columns: var(--help-sidebar-w) minmax(0, 1fr);
    min-height: calc(100vh - var(--help-topbar-h));
    background: var(--bs-body-bg);
    color: var(--help-ink);
    position: relative;
}

@media (min-width: 1200px) {
    .help-page-container { grid-template-columns: var(--help-sidebar-w) minmax(0, 1fr); }
}

/* ---------- Sidebar ----------
   Sticks to the viewport top once the site navbar scrolls away. */
.help-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    background: var(--help-subtle-bg);
    border-right: 1px solid var(--help-card-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 30;
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--help-card-border);
}

.sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: var(--help-accent);
}

.btn-close-sidebar {
    background: transparent;
    border: 0;
    padding: 0.25rem 0.5rem;
    color: var(--help-ink);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.btn-close-sidebar:hover { background: var(--bs-secondary-bg); }

.sidebar-search { padding: 0.75rem 1rem 0.5rem; }

.sidebar-search .search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.sidebar-search .search-input-wrapper i.mdi-magnify {
    position: absolute;
    left: 0.75rem;
    color: var(--help-ink-muted);
    pointer-events: none;
    font-size: 1.1rem;
}
.sidebar-search input.form-control {
    padding-left: 2.2rem;
    padding-right: 3rem;
    height: 38px;
    border-radius: var(--help-radius-sm);
    background: var(--bs-body-bg);
    border: 1px solid var(--help-card-border);
    font-size: 0.9rem;
}
.sidebar-search input.form-control:focus {
    border-color: var(--help-accent);
    box-shadow: 0 0 0 3px var(--help-accent-ring);
}
.search-shortcut {
    position: absolute;
    right: 0.5rem;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--bs-secondary-bg);
    color: var(--help-ink-muted);
    border-radius: 4px;
    border: 1px solid var(--help-card-border);
    font-family: inherit;
}

/* Scrollable nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0.5rem 1.25rem;
    scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 3px;
}

.nav-section { margin: 0.4rem 0 0.2rem; }

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    color: var(--help-ink-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    user-select: none;
    border-radius: var(--help-radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
}
.nav-section-title:hover { color: var(--help-ink); background: var(--bs-secondary-bg); }
.nav-section-title > i:first-child { font-size: 1rem; color: var(--help-accent); }
.nav-section-title > span { flex: 1; }
.nav-chevron {
    font-size: 1rem;
    transition: transform 0.2s ease;
}
.nav-section-title[aria-expanded="false"] .nav-chevron,
.nav-section-title.collapsed .nav-chevron { transform: rotate(-90deg); }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.52rem 0.8rem;
    margin: 2px 0.25rem;
    color: var(--help-ink);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--help-radius-sm);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    position: relative;
}
.sidebar-nav .nav-link i {
    font-size: 1rem;
    color: var(--help-ink-muted);
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-nav .nav-link:hover {
    background: var(--bs-secondary-bg);
    color: var(--help-ink);
}
.sidebar-nav .nav-link:hover i { color: var(--help-accent); }
.sidebar-nav .nav-link.active {
    background: var(--help-accent-soft);
    color: var(--help-accent);
}
.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.25rem;
    top: 25%;
    bottom: 25%;
    width: 3px;
    border-radius: 2px;
    background: var(--help-accent);
}
.sidebar-nav .nav-link.active i { color: var(--help-accent); }

/* ---------- Content area ---------- */
.help-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.mobile-header {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--help-card-border);
    background: var(--bs-body-bg);
    position: sticky;
    top: 0;
    z-index: 20;
}
.mobile-header .mobile-title {
    font-weight: 600;
    font-size: 1rem;
}

.content-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--help-gap);
    padding: 1rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--help-card-border);
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-container { flex: 1 1 320px; min-width: 0; }

.global-search {
    position: relative;
    display: flex;
    align-items: center;
}
.global-search > i.mdi-magnify {
    position: absolute;
    left: 0.9rem;
    color: var(--help-ink-muted);
    pointer-events: none;
    font-size: 1.25rem;
}
.global-search input.form-control {
    height: 44px;
    padding-left: 2.6rem;
    padding-right: 2.8rem;
    border-radius: var(--help-radius);
    background: var(--help-subtle-bg);
    border: 1px solid transparent;
    font-size: 0.95rem;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.global-search input.form-control:focus {
    background: var(--bs-body-bg);
    border-color: var(--help-accent);
    box-shadow: 0 0 0 3px var(--help-accent-ring);
}
.btn-clear {
    position: absolute;
    right: 0.4rem;
    background: transparent;
    border: 0;
    padding: 0.35rem 0.5rem;
    color: var(--help-ink-muted);
    border-radius: 8px;
}
.btn-clear:hover { background: var(--bs-secondary-bg); color: var(--help-ink); }

.header-actions { display: flex; align-items: center; gap: 1rem; }

.docs-progress-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    background: var(--help-subtle-bg);
    border-radius: var(--help-radius);
    border: 1px solid var(--help-card-border);
}
.progress-ring {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring-bg {
    fill: none;
    stroke: var(--bs-border-color);
    stroke-width: 3;
}
.progress-ring-fill {
    fill: none;
    stroke: var(--help-accent);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-ring .progress-text {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--help-ink);
}
.progress-label {
    font-size: 0.8rem;
    color: var(--help-ink-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* ---------- Search results panel ---------- */
.docs-search-results-container {
    margin: 1rem clamp(1rem, 3vw, 2rem);
    border: 1px solid var(--help-card-border);
    border-radius: var(--help-radius);
    background: var(--help-card-bg);
    box-shadow: var(--help-shadow);
    overflow: hidden;
}
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--help-subtle-bg);
    border-bottom: 1px solid var(--help-card-border);
    font-size: 0.9rem;
    color: var(--help-ink-muted);
}
.search-results-header .btn-link {
    padding: 0.25rem 0.5rem;
    color: var(--help-ink-muted);
    text-decoration: none;
    border-radius: 6px;
}
.search-results-header .btn-link:hover { background: var(--bs-secondary-bg); color: var(--help-ink); }
.search-results-list { padding: 0.5rem; max-height: 480px; overflow-y: auto; }
.search-results-list .search-result-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--help-radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}
.search-results-list .search-result-item:hover,
.search-results-list .search-result-item.selected {
    background: var(--help-accent-soft);
}
.search-results-list mark {
    background: color-mix(in srgb, var(--bs-warning) 35%, transparent);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

/* ---------- Content grid (article + TOC) ---------- */
.content-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--help-gap);
    padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem);
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.help-toc {
    display: none; /* shown at >=1200px */
}

@media (min-width: 1200px) {
    .help-content { position: relative; }
    .content-body {
        grid-template-columns: minmax(0, 1fr) var(--help-toc-w);
    }
    .help-toc {
        display: block;
        order: 2;
        grid-column: 2;
        grid-row: 1;
    }
    .help-toc.is-empty { visibility: hidden; }
    .help-toc-inner {
        position: sticky;
        top: 96px; /* below the sticky content-header */
        padding: 1rem 0.5rem 1rem 1rem;
        border-left: 1px solid var(--help-card-border);
    }
    .help-toc-label {
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--help-ink-muted);
        font-weight: 700;
        margin-bottom: 0.5rem;
        padding-left: 0.5rem;
    }
    .help-toc-list {
        list-style: none;
        padding: 0;
        margin: 0;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }
    .help-toc-list li { margin: 0; }
    .help-toc-list a {
        display: block;
        padding: 0.35rem 0.6rem;
        font-size: 0.85rem;
        color: var(--help-ink-muted);
        text-decoration: none;
        border-left: 2px solid transparent;
        border-radius: 0 6px 6px 0;
        line-height: 1.35;
        transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    }
    .help-toc-list a:hover { color: var(--help-ink); background: var(--bs-secondary-bg); }
    .help-toc-list a.active {
        color: var(--help-accent);
        border-left-color: var(--help-accent);
        font-weight: 600;
    }
}

/* ---------- Sections ---------- */
.doc-section {
    display: none;
    animation: helpDocFadeIn 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
    grid-column: 1;
}
.doc-section.active { display: block; }
@keyframes helpDocFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    padding: 1.5rem 1.75rem;
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: var(--help-radius);
    box-shadow: var(--help-shadow);
    margin-bottom: var(--help-gap);
    position: relative;
    overflow: hidden;
}
.section-header::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--help-accent);
    opacity: 0.9;
}
.section-header h1 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.section-header h1 i {
    font-size: 1.5em;
    color: var(--help-accent);
    padding: 0.4rem;
    background: var(--help-accent-soft);
    border-radius: var(--help-radius-sm);
    line-height: 1;
}
.section-header .lead {
    font-size: 1rem;
    color: var(--help-ink-muted);
    margin: 0;
    max-width: 72ch;
    line-height: 1.5;
}
.section-header .btn-tour {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--help-accent);
    color: #fff;
    border: 0;
    padding: 0.55rem 1rem;
    border-radius: var(--help-radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.section-header .btn-tour:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--help-accent-ring);
}

/* Subsection headings inside a doc-section */
.doc-section h2 {
    font-size: clamp(1.125rem, 1.6vw, 1.4rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 2rem 0 1rem;
    padding: 0 0 0.4rem;
    border-bottom: 1px solid var(--help-card-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.doc-section h2 i { color: var(--help-accent); }
.doc-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
}
.doc-section h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1rem 0 0.35rem;
}
.doc-section p {
    line-height: 1.6;
    color: var(--help-ink);
    margin: 0 0 0.75rem;
}
.doc-section ul, .doc-section ol {
    line-height: 1.6;
    padding-left: 1.25rem;
    margin: 0 0 1rem;
}
.doc-section li { margin-bottom: 0.35rem; }
.doc-section code {
    background: var(--help-subtle-bg);
    border: 1px solid var(--help-card-border);
    padding: 0.1em 0.4em;
    border-radius: 5px;
    font-size: 0.85em;
}
.doc-section pre {
    background: var(--help-subtle-bg);
    border: 1px solid var(--help-card-border);
    border-radius: var(--help-radius-sm);
    padding: 0.85rem 1rem;
    overflow-x: auto;
    margin: 0 0 1rem;
}
.doc-section pre code { background: transparent; border: 0; padding: 0; }
.doc-section a { color: var(--help-accent); text-decoration: none; }
.doc-section a:hover { text-decoration: underline; }

/* Card-like containers seen across sections */
.feature-cards,
.feature-box,
.quick-links-section,
.method-card,
.command-list,
.template-grid,
.action-list,
.step-list {
    margin: 1rem 0;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--help-gap);
}
.feature-card,
.action-item,
.method-card,
.component-item,
.template-item,
.command-item,
.step-content,
.quick-links-section {
    display: flex;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: var(--help-radius);
    box-shadow: var(--help-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.feature-card[data-navigate],
.feature-card.is-clickable { cursor: pointer; }
.feature-card[data-navigate]:hover,
.feature-card:hover,
.action-item:hover,
.method-card:hover,
.component-item:hover,
.template-item:hover,
.command-item:hover {
    transform: translateY(-2px);
    border-color: var(--help-accent-ring);
    box-shadow: var(--help-shadow-lg);
}
.feature-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--help-radius-sm);
    font-size: 1.4rem;
}
.feature-icon i { font-size: 1.4rem; }
.feature-content { min-width: 0; }
.feature-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}
.feature-content p {
    margin: 0;
    color: var(--help-ink-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

/* Quick links: slightly larger, full-width */
.quick-links-section {
    display: block;
    padding: 1.25rem 1.5rem;
}
.quick-links-section h2 {
    margin-top: 0;
    border-bottom: 0;
    padding-bottom: 0;
}

/* Alert-ish callouts */
.doc-section .alert {
    border-radius: var(--help-radius-sm);
    border-width: 1px;
    border-style: solid;
    padding: 0.75rem 1rem;
}

/* ---------- Search modal (Ctrl+K) ---------- */
#searchModal .modal-dialog { max-width: 640px; margin-top: min(10vh, 100px); }
#searchModal .modal-content {
    border-radius: var(--help-radius);
    border: 1px solid var(--help-card-border);
    box-shadow: var(--help-shadow-lg);
    overflow: hidden;
    backdrop-filter: blur(12px);
    background: var(--help-card-bg);
}
#searchModal .modal-header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    align-items: center;
}
.search-modal-input {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}
.search-modal-input i.mdi-magnify {
    position: absolute;
    left: 0.85rem;
    color: var(--help-ink-muted);
    font-size: 1.25rem;
    pointer-events: none;
}
.search-modal-input input.form-control {
    height: 46px;
    padding-left: 2.6rem;
    border: 0;
    background: transparent;
    font-size: 1rem;
    box-shadow: none !important;
}
.search-modal-input input.form-control:focus { outline: none; }
#searchModal .modal-body { padding: 0.5rem 0.75rem 1rem; max-height: 60vh; overflow-y: auto; }
#searchModal .modal-body .search-results-list { padding: 0; }
.search-hints { padding: 1rem; color: var(--help-ink-muted); }
.search-hints p {
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.hint-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.hint-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    background: var(--help-subtle-bg);
    border: 1px solid var(--help-card-border);
    color: var(--help-ink);
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.hint-tag:hover {
    background: var(--help-accent-soft);
    color: var(--help-accent);
    transform: translateY(-1px);
}

/* ---------- Tablet (<1200) ---------- */
@media (max-width: 1199.98px) {
    .help-page-container { --help-sidebar-w: 260px; }
}

/* ---------- Mobile (<768) ---------- */
@media (max-width: 991.98px) {
    .help-page-container { grid-template-columns: 1fr; }
    .help-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: min(320px, 85vw);
        transform: translateX(-100%);
        z-index: 1050;
        box-shadow: var(--help-shadow-lg);
    }
    .help-sidebar.show { transform: translateX(0); }
    body.help-sidebar-open { overflow: hidden; }
    body.help-sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1040;
        animation: helpDocFadeIn 0.2s ease;
    }
    .mobile-header { display: flex; }
    .content-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
        top: 0;
    }
    .header-actions { flex-wrap: wrap; gap: 0.5rem; }
    .docs-progress-indicator { padding: 0.35rem 0.6rem; }
    .progress-label { display: none; }
    .content-body { padding: 1rem; }
    .section-header { padding: 1.25rem; }
    .section-header h1 { font-size: 1.35rem; }
    .feature-cards { grid-template-columns: 1fr; gap: 0.75rem; }
    .feature-card,
    .action-item,
    .method-card,
    .component-item,
    .template-item,
    .command-item,
    .step-content {
        padding: 0.85rem;
    }
}

@media (max-width: 575.98px) {
    .content-header { flex-direction: column; align-items: stretch; }
    .header-actions { justify-content: flex-start; }
    .search-shortcut { display: none; }
    #searchModal .modal-dialog { margin: 0; max-width: 100%; height: 100vh; }
    #searchModal .modal-content { border-radius: 0; height: 100vh; }
    #searchModal .modal-body { max-height: calc(100vh - 72px); }
}

/* ---------- Print ---------- */
@media print {
    .help-sidebar,
    .mobile-header,
    .content-header,
    .help-toc,
    #searchModal { display: none !important; }
    .help-page-container { display: block; }
    .doc-section { display: block !important; break-inside: avoid; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .doc-section,
    .help-sidebar,
    .feature-card,
    .action-item,
    .method-card,
    .hint-tag,
    .progress-ring-fill {
        transition: none !important;
        animation: none !important;
    }
}
