/* Greens Knowledge Base Portal */

:root {
    --sidebar-width: 280px;
    --header-height: 56px;
    --green-primary: #1a6b3c;
    --green-dark: #134d2b;
    --green-light: #e8f5ee;
    --green-accent: #2d9254;
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #888;
    --border-color: #e2e8f0;
    --bg-sidebar: #f8faf9;
    --bg-main: #ffffff;
    --bg-hover: #f0f7f3;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-main);
    line-height: 1.55;
    font-size: 14.5px;
}

/* ── Header ── */
.portal-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--green-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.portal-header .logo {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.portal-header .logo span {
    font-weight: 400;
    opacity: .85;
    margin-left: 8px;
}

/* Header search */
.header-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px;
    padding: 0 8px;
    transition: all .2s;
    max-width: 320px;
    width: 100%;
    margin-left: 24px;
}

.header-search:focus-within {
    background: rgba(255,255,255,.25);
    border-color: rgba(255,255,255,.5);
}

.header-search input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: .875rem;
    padding: 6px 4px;
    width: 100%;
}

.header-search input::placeholder {
    color: rgba(255,255,255,.6);
}

.header-search button {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-search button:hover {
    color: #fff;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 12px 0;
    z-index: 50;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.nav-section-title {
    padding: 8px 20px 4px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-top: 8px;
}

.nav-section-title:first-child { margin-top: 0; }

.nav-item {
    display: block;
    padding: 8px 36px 8px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.4;
    border-left: 4px solid transparent;
    transition: background .12s, color .12s;
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--green-light);
    color: var(--green-primary);
    border-left-color: var(--green-primary);
    font-weight: 700;
}

.nav-item.active:hover {
    background: var(--green-light);
    color: var(--green-primary);
}

/* Folder rows: stronger weight so they read as section headers */
.nav-parent > .nav-item { font-weight: 600; color: var(--text-primary); }
.nav-parent > .nav-item.active { color: var(--green-primary); font-weight: 700; }

/* When a section contains the active article, hint at it on the parent row */
.nav-parent-group:not(.collapsed) > .nav-item:not(.active) { color: var(--green-primary); }

/* Nested levels — indent only, no font shrink */
.nav-item[data-depth="1"] { padding-left: 32px; }
.nav-item[data-depth="2"] { padding-left: 48px; }
.nav-item[data-depth="3"] { padding-left: 64px; }
.nav-item[data-depth="4"] { padding-left: 80px; }

/* Right-side toggle chevron — pointing down when expanded, right when collapsed */
.nav-parent .toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);  /* expanded → chevron points DOWN */
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform .2s;
    user-select: none;
    border-radius: 3px;
}

.nav-parent .toggle:hover { background: rgba(0,0,0,.08); color: var(--text-primary); }
.nav-item.active.nav-parent .toggle { color: var(--green-primary); }
.nav-item.active.nav-parent .toggle:hover { background: rgba(26,107,60,.12); color: var(--green-dark); }

/* Collapsed → no rotation; chevron base glyph points RIGHT naturally */
.nav-parent-group.collapsed > .nav-item .toggle { transform: translateY(-50%) rotate(0); }
.nav-parent-group.collapsed > .nav-children { display: none; }

/* Sidebar utility links (bottom of nav) */
.sidebar-footer {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.nav-utility {
    display: block;
    padding: 8px 36px 8px 20px;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: background .12s, color .12s;
}

.nav-utility:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-utility.active {
    background: var(--green-light);
    color: var(--green-primary);
    border-left-color: var(--green-primary);
    font-weight: 700;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height) - 40px);
    padding: 32px 48px 40px;
    max-width: 900px;
}

/* ── Breadcrumbs ── */
.breadcrumbs {
    font-size: .85rem;
    margin-bottom: 20px;
    color: var(--text-muted);
    padding: 8px 14px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.breadcrumbs a {
    color: var(--green-accent);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .sep {
    margin: 0 6px;
    color: #ccc;
}

.breadcrumbs .current {
    color: var(--text-secondary);
}

/* ── Article content styling ── */
.article-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.article-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.article-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 6px;
}

.article-meta {
    font-size: .8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-id {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: .7rem;
    color: #aaa;
    background: #f5f5f5;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: .02em;
}

/* Print button */
.print-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: .78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.print-btn:hover {
    color: var(--text-primary);
    border-color: #bbb;
    background: #fafafa;
}

.article-body h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 28px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green-light);
}

.article-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 22px 0 8px;
}

.article-body h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 18px 0 6px;
}

.article-body p {
    margin: 0 0 14px;
    color: var(--text-primary);
}

.article-body ul, .article-body ol {
    margin: 0 0 14px;
    padding-left: 24px;
}

.article-body li {
    margin-bottom: 4px;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: .9rem;
}

.article-body thead th {
    background: var(--green-light);
    color: var(--green-dark);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

.article-body td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
}

.article-body tbody tr:nth-child(even) { background: #fafbfc; }

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.article-body a {
    color: var(--green-accent);
    text-decoration: none;
}

.article-body a:hover {
    text-decoration: underline;
}

.article-body mark {
    background: #fff3cd;
    padding: 1px 4px;
    border-radius: 3px;
}

.article-body strong {
    font-weight: 600;
}

/* ── Welcome / landing state ── */
.welcome {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.welcome h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome p {
    font-size: 1rem;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Sitemap (home page) ── */
.sitemap-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sitemap-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.sitemap-header p {
    color: var(--text-secondary);
    font-size: .95rem;
}

.sitemap-section {
    margin-bottom: 28px;
}

.sitemap-section > h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green-light);
}

.sitemap-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.sitemap-list .sitemap-list {
    padding-left: 20px;
    margin-top: 4px;
    border-left: 1px solid var(--border-color);
    margin-left: 6px;
}

.sitemap-list li {
    margin: 4px 0;
    line-height: 1.5;
}

.sitemap-list a {
    text-decoration: none;
    color: var(--green-accent);
    padding: 1px 4px;
    border-radius: 3px;
}

.sitemap-list a:hover {
    background: var(--green-light);
    color: var(--green-dark);
}

.sitemap-folder > a {
    color: var(--text-primary);
    font-weight: 600;
}

.sitemap-folder > a::before {
    content: "▸ ";
    color: var(--text-muted);
    font-size: .85em;
}

.sitemap-empty {
    color: var(--text-muted);
    padding: 40px 0;
    text-align: center;
}

/* ── Search results ── */
.search-results h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.search-count {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.search-result {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    text-decoration: none;
    transition: all .15s;
}

.search-result:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
}

.search-result-title {
    font-weight: 600;
    color: var(--green-primary);
    font-size: .95rem;
    margin-bottom: 4px;
}

.search-result-snippet {
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.search-result-snippet mark {
    background: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-meta {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Prev / Next nav ── */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
}

.article-nav a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all .15s;
    max-width: 45%;
}

.article-nav a:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
}

.article-nav .label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 1px;
}

.article-nav .title {
    font-size: .8rem;
    font-weight: 600;
    color: var(--green-primary);
    line-height: 1.3;
}

.article-nav .nav-next {
    text-align: right;
    margin-left: auto;
}

/* ── Child TOC (folder section listing) ── */
.child-toc {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.child-toc li {
    padding: 0;
    margin: 0;
}

.child-toc li a {
    display: block;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all .15s;
}

.child-toc li a:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
    color: var(--green-primary);
}

/* ── Footer ── */
.portal-footer {
    margin-left: var(--sidebar-width);
    padding: 16px 48px;
    font-size: .75rem;
    color: #aaa;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* ── Print styles ── */
@media print {
    .portal-header,
    .sidebar,
    .portal-footer,
    .article-nav,
    .breadcrumbs,
    .print-btn,
    .header-search {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 20px !important;
        max-width: 100% !important;
    }

    .article-header {
        border-bottom: 2px solid #333;
    }

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

    .article-body img {
        box-shadow: none;
        max-width: 80%;
    }

    .article-body a {
        color: #333;
    }

    .article-body a::after {
        content: " (" attr(href) ")";
        font-size: .75em;
        color: #666;
    }

    .article-body a[href^="#"]::after,
    .article-body a[href^="kb://"]::after {
        content: none;
    }

    .print-footer {
        display: flex !important;
        justify-content: space-between;
        margin-top: 40px;
        padding-top: 10px;
        border-top: 1px solid #ccc;
        font-size: 8pt;
        color: #999;
    }

    body {
        font-size: 11pt;
        line-height: 1.5;
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content {
        margin-left: 0;
        padding: 24px 16px 40px;
    }
    .portal-footer {
        margin-left: 0;
    }
    .header-search {
        max-width: 200px;
    }
}
