/*
 * Documentation theme for Barcode Producer Help
 *
 * Uses Web Awesome components and design tokens.
 * Separate from main site theme (theme-bcp.css).
 */

/* ==========================================================================
   Layout: wa-page configuration
   ========================================================================== */

@layer wa-theme-overrides {
    wa-page {
        --menu-width: 280px;
        --aside-width: 220px;
    }

    /* Critical: Reset widths on mobile */
    wa-page[view='mobile'] {
        --menu-width: auto;
        --aside-width: auto;
    }
}

/* ==========================================================================
   Header
   ========================================================================== */

.docs-header {
    padding: var(--wa-space-s) var(--wa-space-l);
    border-bottom: 1px solid var(--wa-color-surface-border);
    background: var(--wa-color-surface-default);
}

.docs-logo {
    display: inline-flex;
    align-items: center;
    gap: var(--wa-space-xs);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--wa-color-text-normal);
    text-decoration: none;
}

.docs-logo:hover {
    color: var(--wa-color-text-link);
}

.docs-search-container {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    max-width: 300px;
    margin-left: auto;
    margin-right: var(--wa-space-m);
}

.docs-search-input {
    width: 100%;
    cursor: pointer;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */

.docs-sidebar {
    background-color: var(--wa-color-surface-lowered);
    padding: var(--wa-space-m) 0;
}

.docs-sidebar-header {
    padding: var(--wa-space-m) var(--wa-space-l);
    border-bottom: 1px solid var(--wa-color-surface-border);
    margin-bottom: var(--wa-space-m);
}

.docs-search-mobile {
    padding: 0 var(--wa-space-m) var(--wa-space-m);
}

/* Navigation tree styling */
.docs-nav-tree {
    --indent-guide-width: 0;              /* No visible guides */
    --indent-size: var(--wa-space-l);     /* Indentation depth */
}

/* Move expand button to right side using flexbox */
.docs-nav-tree wa-tree-item::part(item) {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-height: 2rem;
    padding: var(--wa-space-3xs) var(--wa-space-s) var(--wa-space-3xs) var(--wa-space-l);
    border-radius: 0;
    cursor: pointer;
}

.docs-nav-tree wa-tree-item::part(expand-button) {
    order: 1;              /* Move to end */
    margin-left: auto;     /* Push to right edge */
    rotate: none;          /* Disable rotation - we use different icons for each state */
}

.docs-nav-tree wa-tree-item::part(label) {
    order: 0;              /* Keep label first */
    flex: 1;
    font-size: 0.875rem;
}

/* Navigation labels */
.docs-nav-label {
    display: inline-flex;
    align-items: center;
    gap: var(--wa-space-xs);
}

/* Section labels (items with children) */
.docs-nav-section {
    font-weight: 500;
}

/* Hover state on tree items */
.docs-nav-tree wa-tree-item::part(item):hover {
    background: var(--wa-color-surface-lowered);
}

/* Active/selected state - right edge indicator bar */
.docs-nav-tree wa-tree-item[selected]::part(item) {
    background: var(--wa-color-brand-fill-quiet);
    border-right: 3px solid var(--wa-color-brand-border-normal);
}

.docs-nav-tree wa-tree-item[selected] > .docs-nav-label {
    color: var(--wa-color-text-link);
    font-weight: 500;
}

/* Section headers (static labels between trees) */
.docs-nav-section-header {
    display: block;
    padding: var(--wa-space-s) var(--wa-space-s) var(--wa-space-3xs) var(--wa-space-l);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--wa-color-text-quiet);
}

/* Tags in navigation */
.docs-nav-tree wa-tag {
    margin-left: var(--wa-space-xs);
    font-size: 0.6rem;
}

/* Navigation icons */
.docs-nav-label wa-icon {
    font-size: 0.875rem;
    color: var(--wa-color-text-quiet);
    flex-shrink: 0;
}

.docs-nav-tree wa-tree-item[selected] > .docs-nav-label wa-icon {
    color: var(--wa-color-text-link);
}

/* Navigation footer (wa-page navigation-footer slot) */
.docs-nav-footer {
    width: 100%;
    border-block-start: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}

.docs-nav-footer-link {
    display: inline-flex;
    align-items: center;
    gap: var(--wa-space-xs);
    padding: var(--wa-space-2xs) 0;
    font-size: 0.8125rem;
    color: var(--wa-color-text-quiet);
    text-decoration: none;
}

.docs-nav-footer-link:hover {
    color: var(--wa-color-text-link);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.docs-main {
    padding: var(--wa-space-xl);
    max-width: 900px;
}

.docs-article-header {
    margin-bottom: var(--wa-space-xl);
}

.docs-article-header h1 {
    margin: 0 0 var(--wa-space-s) 0;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.docs-article-tags {
    display: flex;
    gap: var(--wa-space-xs);
}

/* Content rendered from markdown */
.docs-content {
    line-height: 1.7;
}

/* Headings */
.docs-content h2 {
    margin-top: var(--wa-space-2xl);
    margin-bottom: var(--wa-space-m);
    padding-bottom: var(--wa-space-s);
    border-bottom: 1px solid var(--wa-color-surface-border);
}

.docs-content h3 {
    margin-top: var(--wa-space-xl);
    margin-bottom: var(--wa-space-s);
}

.docs-content h4,
.docs-content h5,
.docs-content h6 {
    margin-top: var(--wa-space-l);
    margin-bottom: var(--wa-space-xs);
}

/* Permalink anchors */
.docs-content .headerlink {
    opacity: 0;
    margin-left: var(--wa-space-xs);
    color: var(--wa-color-text-quiet);
    text-decoration: none;
    font-weight: 400;
    transition: opacity 0.2s;
}

.docs-content h2:hover .headerlink,
.docs-content h3:hover .headerlink,
.docs-content h4:hover .headerlink {
    opacity: 1;
}

.docs-content .headerlink:hover {
    color: var(--wa-color-text-link);
}

/* Paragraphs and lists */
.docs-content p {
    margin-bottom: var(--wa-space-m);
}

.docs-content ul,
.docs-content ol {
    margin-bottom: var(--wa-space-m);
    padding-left: var(--wa-space-xl);
}

.docs-content li {
    margin-bottom: var(--wa-space-xs);
}

/* Links */
.docs-content a {
    color: var(--wa-color-text-link);
}

.docs-content a:hover {
    text-decoration: underline;
}

/* Images */
.docs-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--wa-border-radius-m);
    margin: var(--wa-space-l) 0;
}

/* Code */
.docs-content code {
    font-family: var(--wa-font-mono);
    font-size: 0.875em;
    padding: 0.125em 0.25em;
    background: var(--wa-color-surface-lowered);
    border: 1px solid var(--wa-color-surface-border);
    border-radius: var(--wa-border-radius-s);
}

.docs-content pre {
    margin: var(--wa-space-l) 0;
    padding: var(--wa-space-m);
    background: var(--wa-color-surface-lowered);
    border: 1px solid var(--wa-color-surface-border);
    border-radius: var(--wa-border-radius-m);
    overflow-x: auto;
}

.docs-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Tables */
.docs-content table {
    width: 100%;
    margin: var(--wa-space-l) 0;
    border-collapse: collapse;
}

.docs-content th,
.docs-content td {
    padding: var(--wa-space-s) var(--wa-space-m);
    text-align: left;
    border-bottom: 1px solid var(--wa-color-surface-border);
}

.docs-content th {
    font-weight: 600;
    background: var(--wa-color-surface-lowered);
}

.docs-content tr:hover td {
    background: var(--wa-color-surface-lowered);
}

/* Blockquotes */
.docs-content blockquote {
    margin: var(--wa-space-l) 0;
    padding: var(--wa-space-m) var(--wa-space-l);
    border-left: 4px solid var(--wa-color-brand-border-normal);
    background: var(--wa-color-brand-fill-quiet);
    border-radius: 0 var(--wa-border-radius-m) var(--wa-border-radius-m) 0;
}

.docs-content blockquote p:last-child {
    margin-bottom: 0;
}

/* wa-callout (from admonitions) */
.docs-content wa-callout {
    margin: var(--wa-space-l) 0;
}

/* ==========================================================================
   Section Index (auto-list of children)
   ========================================================================== */

.docs-section-children {
    margin-top: var(--wa-space-2xl);
    padding-top: var(--wa-space-xl);
    border-top: 1px solid var(--wa-color-surface-border);
}

.docs-section-children h2 {
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.docs-children-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-children-list li {
    padding: var(--wa-space-s) 0;
    border-bottom: 1px solid var(--wa-color-surface-border);
    display: flex;
    align-items: center;
    gap: var(--wa-space-s);
}

.docs-children-list li:last-child {
    border-bottom: none;
}

.docs-children-list a {
    color: var(--wa-color-text-link);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--wa-space-xs);
}

.docs-children-list a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Table of Contents (Right Aside)
   ========================================================================== */

.docs-aside {
    padding: var(--wa-space-l);
}

.toc {
    position: sticky;
    top: var(--wa-space-l);
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wa-color-text-quiet);
    margin-bottom: var(--wa-space-s);
}

/* TOC generated by markdown extension */
.toc-nav .toc {
    /* Reset inner toc wrapper */
    position: static;
}

.toc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin: 0;
}

.toc-nav a {
    display: block;
    padding: var(--wa-space-2xs) 0;
    font-size: 0.8125rem;
    color: var(--wa-color-text-quiet);
    text-decoration: none;
    line-height: 1.4;
}

.toc-nav a:hover {
    color: var(--wa-color-text-link);
}

/* Nested TOC levels */
.toc-nav ul ul {
    padding-left: var(--wa-space-m);
}

/* ==========================================================================
   Search Dialog
   ========================================================================== */

.docs-search-dialog {
    --width: 600px;
}

.docs-search-dialog wa-input {
    margin-bottom: var(--wa-space-m);
}

.docs-search-results {
    max-height: 400px;
    overflow-y: auto;
}

.docs-search-hint {
    color: var(--wa-color-text-quiet);
    text-align: center;
    padding: var(--wa-space-xl);
}

.docs-search-result {
    padding: var(--wa-space-s) var(--wa-space-m);
    border-radius: var(--wa-border-radius-m);
    cursor: pointer;
}

.docs-search-result:hover {
    background: var(--wa-color-surface-lowered);
}

.docs-search-result-title {
    font-weight: 500;
    color: var(--wa-color-text-normal);
}

.docs-search-result-excerpt {
    font-size: 0.875rem;
    color: var(--wa-color-text-quiet);
    margin-top: var(--wa-space-2xs);
}

.docs-search-result mark {
    background: var(--wa-color-warning-fill-quiet);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .docs-main {
        padding: var(--wa-space-l);
    }

    .docs-article-header h1 {
        font-size: 2rem;
    }
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

.wa-dark .docs-content pre,
.wa-dark .docs-content code {
    background: var(--wa-color-neutral-90);
}
