/* Core Page Settings */
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 900px; /* Keeps text from stretching too far */
    margin: 0 auto;
    padding: 2rem;
    background-color: #fdfdfd;
}

/* Site nav — small home link at the top of every non-home page */
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
}
.home-link,
.pdf-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.home-link:hover,
.pdf-link:hover {
    background: #fff8ec;
    border-color: #e08a19;
    color: #7a4b12;
    text-decoration: none;
}

/* ============================================================
   PRINT / PDF
   Hide navigation & search chrome so the exported PDF only
   contains the doc content + branded header.
   ============================================================ */
@media print {
    .site-nav,
    .smart-search-panel,
    .smart-search-results,
    #search,
    .search-hint {
        display: none !important;
    }
    body {
        max-width: none;
        padding: 0;
        background: #ffffff;
        color: #000000;
        font-size: 11pt;
    }
    a { color: #000000; text-decoration: none; }
    /* Avoid awkward page breaks in the middle of headings and images */
    h1, h2, h3, h4 { page-break-after: avoid; }
    img, table { page-break-inside: avoid; }
    /* Keep the orange doc header but flatten it for ink-friendly print */
    .doc-header {
        box-shadow: none;
        border-radius: 0;
        margin-bottom: 1rem;
    }
}

/* Orange doc header banner (Savance logo left, doc title right) */
.doc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #e08a19;
    color: #ffffff;
    padding: 1.25rem 2rem;
    border-radius: 6px;
    margin: 0 0 2rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.doc-header-logo {
    max-height: 60px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent;
}

.doc-header-title {
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 600;
    text-align: right;
    margin-left: 1rem;
}

/* Typography */
h1, h2, h3, h4 {
    color: #111;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

a {
    color: #0366d6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Image Formatting (Prevents giant screenshots and preserves aspect ratio,
   even when a raw <img> comes with inline width/height from Pandoc). */
img {
    max-width: 100% !important;
    height: auto !important;
    width: auto !important;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin: 1.5rem 0;
    border: 1px solid #eaeaea;
}

/* Markdown Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95em;
}

th, td {
    padding: 12px;
    border: 1px solid #ddd;
    text-align: left;
}

th {
    background-color: #f6f8fa;
    font-weight: bold;
}

/* Code Blocks */
code {
    background-color: #f6f8fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
    color: #e34c26;
}

/* Custom Navigation Tree Styles */
.docs-tree {
    list-style-type: none;
    padding-left: 20px;
}

.docs-tree li {
    margin-top: 10px;
}

/* ============================================================
   HOMEPAGE
   ============================================================ */

/* Give the homepage a bit more breathing room. */
body:has(.home-hero) {
    max-width: 1100px;
}

/* Hero banner */
.home-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: linear-gradient(135deg, #e08a19 0%, #c46b0a 100%);
    color: #ffffff;
    padding: 2.5rem 2rem;
    border-radius: 10px;
    margin: 0 0 2.5rem 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.home-hero-logo {
    max-height: 90px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent;
    flex-shrink: 0;
}

.home-hero-text h1 {
    color: #ffffff;
    margin: 0 0 0.3rem 0;
    font-size: 2rem;
    line-height: 1.2;
}

.home-hero-text p {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-size: 1rem;
}

/* Category tile grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.category-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    overflow: hidden;
}

.category-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.category-card > summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    color: #1f2937;
    list-style: none;
    user-select: none;
}

.category-card > summary::-webkit-details-marker { display: none; }
.category-card > summary::marker { content: ""; }

.category-card > summary::after {
    content: "▸";
    margin-left: auto;
    color: #9ca3af;
    transition: transform 0.15s ease;
    font-size: 0.9rem;
}

.category-card[open] > summary::after {
    transform: rotate(90deg);
}

.category-card .cat-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.category-card .cat-name {
    font-size: 1.05rem;
}

.category-card .cat-count {
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 500;
    background: #f3f4f6;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}

.category-body {
    padding: 0 1.25rem 1rem 1.25rem;
    border-top: 1px solid #f3f4f6;
}

/* Doc / sub-folder list inside a category */
.docs-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.docs-list li {
    margin: 0;
}

.docs-list li.folder > details > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.25rem;
    cursor: pointer;
    color: #374151;
    font-weight: 600;
    list-style: none;
}

.docs-list li.folder > details > summary::-webkit-details-marker { display: none; }
.docs-list li.folder > details > summary::marker { content: ""; }

.docs-list li.folder > details > summary::before {
    content: "▸";
    color: #9ca3af;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
    width: 0.75rem;
    display: inline-block;
}

.docs-list li.folder > details[open] > summary::before {
    transform: rotate(90deg);
}

.docs-list li.folder .folder-name::before {
    content: "📁 ";
    margin-right: 0.25rem;
}

.docs-list li.folder .folder-count {
    color: #9ca3af;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: auto;
}

.docs-list li.folder > details > .docs-list,
.docs-list li.folder > details > ul {
    padding-left: 1rem;
    border-left: 1px solid #f3f4f6;
    margin-left: 0.4rem;
}

.docs-list li.doc a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    color: #0366d6;
    text-decoration: none;
    border-radius: 4px;
}

.docs-list li.doc a:hover {
    background: #f6f8fa;
    text-decoration: none;
}

.docs-list li.doc a::before {
    content: "📄";
    font-size: 0.9rem;
    opacity: 0.8;
}

.docs-list li.doc .doc-title {
    flex: 1;
}

/* Doc-type badges */
.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.5;
    flex-shrink: 0;
}

.badge-kb      { background: #dbeafe; color: #1e40af; }
.badge-process { background: #dcfce7; color: #166534; }
.badge-core    { background: #ffedd5; color: #9a3412; }

/* Search bar polish */
#search {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fdfdfd;
    padding: 0.5rem 0;
}

.search-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0 0 1.5rem 0;
    padding: 0 0.25rem;
}
.search-hint code {
    background: #f3f4f6;
    color: #374151;
    font-size: 0.75rem;
    padding: 0.05rem 0.35rem;
}

/* Smart (semantic) search — compact single-row layout */
.smart-search-panel {
    margin: 0 0 1.5rem 0;
}
.smart-search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.smart-search-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}
.smart-search-go {
    padding: 0.55rem 1.15rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    background: #e08a19;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}
.smart-search-go:hover:not([disabled]) { background: #c46b0a; }
.smart-search-go[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Tiny status dot with hover tooltip (uses native title attr) */
.smart-search-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
    cursor: help;
    flex-shrink: 0;
}
.smart-search-dot-loading {
    background: #f59e0b;
    animation: smart-search-pulse 1.2s ease-in-out infinite;
}
.smart-search-dot-ready { background: #10b981; }
.smart-search-dot-error { background: #ef4444; }
@keyframes smart-search-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}

/* Results panel with a close button */
.smart-search-results {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fff8ec;
    border: 1px solid #f3d9a4;
    border-radius: 8px;
}
.smart-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}
.smart-search-header strong { color: #374151; }
.smart-search-close {
    background: transparent;
    border: 0;
    color: #6b7280;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.35rem;
    border-radius: 4px;
}
.smart-search-close:hover { background: #f3d9a4; color: #7a4b12; }

.smart-search-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.smart-search-item + .smart-search-item { margin-top: 0.5rem; }
.smart-search-item a {
    display: block;
    padding: 0.55rem 0.7rem;
    background: #ffffff;
    border: 1px solid #f3d9a4;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
}
.smart-search-item a:hover {
    border-color: #e08a19;
    background: #fffdf7;
}
.smart-search-title {
    font-weight: 600;
    color: #0366d6;
    font-size: 0.95rem;
}
.smart-search-meta {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.15rem;
    display: flex;
    gap: 0.75rem;
}
.smart-search-category {
    background: #f3f4f6;
    color: #374151;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
}
.smart-search-score { color: #059669; font-weight: 600; }
.smart-search-excerpt {
    font-size: 0.85rem;
    color: #4b5563;
    margin-top: 0.3rem;
    line-height: 1.45;
}

/* "Ask the docs" AI chat box */
.ask-box {
    background: #fff8ec;
    border: 1px solid #f3d9a4;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 0 0 2rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.ask-form {
    display: flex;
    gap: 0.5rem;
}
.ask-form input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}
.ask-form button {
    padding: 0.55rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    background: #e08a19;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}
.ask-form button:hover:not([disabled]) { background: #c46b0a; }
.ask-form button[disabled] { opacity: 0.6; cursor: wait; }
.ask-answer {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid #f3d9a4;
    font-size: 0.95rem;
    line-height: 1.55;
}
.ask-answer .ask-answer-text { color: #1f2937; }
.ask-answer .ask-citations {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #6b7280;
}
.ask-answer .ask-citations ol {
    margin: 0.35rem 0 0 1.25rem;
    padding: 0;
}
.ask-answer .ask-citations a { color: #0366d6; }

/* Mobile responsive tweaks */
@media (max-width: 640px) {
    .home-hero { flex-direction: column; text-align: center; padding: 1.5rem 1rem; }
    .home-hero-text h1 { font-size: 1.4rem; }
    .category-grid { grid-template-columns: 1fr; }
    body { padding: 1rem; }
}