/* Knowledge Base Markdown Styling */
.markdown-body {
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.73); /* Золотая середина: не слишком ярко, не слишком тускло */
    max-width: 850px;
    margin: 0 auto;
    padding: 0 1rem;
}

.markdown-body strong, .markdown-body b {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: #c9b082; /* Более приглушенный и теплый золотой оттенок для заголовков */
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    scroll-margin-top: 120px;
}

.markdown-body h1 {
    font-size: 2.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

.markdown-body h2 {
    font-size: 1.8rem;
    border-bottom: 1px dashed rgba(201, 169, 78, 0.3);
    padding-bottom: 0.3rem;
}

.markdown-body h3 {
    font-size: 1.4rem;
}

.markdown-body h4 {
    font-size: 1.25rem;
}

.markdown-body h5 {
    font-size: 1.15rem;
}

.markdown-body h6 {
    font-size: 1.1rem;
}

.markdown-body p {
    margin-bottom: 1.5rem;
}

.markdown-body ul, 
.markdown-body ol {
    margin-bottom: 1.8rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body li > p {
    margin-bottom: 0.5rem;
}

.markdown-body img {
    max-width: 500px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem auto 2rem auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-body img.full-width,
.markdown-body img[src$=".svg"] {
    max-width: 100%;
}

.markdown-body em {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Premium Blockquote Styling */
.markdown-body blockquote {
    position: relative;
    margin: 2rem 0;
    padding: 2rem 2rem 1.5rem 3.5rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: none; /* Removed the default gold border for the new design */
}

.markdown-body blockquote .quote-icon {
    position: absolute;
    top: 1.5rem;
    left: 1.2rem;
    width: 24px;
    height: 24px;
    color: rgba(255, 255, 255, 0.2);
}

.markdown-body blockquote .quote-text {
    font-size: 1.1rem;
    font-style: italic;
    font-weight: 400;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.85);
}

.markdown-body blockquote .quote-author {
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
    font-style: normal;
}

.markdown-body blockquote .quote-copy {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    padding: 0.2rem;
}

.markdown-body blockquote .quote-copy:hover {
    opacity: 1;
    color: var(--accent);
}

.markdown-body a, .markdown-body button.share-copy {
    color: inherit;
    text-decoration: none;
    border: none;
    background: transparent;
    border-bottom: 1px solid rgba(212, 175, 55, 0.4);
    transition: all 0.2s ease;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding-bottom: 6px;
    vertical-align: middle;
}

.markdown-body a:hover, .markdown-body button.share-copy:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* TOC Active Item Dot styling */
.toc-item--active::before {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
}

/* Premium Table Styling */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2.5rem 0;
    background: rgba(14, 18, 30, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(200, 169, 126, 0.1);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.markdown-body table th {
    background: rgba(200, 169, 126, 0.08);
    color: var(--accent, #c8a97e);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.15rem;
    text-align: left;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(200, 169, 126, 0.2);
    letter-spacing: 0.03em;
}

.markdown-body table td {
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(200, 169, 126, 0.05);
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.markdown-body table tr:last-child td {
    border-bottom: none;
}

.markdown-body table tr {
    transition: background-color 0.2s ease;
}

.markdown-body table tbody tr:hover {
    background: rgba(200, 169, 126, 0.04);
}

.markdown-body table tbody tr:hover td {
    color: rgba(255, 255, 255, 0.95);
}

/* ═══════════════════════════════════════════════════
   Glossary Tooltip — Inline Term Highlighting
   ═══════════════════════════════════════════════════ */
.kb-term {
    border-bottom: 1px dotted rgba(200, 169, 126, 0.45);
    cursor: help;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.kb-term:hover {
    border-bottom-color: rgba(200, 169, 126, 0.9);
    color: rgba(255, 255, 255, 0.95);
}

/* ═══════════════════════════════════════════════════
   Glossary Tooltip — Floating Popup
   ═══════════════════════════════════════════════════ */
#kb-glossary-tooltip {
    position: fixed;
    max-width: 340px;
    min-width: 200px;
    padding: 0.85rem 1rem 0.75rem;
    background: rgba(18, 18, 32, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(200, 169, 126, 0.25);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    line-height: 1.55;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45),
                0 0 0 1px rgba(200, 169, 126, 0.08) inset;
}

#kb-glossary-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#kb-glossary-tooltip .kb-tip-term {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-weight: 600;
    color: #c9b082;
    margin-bottom: 0.35rem;
}

#kb-glossary-tooltip .kb-tip-def {
    display: block;
    margin-bottom: 0.5rem;
}

#kb-glossary-tooltip .kb-tip-link {
    display: inline-block;
    font-size: 0.78rem;
    color: rgba(200, 169, 126, 0.8);
    border-bottom: 1px solid rgba(200, 169, 126, 0.3);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

#kb-glossary-tooltip .kb-tip-link:hover {
    color: #c9b082;
    border-bottom-color: #c9b082;
}

/* Mobile: make tooltip wider and ensure it doesn't overflow */
@media (max-width: 768px) {
    #kb-glossary-tooltip {
        max-width: calc(100vw - 2rem);
        font-size: 0.85rem;
    }
}

/* ═══════════════════════════════════════════════════
   Knowledge Base Layout
   ═══════════════════════════════════════════════════ */
.knowledge-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.knowledge-menu, .knowledge-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.knowledge-menu li {
    list-style: none;
}

.knowledge-sidebar {
    flex: 0 0 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

#kb-search-input {
    width: 100%;
    padding: 0.75rem 2rem 0.75rem 1rem;
    margin-bottom: 0;
    background: rgba(14, 18, 30, 0.6) !important;
    border: 1px solid rgba(200, 169, 126, 0.2) !important;
    border-radius: 8px !important;
    color: var(--text-primary) !important;
    font-size: 0.95rem;
    font-family: 'Nunito', sans-serif;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

#kb-search-input:focus {
    outline: none;
    border-color: rgba(200, 169, 126, 0.6);
    background: rgba(20, 25, 40, 0.8);
    box-shadow: 0 0 0 2px rgba(200, 169, 126, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

#kb-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}
#kb-search-input::-webkit-search-cancel-button,
#kb-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.knowledge-article {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 2rem 2rem 2rem;
    min-height: 60vh;
}

.knowledge-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* Mobile Adjustments for Layout */
@media (max-width: 768px) {
    .knowledge-layout {
        flex-direction: column;
    }

    .knowledge-sidebar {
        flex: none;
        width: 100%;
        max-height: 35vh; /* Takes up only part of the screen so article is visible below */
        position: static; /* Let it scroll normally with the page */
        border-radius: 8px;
    }

    .knowledge-article {
        padding: 1rem;
        width: 100%;
    }
}
