/* =============================================================================
   99 Digital API Documentation — Styles
   Brand colors extracted from logo:
     Dark Green:  #1B5E3B
     Coral Red:   #E8655A
     Teal/Cyan:   #7ECEC2
     Orange:      #F0A830
     Blue:        #5B9BD5
   ============================================================================= */

/* --- CSS Variables --- */
:root {
    /* Brand */
    --color-primary:        #1B5E3B;
    --color-primary-dark:   #144A2E;
    --color-primary-darker: #0E3620;
    --color-primary-light:  #27774D;
    --color-accent-red:     #E8655A;
    --color-accent-teal:    #7ECEC2;
    --color-accent-orange:  #F0A830;
    --color-accent-blue:    #5B9BD5;

    /* Surfaces */
    --color-bg:             #FAFBFC;
    --color-surface:        #FFFFFF;
    --color-surface-hover:  #F3F6F9;
    --color-border:         #E2E8F0;
    --color-border-light:   #EDF2F7;

    /* Text */
    --color-text:           #1A202C;
    --color-text-secondary: #64748B;
    --color-text-muted:     #94A3B8;
    --color-text-inverse:   #FFFFFF;

    /* Sidebar */
    --sidebar-width:        300px;
    --sidebar-bg:           #0F2B1C;
    --sidebar-text:         #CBD5E1;
    --sidebar-text-hover:   #FFFFFF;
    --sidebar-active-bg:    rgba(126, 206, 194, 0.13);
    --sidebar-active-text:  #7ECEC2;
    --sidebar-divider:      rgba(255,255,255,0.09);

    /* Layout */
    --header-height:        56px;
    --content-max-width:    960px;
    --radius-sm:            4px;
    --radius-md:            8px;
    --radius-lg:            12px;

    /* Fonts */
    --font-sans:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:            'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Transitions */
    --transition-fast:      150ms ease;
    --transition-normal:    250ms ease;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--color-primary-dark);
    color: var(--color-text-inverse);
    z-index: 1000;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--color-text-inverse);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background var(--transition-fast);
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text-inverse);
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    transition: transform var(--transition-normal);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--sidebar-divider);
    flex-shrink: 0;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: opacity var(--transition-fast);
}
.logo-link:hover { opacity: 0.9; }

.logo-img {
    width: 36px;
    height: 36px;
    max-width: 36px;
    max-height: 36px;
    flex-shrink: 0;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-inverse);
    letter-spacing: -0.01em;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: var(--color-accent-teal);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* --- Search --- */
.search-container {
    position: relative;
    margin: 16px;
    flex-shrink: 0;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 9px 36px 9px 36px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    color: var(--color-text-inverse);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    outline: none;
    transition: all var(--transition-fast);
}
.search-input::placeholder { color: rgba(255,255,255,0.35); }
.search-input:focus {
    background: rgba(255,255,255,0.12);
    border-color: var(--color-accent-teal);
    box-shadow: 0 0 0 2px rgba(126,206,194,0.2);
}

.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    transition: color var(--transition-fast);
}
.search-clear:hover { color: var(--color-text-inverse); }
.search-clear .material-icons-outlined { font-size: 16px; }

/* --- Search Results --- */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}

.search-results-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 8px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent-teal);
}
.search-results-header .material-icons-outlined { font-size: 16px; }

.search-result-item {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-left: 2px solid transparent;
    margin-bottom: 2px;
}
.search-result-item:hover {
    background: rgba(255,255,255,0.06);
    border-left-color: var(--color-accent-teal);
}

.search-result-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-inverse);
    margin-bottom: 2px;
}

.search-result-collection {
    font-size: 0.7rem;
    color: var(--color-accent-orange);
    font-weight: 500;
}

.search-result-snippet {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    margin-top: 4px;
    line-height: 1.4;
    opacity: 0.7;
}

.search-no-results {
    padding: 20px 12px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* --- Nav Collection (top-level API folder) --- */
.nav-collection {
    margin-bottom: 4px;
}

.nav-collection-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
    user-select: none;
}
.nav-collection-header:hover { color: var(--color-text-inverse); }

.nav-collection-header .material-icons-outlined {
    font-size: 18px;
    transition: transform var(--transition-fast);
}

.nav-collection-header.expanded .caret-icon {
    transform: rotate(90deg);
}

.nav-collection-header .collection-icon {
    color: var(--color-accent-orange);
    font-size: 16px;
}

.nav-collection-body {
    display: none;
    padding-left: 0;
}
.nav-collection-body.expanded { display: block; }

/* --- Nav Folder (subfolder inside collection) --- */
.nav-folder {
    margin-bottom: 0;
}

.nav-folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px 9px 28px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--sidebar-text);
    transition: all var(--transition-fast);
    user-select: none;
}
.nav-folder-header:hover { color: var(--color-text-inverse); background: rgba(255,255,255,0.03); }

.nav-folder-header .material-icons-outlined { font-size: 16px; }
.nav-folder-header .caret-icon { transition: transform var(--transition-fast); }
.nav-folder-header.expanded .caret-icon { transform: rotate(90deg); }
.nav-folder-header .folder-icon { color: var(--color-accent-blue); font-size: 16px; }

.nav-folder-body {
    display: none;
}
.nav-folder-body.expanded { display: block; }

/* --- Nav Document (page link) --- */
.nav-doc {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px 9px 40px;
    font-size: 0.95rem;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
    text-decoration: none;
}
.nav-doc:hover {
    color: var(--color-text-inverse);
    background: rgba(255,255,255,0.04);
}
.nav-doc.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    border-left-color: var(--color-accent-teal);
    font-weight: 500;
}
.nav-doc .material-icons-outlined { font-size: 15px; opacity: 0.6; }

/* Deeper nesting indentation */
.nav-doc.depth-2 { padding-left: 52px; }
.nav-doc.depth-3 { padding-left: 64px; }
.nav-folder-header.depth-2 { padding-left: 40px; }
.nav-folder-header.depth-3 { padding-left: 52px; }

/* --- Sidebar Footer --- */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-divider);
    padding: 8px 12px 12px;
    flex-shrink: 0;
}

.changelog-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--sidebar-text);
    transition: all var(--transition-fast);
}
.changelog-link:hover {
    background: rgba(255,255,255,0.06);
    color: var(--color-text-inverse);
}
.changelog-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
}
.changelog-link .material-icons-outlined { font-size: 18px; }

.sidebar-copyright {
    padding: 10px 12px 4px;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.25);
    text-align: center;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Breadcrumb --- */
.breadcrumb-bar {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0 32px;
    z-index: 100;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 0;
    max-width: var(--content-max-width);
    font-size: 0.82rem;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.breadcrumb a {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
    white-space: nowrap;
}
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb a .material-icons-outlined { font-size: 17px; }

.breadcrumb-sep {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    user-select: none;
    margin: 0 2px;
}
.breadcrumb-sep .material-icons-outlined { font-size: 14px; }

.breadcrumb-current {
    color: var(--color-text);
    font-weight: 500;
    white-space: nowrap;
}

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding: 32px;
    width: 100%;
}

.content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* =============================================================================
   Tiptap Content Styling (new format — content_html from editor)

   The content_html field contains ready-to-render HTML with inline styles
   for tables, colors, widths, etc. This CSS provides base typography that
   matches the editor's appearance.
   ============================================================================= */

.tiptap {
    font-family: 'Heebo', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #2c3e50;
    direction: ltr;
    max-width: 100%;
    padding: 20px 28px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.tiptap h1 { font-size: 1.8em; font-weight: 700; color: #2c3e50; border-bottom: 2px solid #667eea; padding-bottom: 0.3em; margin-top: 1.2em; margin-bottom: 0.6em; }
.tiptap h2 { font-size: 1.5em; font-weight: 700; color: #2c3e50; border-bottom: 1px solid #e8ecf1; padding-bottom: 0.2em; margin-top: 1.2em; margin-bottom: 0.5em; }
.tiptap h3 { font-size: 1.25em; font-weight: 700; color: #2c3e50; margin-top: 1em; margin-bottom: 0.4em; }
.tiptap h4 { font-size: 1.1em; font-weight: 700; color: #2c3e50; margin-top: 0.8em; margin-bottom: 0.3em; }
.tiptap p:empty,
.tiptap p br:only-child {
    display: block;
    min-height: 1em;
}
.tiptap p { margin-bottom: 0.8em; }
.tiptap a { color: #667eea; text-decoration: underline; }
.tiptap blockquote { border-left: 4px solid #667eea; padding: 12px 20px; margin: 16px 0; background: #f8f9ff; border-radius: 8px 0 0 8px; color: #555; }
.tiptap pre { background: #1e1e2e; color: #cdd6f4; padding: 16px 20px; border-radius: 8px; font-size: 13px; direction: ltr; text-align: left; overflow-x: auto; font-family: 'Fira Code', 'Consolas', monospace; margin: 16px 0; }
.tiptap pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.tiptap code { background: #f0f2ff; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; color: #e74c3c; direction: ltr; font-family: 'Fira Code', 'Consolas', monospace; }
.tiptap ul, .tiptap ol { padding-left: 24px; margin-bottom: 0.8em; }
.tiptap li { margin-bottom: 0.3em; list-style: revert; }
.tiptap hr { border: none; border-top: 2px solid #e8ecf1; margin: 24px 0; }
.tiptap img { max-width: 100%; height: auto; border-radius: 8px; }
.tiptap table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.tiptap table td, .tiptap table th { border: 1px solid #dee2e6; padding: 8px 12px; text-align: left; vertical-align: top; }
.tiptap table th { background: #f8f9fa; font-weight: 600; }
.tiptap mark { padding: 2px 4px; border-radius: 2px; }
.tiptap figure { margin: 1em 0; }
.tiptap s { text-decoration: line-through; opacity: 0.7; }

/* Callout blocks */
.tiptap div[data-callout] { border-radius: 8px; padding: 14px 18px; margin: 16px 0; display: flex; gap: 12px; align-items: flex-start; }
.tiptap div[data-callout][data-type="info"] { background: #e8f4fd; border-left: 4px solid #3498db; }
.tiptap div[data-callout][data-type="warning"] { background: #fef9e7; border-left: 4px solid #f39c12; }
.tiptap div[data-callout][data-type="danger"] { background: #fdedec; border-left: 4px solid #e74c3c; }
.tiptap div[data-callout][data-type="tip"] { background: #eafaf1; border-left: 4px solid #27ae60; }

/* Callout blocks (class-based, for JSON-rendered content) */
.tiptap .callout { border-radius: 8px; padding: 14px 18px; margin: 16px 0; display: flex; gap: 12px; }
.tiptap .callout > div { flex: 1; min-width: 0; }
.tiptap .callout p { margin: 0 0 8px; }
.tiptap .callout p:last-child { margin-bottom: 0; }
.tiptap .callout-info    { background: #e8f4fd; border-left: 4px solid #3498db; }
.tiptap .callout-tip     { background: #eafaf1; border-left: 4px solid #27ae60; }
.tiptap .callout-warning { background: #fef9e7; border-left: 4px solid #f39c12; }
.tiptap .callout-danger  { background: #fdedec; border-left: 4px solid #e74c3c; }

/* =============================================================================
   Document HTML Content Styling (legacy — JSON-rendered pages)

   IMPORTANT: Firestore delivers raw HTML (often with inline styles) that must
   render exactly as authored.  Our approach:
     1. Restore browser-default margins / padding / list-styles / borders that
        the global reset (*, *::before, *::after) removed.
     2. Apply our branded "pretty" styles ONLY to elements that do NOT carry
        an inline `style` attribute  →  :not([style]).
     3. Elements WITH an inline style attribute are left completely alone so
        the Firestore HTML renders pixel-perfect.
   ============================================================================= */

/* --- Container defaults --- */
.doc-html-content {
    line-height: 1.75;
    color: var(--color-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ---------------------------------------------------------------------------
   1.  RESTORE BROWSER DEFAULTS inside .doc-html-content
       (counteract the global  *{margin:0;padding:0}  reset)
   --------------------------------------------------------------------------- */
.doc-html-content h1 { display: block; font-size: 2em;    font-weight: bold; margin: 0.67em 0; }
.doc-html-content h2 { display: block; font-size: 1.5em;  font-weight: bold; margin: 0.83em 0; }
.doc-html-content h3 { display: block; font-size: 1.17em; font-weight: bold; margin: 1em 0;    }
.doc-html-content h4 { display: block; font-size: 1em;    font-weight: bold; margin: 1.33em 0; }
.doc-html-content h5 { display: block; font-size: 0.83em; font-weight: bold; margin: 1.67em 0; }
.doc-html-content h6 { display: block; font-size: 0.67em; font-weight: bold; margin: 2.33em 0; }
.doc-html-content p  { display: block; margin: 1em 0; }
.doc-html-content ul { display: block; list-style-type: disc;    margin: 1em 0; padding-left: 40px; }
.doc-html-content ol { display: block; list-style-type: decimal; margin: 1em 0; padding-left: 40px; }
.doc-html-content li { display: list-item; }
.doc-html-content blockquote { display: block; margin: 1em 40px; }
.doc-html-content pre { display: block; font-family: monospace; white-space: pre; margin: 1em 0; }
.doc-html-content code, .doc-html-content kbd, .doc-html-content samp { font-family: monospace; }
.doc-html-content hr  { display: block; margin: 0.5em 0; border-style: inset; border-width: 1px; }
.doc-html-content a   { color: LinkText; text-decoration: underline; cursor: pointer; }
.doc-html-content table { display: table; border-collapse: separate; border-spacing: 2px; }
.doc-html-content thead { display: table-header-group; vertical-align: middle; }
.doc-html-content tbody { display: table-row-group;    vertical-align: middle; }
.doc-html-content tfoot { display: table-footer-group;  vertical-align: middle; }
.doc-html-content tr    { display: table-row;           vertical-align: inherit; }
.doc-html-content th    { display: table-cell; vertical-align: inherit; font-weight: bold; text-align: center; padding: 1px; }
.doc-html-content td    { display: table-cell; vertical-align: inherit; padding: 1px; }
.doc-html-content img   { /* allow natural sizing; :not([style]) block below adds constraints */ }
.doc-html-content sub   { vertical-align: sub;   font-size: smaller; }
.doc-html-content sup   { vertical-align: super; font-size: smaller; }
.doc-html-content b, .doc-html-content strong { font-weight: bold; }
.doc-html-content i, .doc-html-content em     { font-style: italic; }

/* ---------------------------------------------------------------------------
   2.  BRANDED / PRETTY STYLES — only for elements WITHOUT inline styles
   --------------------------------------------------------------------------- */

/* Headings */
.doc-html-content h1:not([style]) {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-primary-dark);
    letter-spacing: -0.02em;
}

.doc-html-content h2:not([style]) {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 32px 0 12px;
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

.doc-html-content h3:not([style]) {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 24px 0 8px;
    color: var(--color-text);
}

.doc-html-content h4:not([style]),
.doc-html-content h5:not([style]),
.doc-html-content h6:not([style]) {
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 8px;
}

/* Paragraphs */
.doc-html-content p:not([style]) {
    margin: 0 0 16px;
}

/* Links */
.doc-html-content a:not([style]) {
    color: var(--color-accent-blue);
    text-decoration: underline;
    text-decoration-color: rgba(91,155,213,0.3);
    text-underline-offset: 2px;
    transition: all var(--transition-fast);
}
.doc-html-content a:not([style]):hover {
    color: var(--color-primary);
    text-decoration-color: var(--color-primary);
}

/* Lists */
.doc-html-content ul:not([style]),
.doc-html-content ol:not([style]) {
    margin: 0 0 16px;
    padding-left: 24px;
}
.doc-html-content li:not([style]) { margin-bottom: 4px; }

/* Inline code */
.doc-html-content code:not([style]) {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: #F1F5F9;
    color: var(--color-accent-red);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

/* Code blocks */
.doc-html-content pre:not([style]) {
    background: #1E293B;
    color: #E2E8F0;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 0 0 20px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    border: 1px solid #334155;
}

.doc-html-content pre:not([style]) code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* Prism.js overrides — ensure code blocks match site theme */
.doc-html-content pre[class*="language-"] {
    background: #1E293B;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    margin: 0 0 20px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    border: 1px solid #334155;
}
.doc-html-content pre[class*="language-"] code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* Blockquote */
.doc-html-content blockquote:not([style]) {
    margin: 0 0 16px;
    padding: 12px 20px;
    border-left: 4px solid var(--color-accent-teal);
    background: #F0FDFA;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--color-text-secondary);
}

/* Horizontal rule */
.doc-html-content hr:not([style]) {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 24px 0;
}

/* --- Tables --- */
.doc-html-content table:not([style]) {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 20px;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.doc-html-content table:not([style]) thead th,
.doc-html-content table:not([style]) th:not([style]) {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.doc-html-content table:not([style]) td:not([style]) {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}

.doc-html-content table:not([style]) tbody tr:hover {
    background: var(--color-surface-hover);
}

.doc-html-content table:not([style]) tbody tr:last-child td:not([style]) {
    border-bottom: none;
}

/* --- Images --- */
/* Images WITH inline styles: undo the global max-width constraint */
.doc-html-content img[style] {
    max-width: none;
}
/* Images WITHOUT inline styles: apply branded look + keep safe sizing */
.doc-html-content img:not([style]) {
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin: 8px 0;
}

/* --- Figures (Tiptap image wrapper) --- */
.doc-html-content figure {
    margin: 1em 0;
}

/* --- Callouts (Tiptap custom extension) --- */
.doc-html-content .callout {
    border-radius: 8px;
    padding: 14px 18px;
    margin: 16px 0;
    display: flex;
    gap: 12px;
    line-height: 1.6;
}
.doc-html-content .callout > div { flex: 1; min-width: 0; }
.doc-html-content .callout p { margin: 0 0 8px; }
.doc-html-content .callout p:last-child { margin-bottom: 0; }
.doc-html-content .callout-info    { background: #e8f4fd; border-left: 4px solid #3498db; }
.doc-html-content .callout-tip     { background: #eafaf1; border-left: 4px solid #27ae60; }
.doc-html-content .callout-warning { background: #fef9e7; border-left: 4px solid #f39c12; }
.doc-html-content .callout-danger  { background: #fdedec; border-left: 4px solid #e74c3c; }

/* --- Highlighted text (Tiptap mark) --- */
.doc-html-content mark {
    padding: 2px 4px;
    border-radius: 2px;
}

/* --- Strikethrough --- */
.doc-html-content s {
    text-decoration: line-through;
    opacity: 0.7;
}

/* --- Front Page Specific --- */
.front-page {
    text-align: center;
    padding: 60px 24px;
}

.front-page-logo {
    width: 72px;
    height: 72px;
    max-width: 72px;
    max-height: 72px;
    margin: 0 auto 16px;
    display: block;
    object-fit: contain;
}

.front-page-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.front-page-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-bottom: 40px;
}

.front-page-content {
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
}

/* --- Changelog --- */
.changelog-page .doc-html-content {
    max-width: 800px;
}

/* --- Page Footer --- */
.page-footer {
    padding: 16px 32px 24px;
    max-width: var(--content-max-width);
}

.page-updated {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    background: var(--color-surface-hover);
    padding: 6px 14px;
    border-radius: 20px;
}
.page-updated .material-icons-outlined { font-size: 15px; }

/* --- Loading Spinner --- */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(126,206,194,0.2);
    border-top-color: var(--color-accent-teal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.loading-spinner.large { width: 36px; height: 36px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Scrollbar (global) --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--header-height);
    }

    .breadcrumb-bar {
        top: var(--header-height);
        padding: 0 16px;
    }

    .page-content {
        padding: 24px 16px;
    }

    .page-footer {
        padding: 16px;
    }

    .front-page {
        padding: 24px 16px;
    }

    .front-page-logo {
        width: 40px !important;
        height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        margin-bottom: 8px !important;
    }

    .front-page-title {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    .front-page-subtitle {
        font-size: 0.9rem;
        margin-bottom: 24px;
    }

    .doc-html-content h1:not([style]) { font-size: 1.6rem; }
    .doc-html-content h2:not([style]) { font-size: 1.3rem; }

    .doc-html-content table:not([style]) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .tiptap { padding: 16px; font-size: 14px; }
    .tiptap h1 { font-size: 1.5em; }
    .tiptap h2 { font-size: 1.3em; }
    .tiptap table { display: block; overflow-x: auto; }
}

@media (max-width: 480px) {
    .front-page-title { font-size: 1.25rem; }
    .front-page-logo { width: 36px !important; height: 36px !important; max-width: 36px !important; max-height: 36px !important; }
}
