/* Documentation page layout */
.docs-layout {
    display: flex;
    min-height: calc(100vh - 200px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    gap: 3rem;
}

/* Sticky sidebar TOC */
.docs-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 5rem;
    align-self: flex-start;
    max-height: calc(100vh - 6rem);
    overflow: visible; /* allow search dropdown to escape */
    display: flex;
    flex-direction: column;
}

.docs-sidebar-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
}

/* Search */
.docs-search-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}

.docs-search-input {
    width: 100%;
    padding: 0.375rem 0.5rem 0.375rem 1.875rem;
    font-size: 0.8125rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-body-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.5rem center;
    background-size: 0.875rem;
    color: var(--bs-body-color);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}

.docs-search-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.15);
}

/* Hide the native clear (×) button */
.docs-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.docs-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 380px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}

.docs-search-result {
    display: block;
    padding: 0.625rem 0.875rem;
    text-decoration: none;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    transition: background 0.1s;
}

.docs-search-result:last-child {
    border-bottom: none;
}

.docs-search-result:hover {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.docs-search-result-title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
}

.docs-search-result-sub {
    font-size: 0.75rem;
    color: var(--bs-primary);
    margin-top: 1px;
}

.docs-search-result-snippet {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    margin-top: 3px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.docs-search-result-snippet mark {
    background: rgba(var(--bs-warning-rgb), 0.35);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.docs-search-empty {
    padding: 0.75rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.docs-sidebar-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
}

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

.docs-nav li {
    margin: 0;
}

.docs-nav-link {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    color: var(--bs-body-color);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.docs-nav-link:hover {
    color: var(--bs-primary);
}

.docs-nav-link.active {
    color: var(--bs-primary);
    border-left-color: var(--bs-primary);
    font-weight: 500;
}

/* Nested nav for subsections */
.docs-nav .docs-nav {
    padding-left: 0.75rem;
}

.docs-nav .docs-nav .docs-nav-link {
    font-size: 0.8125rem;
    padding: 0.25rem 0.75rem;
}

/* Main content area */
.docs-content {
    flex: 1;
    min-width: 0;
    max-width: 760px;
}

/* Section spacing */
.docs-section {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.docs-section:last-child {
    border-bottom: none;
}

.docs-section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-top: 1rem;
}

.docs-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.docs-section p {
    line-height: 1.7;
    margin-bottom: 1rem;
}

.docs-section ul, .docs-section ol {
    line-height: 1.7;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.docs-section li {
    margin-bottom: 0.35rem;
}

/* Callout blocks */
.docs-callout {
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    border-left: 4px solid;
}

.docs-callout p {
    margin-bottom: 0.5rem;
}

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

.docs-callout-tip {
    background-color: rgba(var(--bs-info-rgb), 0.08);
    border-color: var(--bs-info);
}

.docs-callout-tip .docs-callout-label {
    color: var(--bs-info);
    font-weight: 600;
}

.docs-callout-philosophy {
    background-color: rgba(var(--bs-primary-rgb), 0.08);
    border-color: var(--bs-primary);
}

.docs-callout-philosophy .docs-callout-label {
    color: var(--bs-primary);
    font-weight: 600;
}

.docs-callout-warning {
    background-color: rgba(var(--bs-warning-rgb), 0.08);
    border-color: var(--bs-warning);
}

/* Figures / screenshots */
.docs-figure {
    margin: 1.5rem 0;
    text-align: center;
}

.docs-figure img {
    max-width: 100%;
    border-radius: 0.5rem;
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.docs-figure figcaption {
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Screenshot placeholder (when image doesn't exist yet) */
.docs-figure-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: var(--bs-tertiary-bg);
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

/* Code blocks */
.docs-section pre {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 1rem 0;
}

.docs-section code {
    font-size: 0.875em;
    background: var(--bs-tertiary-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

.docs-section pre code {
    background: none;
    padding: 0;
}

/* Hero / intro section */
.docs-hero {
    text-align: center;
    padding: 2rem 0 3rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.docs-hero h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.docs-hero .lead {
    font-size: 1.125rem;
    color: var(--bs-secondary-color);
    max-width: 600px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------------------
   AI Assistant — hero input
--------------------------------------------------------------------------- */

.docs-ai-hero-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 540px;
    margin: 1.75rem auto 0;
    background: var(--bs-body-bg);
    border: 1.5px solid var(--bs-border-color);
    border-radius: 2rem;
    padding: 0.375rem 0.375rem 0.375rem 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.docs-ai-hero-input:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 2px 16px rgba(var(--bs-primary-rgb), 0.15);
}

.docs-ai-hero-icon {
    flex-shrink: 0;
    color: var(--bs-primary);
    opacity: 0.8;
}

.docs-ai-hero-field {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--bs-body-color);
    padding: 0.25rem 0;
    min-width: 0;
}

.docs-ai-hero-field::placeholder {
    color: var(--bs-secondary-color);
}

.docs-ai-hero-btn {
    flex-shrink: 0;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 1.5rem;
    background: var(--bs-primary);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s;
}

.docs-ai-hero-btn:hover {
    opacity: 0.88;
}

.docs-ai-hero-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------------------------------------------------------------------------
   AI Assistant — chat panel
--------------------------------------------------------------------------- */

.docs-ai-panel {
    margin-bottom: 2.5rem;
    border: 1.5px solid var(--bs-border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--bs-body-bg);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
}

.docs-ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.docs-ai-panel-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bs-primary);
}

.docs-ai-clear-btn {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.docs-ai-clear-btn:hover {
    background: var(--bs-border-color);
    color: var(--bs-body-color);
}

/* Message thread */
.docs-ai-messages {
    padding: 1.25rem 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 520px;
    overflow-y: auto;
}

.docs-ai-msg {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.docs-ai-msg-user {
    align-items: flex-end;
}

.docs-ai-msg-assistant {
    align-items: flex-start;
}

.docs-ai-bubble {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.docs-ai-msg-user .docs-ai-bubble {
    background: var(--bs-primary);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.docs-ai-msg-assistant .docs-ai-bubble {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    border-bottom-left-radius: 0.25rem;
    max-width: 100%;
}

.docs-ai-bubble p {
    margin: 0 0 0.5rem;
}

.docs-ai-bubble p:last-child {
    margin-bottom: 0;
}

.docs-ai-bubble code {
    font-size: 0.85em;
    background: rgba(0, 0, 0, 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
}

/* Streaming cursor */
.docs-ai-cursor::after {
    content: '▋';
    animation: docs-ai-blink 0.8s step-end infinite;
    margin-left: 1px;
    font-size: 0.85em;
    color: var(--bs-primary);
}

@keyframes docs-ai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Further reading references */
.docs-ai-refs {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.docs-ai-refs-label {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    font-weight: 500;
    white-space: nowrap;
}

.docs-ai-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 1rem;
    border: 1px solid var(--bs-primary);
    color: var(--bs-primary);
    text-decoration: none;
    background: rgba(var(--bs-primary-rgb), 0.06);
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.docs-ai-ref-chip:hover {
    background: var(--bs-primary);
    color: #fff;
}

/* Compose area */
.docs-ai-compose {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

.docs-ai-followup-field {
    flex: 1;
    border: 1px solid var(--bs-border-color);
    border-radius: 1.5rem;
    padding: 0.4rem 0.875rem;
    font-size: 0.875rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    outline: none;
    transition: border-color 0.15s;
    min-width: 0;
}

.docs-ai-followup-field:focus {
    border-color: var(--bs-primary);
    background: var(--bs-body-bg);
}

.docs-ai-followup-field::placeholder {
    color: var(--bs-secondary-color);
}

.docs-ai-followup-btn {
    flex-shrink: 0;
    width: 2.125rem;
    height: 2.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s;
}

.docs-ai-followup-btn:hover {
    opacity: 0.88;
}

.docs-ai-followup-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Responsive: collapse sidebar on small screens */
@media (max-width: 768px) {
    .docs-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .docs-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        border-bottom: 1px solid var(--bs-border-color);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .docs-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .docs-nav-link {
        border-left: none;
        border-bottom: 2px solid transparent;
        padding: 0.25rem 0.5rem;
        font-size: 0.8125rem;
    }

    .docs-nav-link.active {
        border-left: none;
        border-bottom-color: var(--bs-primary);
    }

    .docs-nav .docs-nav {
        padding-left: 0;
    }
}
