/**
 * MagePeople Documentation Hub — Frontend Styles
 * Clerk.io-inspired documentation UI.
 * Customize via the CSS variables below (override in your theme).
 */

/* ==========================================================================
   1. CSS Variables
   ========================================================================== */
:root {
    --mp-primary: #1F2937;
    --mp-secondary: #10B981;
    --mp-dark: #111827;
    --mp-light: #F9FAFB;
    --mp-border: #E5E7EB;
    --mp-text: #374151;
    --mp-text-light: #6B7280;
    --mp-text-lighter: #9CA3AF;
    --mp-white: #FFFFFF;
    --mp-danger: #EF4444;
    --mp-warning: #F59E0B;
    --mp-info: #3B82F6;
    --mp-success: #10B981;

    --mp-radius-sm: 6px;
    --mp-radius: 10px;
    --mp-radius-lg: 16px;
    --mp-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --mp-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.06);
    --mp-sidebar-width: 280px;
    --mp-toc-width: 220px;
    --mp-header-height: 64px;
    --mp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mp-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    body.mp-docs-dark-auto {
        --mp-light: #0B0F19;
        --mp-white: #131826;
        --mp-dark: #F9FAFB;
        --mp-border: #232A3B;
        --mp-text: #E5E7EB;
        --mp-text-light: #9CA3AF;
        --mp-text-lighter: #6B7280;
    }
}

/* ==========================================================================
   2. Base
   ========================================================================== */
.mp-docs-container,
.mp-search-modal,
.mp-ai-chat-widget {
    font-family: var(--mp-font);
    color: var(--mp-text);
    box-sizing: border-box;
}

.mp-docs-container *,
.mp-search-modal *,
.mp-ai-chat-widget * {
    box-sizing: inherit;
}

.mp-docs-container a {
    color: var(--mp-secondary);
    text-decoration: none;
}

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

/* ==========================================================================
   3. Layout
   ========================================================================== */
.mp-docs-container {
    display: grid;
    grid-template-columns: var(--mp-sidebar-width) minmax(0, 1fr);
    max-width: var(--mp-container-width, 1200px);
    margin: 0 auto;
    min-height: 70vh;
    position: relative;
}

.mp-docs-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--mp-header-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--mp-border);
    position: sticky;
    top: 0;
    background: var(--mp-white);
    z-index: 20;
}

/* WP's admin toolbar is position:fixed at the same top:0, with a higher
   z-index — every sticky/fixed element anchored to "top: 0" (or an offset
   built on it) needs to shift down by the toolbar's height, in both of its
   own responsive states, or it renders underneath the toolbar. */
body.admin-bar .mp-docs-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .mp-docs-header {
        top: 46px;
    }
}

.mp-docs-sidebar {
    border-right: 1px solid var(--mp-border);
    padding: 24px;
    position: sticky;
    top: var(--mp-header-height);
    align-self: start;
    max-height: calc(100vh - var(--mp-header-height));
    overflow-y: auto;
}

body.admin-bar .mp-docs-sidebar {
    top: calc(var(--mp-header-height) + 32px);
    max-height: calc(100vh - var(--mp-header-height) - 32px);
}

.mp-docs-main {
    padding: 40px 48px;
    min-width: 0;
}

/* ==========================================================================
   4. Header / Breadcrumb
   ========================================================================== */
.mp-docs-sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mp-docs-sidebar-toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--mp-text);
    border-radius: 2px;
}

.mp-breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--mp-text-light);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mp-breadcrumb a {
    color: var(--mp-text-light);
}

.mp-breadcrumb a:hover {
    color: var(--mp-secondary);
}

.mp-breadcrumb-sep {
    color: var(--mp-text-lighter);
}

.mp-breadcrumb-current {
    color: var(--mp-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-docs-search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--mp-light);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    color: var(--mp-text-light);
    font-size: 13px;
    cursor: pointer;
}

.mp-docs-search-trigger kbd {
    background: var(--mp-white);
    border: 1px solid var(--mp-border);
    border-radius: 4px;
    font-size: 11px;
    padding: 1px 5px;
}

.mp-docs-ask-ai-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--mp-secondary);
    border: 1px solid var(--mp-secondary);
    border-radius: var(--mp-radius-sm);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.mp-docs-ask-ai-trigger:hover {
    opacity: 0.9;
}

/* ==========================================================================
   5. Sidebar Navigation
   ========================================================================== */
.mp-sidebar-search {
    margin-bottom: 16px;
}

.mp-sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    font-size: 13px;
    background: var(--mp-light);
}

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

.mp-sidebar-item {
    margin-bottom: 4px;
}

.mp-sidebar-link {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: var(--mp-radius-sm);
    background: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    color: var(--mp-text) !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    cursor: pointer;
}

.mp-sidebar-link:hover {
    background: var(--mp-light);
}

.mp-sidebar-link-label {
    flex: 1;
}

.mp-sidebar-caret {
    flex-shrink: 0;
    display: inline-flex;
    color: var(--mp-text-lighter);
    transition: transform 0.15s ease;
}

.mp-sidebar-caret svg {
    display: block;
}

.mp-sidebar-item.is-collapsed .mp-sidebar-caret {
    transform: rotate(-90deg);
}

.mp-sidebar-item.is-collapsed > .mp-sidebar-nested {
    display: none;
}

/* A single-doc leaf category (see parts/sidebar.php) renders as a direct
   link rather than a collapsible heading — same position/padding as a
   heading, but styled like a regular doc link (normal case, lighter
   weight) since it IS one, not a category name. */
.mp-sidebar-leaf-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--mp-radius-sm);
    font-size: 14px;
    font-weight: 400;
    color: var(--mp-text-light) !important;
}

.mp-sidebar-leaf-link:hover,
.mp-sidebar-leaf-link.is-active {
    background: var(--mp-light);
    color: var(--mp-secondary) !important;
    text-decoration: none !important;
}

.mp-sidebar-nested {
    list-style: none;
    margin: 2px 0 8px;
    padding-left: 20px;
}

.mp-sidebar-nested a {
    display: block;
    padding: 6px 10px;
    border-radius: var(--mp-radius-sm);
    font-size: 14px;
    color: var(--mp-text-light) !important;
}

.mp-sidebar-nested a:hover,
.mp-sidebar-nested a.is-active {
    background: var(--mp-light);
    color: var(--mp-secondary) !important;
    text-decoration: none !important;
}

.mp-sidebar-empty {
    color: var(--mp-text-lighter);
    font-size: 13px;
}

/* ==========================================================================
   6. Content
   ========================================================================== */
.mp-docs-content {
    max-width: 100%;
}

.mp-docs-title {
    font-size: 34px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--mp-dark);
    margin: 8px 0 12px;
}

.mp-docs-description {
    font-size: 17px;
    color: var(--mp-text-light);
    margin-bottom: 24px;
}

.mp-docs-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--mp-toc-width);
    gap: 40px;
    align-items: start;
}

.mp-docs-body {
    font-size: 16px;
    line-height: 1.75;
}

.mp-docs-body h2 {
    font-size: 26px;
    font-weight: 700;
    margin: 40px 0 16px;
    scroll-margin-top: calc(var(--mp-header-height) + 16px);
}

.mp-docs-body h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 32px 0 12px;
    scroll-margin-top: calc(var(--mp-header-height) + 16px);
}

.mp-docs-body h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 24px 0 8px;
    scroll-margin-top: calc(var(--mp-header-height) + 16px);
}

.mp-docs-body p {
    margin: 0 0 16px;
}

.mp-docs-body ul,
.mp-docs-body ol {
    margin: 0 0 16px;
    padding-left: 24px;
}

.mp-docs-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--mp-radius);
}

.mp-docs-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 24px;
    font-size: 14px;
}

.mp-docs-body th,
.mp-docs-body td {
    border: 1px solid var(--mp-border);
    padding: 8px 12px;
    text-align: left;
}

.mp-docs-body th {
    background: var(--mp-light);
}

.mp-docs-body code {
    font-family: var(--mp-font-mono);
    background: var(--mp-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.mp-docs-body pre {
    background: var(--mp-dark);
    color: #E5E7EB;
    padding: 16px 20px;
    border-radius: var(--mp-radius);
    overflow-x: auto;
    margin: 0 0 24px;
}

.mp-docs-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 13.5px;
}

.mp-docs-body blockquote {
    border-left: 3px solid var(--mp-secondary);
    margin: 0 0 16px;
    padding: 4px 0 4px 16px;
    color: var(--mp-text-light);
}

/* ==========================================================================
   7. Table of Contents
   ========================================================================== */
.mp-toc {
    position: sticky;
    top: calc(var(--mp-header-height) + 24px);
    font-size: 13px;
}

/* .mp-toc is display:none below 1100px (see the max-width:1100px rule
   below), well above the 782px breakpoint where the toolbar itself
   shrinks, so only the 32px (desktop) toolbar height ever applies here. */
body.admin-bar .mp-toc {
    top: calc(var(--mp-header-height) + 24px + 32px);
}

.mp-toc-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    color: var(--mp-text-lighter);
    margin: 0 0 8px;
}

.mp-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--mp-border);
}

.mp-toc-item a {
    display: block;
    padding: 4px 0 4px 14px;
    color: var(--mp-text-light) !important;
    border-left: 2px solid transparent;
    margin-left: -1px;
}

.mp-toc-item a:hover,
.mp-toc-item a.is-active {
    color: var(--mp-secondary) !important;
    border-left-color: var(--mp-secondary);
    text-decoration: none !important;
}

.mp-toc-level-3 a {
    padding-left: 26px;
}

.mp-toc-level-4 a {
    padding-left: 38px;
}

/* ==========================================================================
   8. Badges, Callouts, Pagination, Related
   ========================================================================== */
.mp-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--mp-badge-color, var(--mp-secondary)) 15%, transparent);
    color: var(--mp-badge-color, var(--mp-secondary));
    margin-bottom: 12px;
}

.mp-callout {
    border-radius: var(--mp-radius);
    padding: 16px 20px;
    margin: 0 0 20px;
    border: 1px solid var(--mp-border);
    border-left-width: 4px;
}

.mp-callout-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.mp-callout-info {
    border-left-color: var(--mp-info);
    background: rgba(59, 130, 246, 0.06);
}

.mp-callout-warning {
    border-left-color: var(--mp-warning);
    background: rgba(245, 158, 11, 0.08);
}

.mp-callout-danger {
    border-left-color: var(--mp-danger);
    background: rgba(239, 68, 68, 0.06);
}

.mp-callout-success {
    border-left-color: var(--mp-success);
    background: rgba(16, 185, 129, 0.06);
}

.mp-docs-pagenav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 48px 0 32px;
}

.mp-docs-pagenav a {
    display: block;
    padding: 16px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    color: var(--mp-text) !important;
}

.mp-docs-pagenav a:hover {
    border-color: var(--mp-secondary);
    text-decoration: none !important;
}

.mp-docs-pagenav-next {
    text-align: right;
}

.mp-docs-pagenav-label {
    display: block;
    font-size: 12px;
    color: var(--mp-text-lighter);
    margin-bottom: 4px;
}

.mp-docs-pagenav-title {
    font-weight: 600;
}

.mp-docs-related {
    border-top: 1px solid var(--mp-border);
    padding-top: 20px;
    margin-top: 20px;
}

.mp-docs-related h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

.mp-docs-related ul {
    margin: 0;
    padding-left: 20px;
}

.mp-docs-footer {
    margin-top: 32px;
    padding: 20px;
    background: var(--mp-light);
    border-radius: var(--mp-radius);
    font-size: 14px;
    color: var(--mp-text-light);
}

.mp-docs-footer-ask-ai {
    background: var(--mp-secondary);
    color: #fff;
    border: none;
    border-radius: var(--mp-radius-sm);
    padding: 6px 12px;
    margin-left: 8px;
    cursor: pointer;
    font-size: 13px;
}

/* ==========================================================================
   9a. Product Picker / Product Home / Product Switcher
   ========================================================================== */
.mp-support-links {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mp-border);
}

.mp-support-links ul {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.mp-support-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--mp-radius-sm);
    font-size: 14px;
    color: var(--mp-text) !important;
}

.mp-support-links a:hover {
    background: var(--mp-light);
    text-decoration: none !important;
}

.mp-support-links-icon {
    font-size: 15px;
    line-height: 1;
}

.mp-sidebar-section-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    color: var(--mp-text-lighter);
    margin: 0 0 8px;
}

.mp-popular-articles {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mp-border);
}

.mp-popular-articles ol {
    list-style: none;
    counter-reset: mp-popular-articles-counter;
    margin: 8px 0 0;
    padding: 0;
}

.mp-popular-articles li {
    counter-increment: mp-popular-articles-counter;
}

.mp-popular-articles a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--mp-radius-sm);
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--mp-text) !important;
}

.mp-popular-articles a::before {
    content: counter(mp-popular-articles-counter);
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--mp-text-lighter);
    min-width: 14px;
}

.mp-popular-articles a:hover {
    background: var(--mp-light);
    text-decoration: none !important;
}

.mp-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 32px;
}

.mp-product-card {
    display: block;
    padding: 24px;
    border: 1px solid var(--mp-border);
    border-top: 3px solid var(--mp-badge-color, var(--mp-secondary));
    border-radius: var(--mp-radius);
    color: var(--mp-text) !important;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.mp-product-card:hover {
    box-shadow: var(--mp-shadow-lg);
    transform: translateY(-2px);
    text-decoration: none !important;
}

.mp-product-card-logo {
    max-width: 40px;
    max-height: 40px;
    margin-bottom: 12px;
}

.mp-product-card-icon {
    display: block;
    font-size: 28px;
    width: 28px;
    height: 28px;
    margin-bottom: 12px;
    color: var(--mp-badge-color, var(--mp-secondary));
}

.mp-product-card-title {
    margin: 0 0 6px;
    font-size: 17px;
}

.mp-product-card-description {
    margin: 0;
    font-size: 14px;
    color: var(--mp-text-light);
}

.mp-docs-product-home .mp-product-home-logo {
    max-width: 56px;
    max-height: 56px;
    margin-bottom: 12px;
}

.mp-docs-product-section {
    margin-top: 40px;
}

.mp-docs-product-section h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.mp-sidebar-back {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--mp-text-light) !important;
}

.mp-product-switcher {
    position: relative;
}

.mp-product-switcher-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: none;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--mp-text);
    cursor: pointer;
}

.mp-product-switcher-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    max-width: min(90vw, 320px);
    max-height: min(70vh, 480px);
    overflow-y: auto;
    background: var(--mp-white);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    box-shadow: var(--mp-shadow-lg);
    list-style: none;
    margin: 0;
    padding: 6px;
    z-index: 40;
}

.mp-product-switcher-menu a {
    display: block;
    padding: 8px 10px;
    border-radius: var(--mp-radius-sm);
    color: var(--mp-text) !important;
    font-size: 14px;
}

.mp-product-switcher-menu a:hover,
.mp-product-switcher-menu a.is-current {
    background: var(--mp-light);
    text-decoration: none !important;
}

.mp-product-switcher-all {
    border-top: 1px solid var(--mp-border);
    margin-top: 4px;
    padding-top: 4px;
}

.mp-product-switcher-row {
    display: flex;
    align-items: center;
}

.mp-product-switcher-row a {
    flex: 1;
    min-width: 0;
}

.mp-product-switcher-toggle {
    flex: 0 0 auto;
    background: none;
    border: none;
    padding: 8px;
    margin-left: 2px;
    color: var(--mp-text-light);
    cursor: pointer;
    border-radius: var(--mp-radius-sm);
    transition: transform 0.15s ease;
}

.mp-product-switcher-toggle:hover {
    background: var(--mp-light);
}

.mp-product-switcher-item.is-open .mp-product-switcher-toggle {
    transform: rotate(180deg);
}

/* Collapsed by default — expanded only for the product/addon family
   currently being viewed (see $is_open in product-switcher.php), or once
   the reader opens it themselves via the toggle button. Without this, a
   product with a dozen-plus addons turns the whole menu into one long,
   unscrollable-feeling wall of links. */
.mp-product-switcher-addons {
    display: none;
    list-style: none;
    margin: 2px 0 4px;
    padding: 0 0 0 14px;
    border-left: 2px solid var(--mp-border);
}

.mp-product-switcher-item.is-open > .mp-product-switcher-addons {
    display: block;
}

.mp-product-switcher-addons a {
    font-size: 13px;
    color: var(--mp-text-light) !important;
    padding: 6px 10px;
}

.mp-search-scope,
.mp-ai-chat-scope {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    font-size: 12px;
    color: var(--mp-text-light);
    border-bottom: 1px solid var(--mp-border);
}

/* ==========================================================================
   9. Archive Grid
   ========================================================================== */
.mp-docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.mp-docs-card {
    display: block;
    padding: 20px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    color: var(--mp-text) !important;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.mp-docs-card:hover {
    box-shadow: var(--mp-shadow-lg);
    transform: translateY(-2px);
    text-decoration: none !important;
}

.mp-docs-card h3 {
    margin: 0 0 8px;
    font-size: 17px;
}

.mp-docs-card p {
    margin: 0;
    font-size: 14px;
    color: var(--mp-text-light);
}

/* ==========================================================================
   10. Search Modal
   ========================================================================== */
.mp-search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}

.mp-search-modal.is-open {
    display: block;
}

.mp-search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    animation: mp-fade-in 0.15s ease;
}

.mp-search-modal-panel {
    position: relative;
    max-width: 640px;
    margin: 10vh auto 0;
    background: var(--mp-white);
    border-radius: var(--mp-radius-lg);
    box-shadow: var(--mp-shadow-lg);
    overflow: hidden;
    animation: mp-slide-down 0.15s ease;
}

.mp-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mp-border);
}

.mp-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    color: var(--mp-text);
}

.mp-search-input-wrap kbd {
    background: var(--mp-light);
    border: 1px solid var(--mp-border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--mp-text-lighter);
}

.mp-search-results {
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
}

.mp-search-result {
    display: block;
    padding: 12px 14px;
    border-radius: var(--mp-radius-sm);
    color: var(--mp-text) !important;
}

.mp-search-result:hover,
.mp-search-result.is-active {
    background: var(--mp-light);
    text-decoration: none !important;
}

.mp-search-result-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.mp-search-result-excerpt {
    font-size: 13px;
    color: var(--mp-text-light);
}

.mp-search-empty,
.mp-search-loading {
    padding: 24px;
    text-align: center;
    color: var(--mp-text-lighter);
    font-size: 14px;
}

/* ==========================================================================
   11. AI Chat Widget
   ========================================================================== */
.mp-ai-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 900;
}

.mp-ai-chat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--mp-primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    box-shadow: var(--mp-shadow-lg);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.mp-ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 480px;
    max-height: 70vh;
    background: var(--mp-white);
    border-radius: var(--mp-radius-lg);
    box-shadow: var(--mp-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mp-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--mp-primary);
    color: #fff;
    font-weight: 600;
}

.mp-ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.mp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mp-ai-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--mp-radius);
    font-size: 14px;
    line-height: 1.5;
}

.mp-ai-message-user {
    align-self: flex-end;
    background: var(--mp-secondary);
    color: #fff;
}

.mp-ai-message-assistant {
    align-self: flex-start;
    background: var(--mp-light);
    color: var(--mp-text);
}

.mp-ai-message-assistant pre {
    background: var(--mp-dark);
    color: #e5e7eb;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12.5px;
}

.mp-ai-message-sources {
    margin-top: 6px;
    font-size: 12px;
}

.mp-ai-message-sources a {
    color: inherit;
    text-decoration: underline;
}

.mp-ai-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--mp-border);
}

.mp-ai-chat-form input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius-sm);
    font-size: 14px;
}

.mp-ai-chat-form button {
    background: var(--mp-secondary);
    color: #fff;
    border: none;
    border-radius: var(--mp-radius-sm);
    padding: 0 16px;
    cursor: pointer;
    font-weight: 600;
}

.mp-ai-chat-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   12. Code Highlighting Tokens (assets/js/highlight.js)
   ========================================================================== */
.mpdocs-tok-comment {
    color: #8B949E;
    font-style: italic;
}

.mpdocs-tok-string {
    color: #A5D6FF;
}

.mpdocs-tok-keyword {
    color: #FF7B72;
    font-weight: 600;
}

.mpdocs-tok-variable {
    color: #79C0FF;
}

.mpdocs-tok-property {
    color: #7EE787;
}

/* ==========================================================================
   13. Animations
   ========================================================================== */
@keyframes mp-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mp-slide-down {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.mp-fade-in {
    animation: mp-fade-in 0.2s ease;
}

.mp-slide-down {
    animation: mp-slide-down 0.2s ease;
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */
@media (max-width: 1100px) {
    .mp-docs-layout {
        grid-template-columns: 1fr;
    }

    .mp-toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .mp-docs-container {
        grid-template-columns: 1fr;
    }

    .mp-docs-sidebar-toggle {
        display: flex;
    }

    .mp-docs-sidebar {
        position: fixed;
        top: var(--mp-header-height);
        left: 0;
        bottom: 0;
        width: min(320px, 85vw);
        background: var(--mp-white);
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--mp-shadow-lg);
    }

    body.admin-bar .mp-docs-sidebar {
        top: calc(var(--mp-header-height) + 32px);
        max-height: none;
    }

    .mp-docs-sidebar.is-open {
        transform: translateX(0);
    }

    .mp-docs-main {
        padding: 24px 20px;
    }

    .mp-docs-title {
        font-size: 26px;
    }
}

@media screen and (max-width: 782px) {
    body.admin-bar .mp-docs-sidebar {
        top: calc(var(--mp-header-height) + 46px);
    }
}

@media (max-width: 600px) {
    .mp-docs-header {
        padding: 0 16px;
    }

    .mp-docs-sidebar {
        padding: 24px 16px;
    }

    .mp-docs-search-trigger span {
        display: none;
    }

    .mp-docs-ask-ai-trigger span:last-child {
        display: none;
    }

    .mp-ai-chat-panel {
        width: calc(100vw - 32px);
        right: -8px;
    }

    .mp-docs-pagenav {
        grid-template-columns: 1fr;
    }
}
