/* ============================================
   MALV Documentation Site - Minimal Monochrome
   Following malv.ai landing page aesthetic
   ============================================ */

/* ============================================
   CSS Variables
   ============================================ */

:root {
    /* Colors - Monochrome palette */
    --color-bg: #ffffff;
    --color-bg-secondary: #f5f5f5;
    --color-text: #111;
    --color-text-secondary: #333;
    --color-text-muted: #666;
    --color-border: #f5f5f5;
    --color-border-subtle: #eee;

    /* Code */
    --color-code-bg: #f5f5f5;
    --color-code-text: #333;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Layout */
    --sidebar-width: 260px;
    --content-max-width: 720px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
}

/* ============================================
   Typography
   ============================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 400;
    line-height: 1.3;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 2rem;
    margin-bottom: var(--space-lg);
}

h2 {
    font-size: 1.5rem;
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
}

h3 {
    font-size: 1.25rem;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-sm);
}

h4 {
    font-size: 1.125rem;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

p {
    margin-bottom: var(--space-md);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px dotted var(--color-text);
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-style: solid;
}

strong {
    font-weight: 600;
}

/* ============================================
   Documentation Layout
   ============================================ */

.docs-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.docs-sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    padding: var(--space-xl) var(--space-lg);
    padding-top: 0 !important;
    margin-top: 0 !important;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    top: 0;
    left: 0;
}

.docs-sidebar::-webkit-scrollbar {
    width: 6px;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.nav-section {
    margin-bottom: var(--space-sm);
}

.nav-section-title {
    display: flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.nav-items {
    list-style: none;
    margin: 0;
    padding: 0 !important;
}

.nav-items li {
    margin-bottom: 2px;
}

.nav-items a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--space-xs) var(--space-sm);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    border-bottom: none;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s, color 0.15s;
}

/* Navigation Icons */
.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.nav-items a:hover .nav-icon svg,
.nav-items a.active .nav-icon svg {
    opacity: 1;
}

.nav-items a:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-text);
    border-bottom: none;
}

.nav-items a.active {
    background-color: var(--color-bg-secondary);
    color: var(--color-text);
    font-weight: 500;
}

/* Content Area */
.docs-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-2xl);
    max-width: calc(var(--sidebar-width) + var(--content-max-width) + var(--space-2xl) * 2);
    position: relative;
    padding-bottom: 200px;
}

.docs-content>*:first-child {
    margin-top: 0;
}

/* ============================================
   Lists
   ============================================ */

ul,
ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-lg);
    color: var(--color-text-secondary);
}

li {
    margin: var(--space-xs) 0;
}

li>ul,
li>ol {
    margin-top: var(--space-xs);
    margin-bottom: var(--space-xs);
}

/* ============================================
   Code
   ============================================ */

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
}

pre {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    background-color: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-lg) 0;
    position: relative;
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.copy-button {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

pre:hover .copy-button {
    opacity: 0.7;
}

.copy-button:hover {
    opacity: 1;
}

/* Page Copy Button */
.page-copy-button {
    position: absolute;
    top: var(--space-2xl);
    right: var(--space-2xl);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.page-copy-button:hover {
    opacity: 1;
}

/* ============================================
   Tables
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-lg) 0;
    font-size: 0.9375rem;
}

th,
td {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-secondary);
}

th {
    font-weight: 500;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border-subtle);
}

td {
    border-bottom: 1px solid var(--color-border);
}

tr:last-child td {
    border-bottom: none;
}

/* ============================================
   Blockquotes / Notes
   ============================================ */

blockquote {
    border-left: 3px solid var(--color-border-subtle);
    padding-left: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--color-text-muted);
    font-style: normal;
}

blockquote p {
    color: inherit;
}

/* ============================================
   Horizontal Rules
   ============================================ */

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-2xl) 0;
}

/* ============================================
   Images
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

/* ============================================
   Mobile Menu
   ============================================ */

/* Mobile menu button - hidden by default */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    z-index: 150;
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
}

.mobile-menu-btn:hover {
    background: var(--color-bg-secondary);
}

/* Mobile backdrop - hidden by default */
.mobile-backdrop {
    display: none;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 900px) {

    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex;
    }

    /* Sidebar as overlay */
    .docs-sidebar-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        background: var(--color-bg);
        border-right: 1px solid var(--color-border);
    }

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

    .docs-sidebar-wrapper .docs-sidebar {
        padding: var(--space-lg);
        height: 100%;
        overflow-y: auto;
    }

    /* Backdrop */
    .mobile-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 199;
    }

    .mobile-backdrop.open {
        display: block;
    }

    .docs-content {
        margin-left: 0;
        padding: var(--space-lg);
        padding-top: calc(var(--space-lg) + 60px);
        max-width: 100%;
    }

    .docs-container {
        flex-direction: column;
    }

    .search-modal {
        padding-top: var(--space-lg);
    }

    .search-footer {
        display: none;
    }

    .search-fab {
        right: var(--space-lg);
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    pre {
        padding: var(--space-md);
        font-size: 0.8125rem;
    }
}

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

/* Sidebar Wrapper */
.docs-sidebar-wrapper {
    width: var(--sidebar-width);
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
}

.docs-sidebar-wrapper .docs-sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: none;
    scrollbar-gutter: stable;
}

/* Hide scrollbar until hover/scroll needed */
.docs-sidebar-wrapper .docs-sidebar::-webkit-scrollbar {
    width: 6px;
}

.docs-sidebar-wrapper .docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar-wrapper .docs-sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

.docs-sidebar-wrapper .docs-sidebar:hover::-webkit-scrollbar-thumb {
    background: var(--color-border);
}

/* Sidebar Header */
.sidebar-header {
    padding: var(--space-sm) 0;
    padding-top: 25px;
    padding-left: 4px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border: none !important;
}

.sidebar-logo img {
    width: 24px;
    height: 24px;
    transition: opacity 0.15s;
}

.sidebar-logo:hover img {
    opacity: 0.7;
}

/* Search Modal */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-modal[hidden] {
    display: none;
}

.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.search-modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 var(--space-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* Search Input */
.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.search-input-wrapper .search-icon {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

#searchInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: transparent;
}

#searchInput::placeholder {
    color: var(--color-text-muted);
}

.search-esc {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}

/* Search Results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-sm);
}

.search-result {
    display: block;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    border-bottom: none;
    cursor: pointer;
    transition: background-color 0.1s;
}

.search-result:hover,
.search-result.selected {
    background: var(--color-bg-secondary);
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.125rem;
}

.search-result-section {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.search-result-preview {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-empty,
.search-no-results {
    padding: var(--space-xl);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Search Footer */
.search-footer {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--color-border);
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.search-footer kbd {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    padding: 0.125rem 0.25rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: 3px;
    margin-right: 0.25rem;
}

/* ============================================
   Download FAB
   ============================================ */

.search-fab {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.search-fab svg {
    width: 20px;
    height: 20px;
}

.search-fab:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.download-fab {
    position: fixed;
    bottom: var(--space-xl);
    left: calc(var(--sidebar-width) + var(--space-xl));
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 100;
}

.download-fab:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.download-fab:disabled {
    opacity: 0.7;
    cursor: wait;
}

.download-fab svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.download-fab-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.download-fab-text {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
}

.download-fab-subtext {
    font-size: 0.625rem;
    opacity: 0.7;
    line-height: 1.2;
}

@media (max-width: 900px) {
    .download-fab {
        display: none;
    }
}

/* Download Modal */
.download-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-modal[hidden] {
    display: none;
}

.download-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.download-modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 var(--space-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.download-modal-content h3 {
    margin: 0 0 var(--space-lg);
    font-size: 1.25rem;
    font-weight: 500;
}

.download-modal-steps {
    margin: 0 0 var(--space-lg);
    padding-left: var(--space-lg);
    color: var(--color-text-secondary);
}

.download-modal-steps li {
    margin-bottom: var(--space-sm);
    line-height: 1.5;
}

.download-modal-steps code {
    background: var(--color-code-bg);
    padding: 0.1em 0.4em;
    border-radius: var(--radius-sm);
    font-size: 0.875em;
}

.download-modal-note {
    margin: 0 0 var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.download-modal-close {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.download-modal-close:hover {
    opacity: 0.9;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .docs-sidebar {
        display: none;
    }

    .docs-content {
        margin-left: 0;
        max-width: 100%;
    }

    a {
        text-decoration: underline;
        border-bottom: none;
    }

    pre {
        page-break-inside: avoid;
    }

    .download-fab {
        display: none;
    }
}
