/* FAQ View Page Styles - Responsive Container System */
:root {
    --container-width: 1200px;
    --content-width-factor: 0.75;
    --banner-width-factor: 0.95;
    --spacing-unit: 1rem;
    --toc-width: 250px;
    --toc-offset: 100px;

    /* FAQ View Color System */
    --faq-primary-color: #5AC0EF;
    --faq-primary-hover: #4a9fd1;
    --faq-search-bg: #f8f9fa;
    --faq-border-color: #dee2e6;
    --faq-search-shadow: rgba(90, 192, 239, 0.25);
    --faq-card-shadow: rgba(0, 0, 0, 0.075);

    /* Dynamic FAQ Configuration (set via JavaScript from kbfaq_details) */
    --faq-font-family: 'Inter', sans-serif;
    /* Default fallback */
    --faq-background-color: #ffffff;
    /* Default fallback */
}

.faq-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 2) var(--spacing-unit);
    position: relative;
}

.faq-content-wrapper {
    max-width: calc(var(--container-width) * var(--banner-width-factor));
    margin: 0 auto;
}

/* Table of Contents Sidebar */
.faq-toc-sidebar {
    position: fixed;
    left: calc(50% - (var(--container-width) * var(--content-width-factor) / 2) - var(--toc-width) - 50px);
    top: 330px;
    /* Position below banner - increased by 50px to avoid overlap */
    width: var(--toc-width);
    background-color: transparent;
    padding: 0;
    z-index: 100;
    max-height: calc(100vh - 350px);
    /* Adjusted to match new top position */
    overflow-y: auto;
}

.faq-toc-sidebar .toc-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #000000;
    margin-bottom: 1rem;
    padding-bottom: 0;
    border-bottom: none;
}

/* TOC Pro AI Badge Styling */
.toc-proai-badge-container {
    text-align: center;
}

.toc-proai-badge-container .badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(90, 192, 239, 0.2);
}

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

.toc-nav li {
    margin-bottom: 0.5rem;
}

.toc-nav a {
    display: block;
    padding: 0.25rem 0;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.85rem;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    padding-left: 0.75rem;
}

.toc-nav a:hover {
    color: #5AC0EF;
}

.toc-nav a.active {
    color: #5AC0EF !important;
    border-left-color: #5AC0EF;
    font-weight: 500;
}

/* Nested subheadings (H1, H2 from markdown) */
.toc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
}

.toc-nav ul li {
    margin-bottom: 0.25rem;
}

.toc-nav ul a {
    font-size: 0.8rem;
    padding-left: 1.5rem;
    color: #b3b3b3;
}

.toc-nav ul a:hover {
    color: #5AC0EF;
}

.toc-nav ul a.active {
    color: #5AC0EF;
    border-left-color: #5AC0EF;
}

.faq-header {
    background: none;
    color: black;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
    text-align: center;
}

/* Banner responsive sizing variables - Help Scout inspired */
.faq-header {
    max-width: calc(var(--container-width) * var(--banner-width-factor));
    margin: 0 auto;
}

.faq-banner-container {
    position: relative;
    display: inline-block;
    width: min(90vw, calc(var(--container-width) * var(--banner-width-factor)));
    margin-bottom: var(--spacing-unit);
}

.faq-banner {
    width: 100%;
    max-height: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    opacity: 0.5;
}

.faq-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    text-transform: uppercase;
    color: black;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    z-index: 2;
}

.faq-logo {
    max-height: 60px;
    margin-top: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Content sections with optimal reading width */
.search-section,
.questions-section {
    max-width: calc(var(--container-width) * var(--content-width-factor));
    margin-left: auto;
    margin-right: auto;
}

/* Search button styling */
.search-section .btn-primary {
    background-color: #000000;
    border-color: #000000;
}

.search-section .btn-primary:hover {
    background-color: #333333;
    border-color: #333333;
}

/* Mobile responsive - Help Scout inspired breakpoints */
@media (max-width: 768px) {
    :root {
        --container-width: 100%;
        --content-width-factor: 0.95;
        --banner-width-factor: 1.0;
        --spacing-unit: 0.75rem;
    }

    .faq-container {
        padding: calc(var(--spacing-unit) * 1.5) var(--spacing-unit);
    }

    .faq-content-wrapper {
        margin: 0 auto;
        max-width: 100%;
    }

    .faq-toc-sidebar {
        display: none;
        /* Hide TOC on mobile */
    }

    .faq-banner-container {
        width: min(95vw, 100%);
    }

    .faq-title {
        font-size: 1.8rem;
    }
}

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1023px) {
    :root {
        --container-width: 1000px;
        --content-width-factor: 0.8;
        --banner-width-factor: 0.9;
    }

    .faq-toc-sidebar {
        left: calc(50% - (var(--container-width) * var(--content-width-factor) / 2) - 200px - 30px);
        width: 200px;
    }
}

/* Large desktop responsive */
@media (min-width: 1400px) {
    :root {
        --container-width: 1400px;
        --content-width-factor: 0.7;
        --banner-width-factor: 0.85;
    }

    .faq-banner {
        height: 240px;
        max-height: 240px;
        border-radius: 16px;
    }

    .faq-toc-sidebar {
        top: 370px;
        /* Increased to account for taller banner (240px + padding) */
        max-height: calc(100vh - 390px);
    }
}

.faq-overview {
    font-size: 1.1rem;
    opacity: 0.95;
    margin: 1rem 0 0 0;
}

.overview-container {
    margin-top: 1rem;
}

.overview-container .faq-overview {
    margin: 0;
    flex-grow: 1;
}

.overview-container .badge {
    flex-shrink: 0;
}

/* Mobile responsive for overview container */
@media (max-width: 768px) {
    .overview-container {
        justify-content: center !important;
        flex-direction: column;
    }

    .overview-container .badge {
        margin-right: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    .overview-container .faq-overview {
        text-align: center;
    }
}

.questions-section h5 {
    color: #000000;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.qa-item {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.qa-item:hover {
    transform: translateY(-2px);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1.25rem;
}

.card-header h6 {
    color: #2c3e50;
    font-weight: 600;
}

.btn-link {
    color: #5AC0EF;
    text-decoration: none;
}

.btn-link:hover {
    color: #4A9FD1;
}

/* Chevron toggle styling */
.toggle-button .chevron-icon {
    transition: transform 0.2s ease;
    font-size: 1rem;
}

.toggle-button:focus {
    box-shadow: none;
}

/* Link copy button styling */
.link-copy-button {
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.link-copy-button:hover {
    opacity: 1;
    transform: scale(1.1);
}

.link-copy-button:focus {
    box-shadow: none;
    outline: none;
}

.link-copy-button .link-icon {
    width: 20px;
    height: 20px;
    display: block;
    transition: filter 0.2s ease;
}

.link-copy-button:hover .link-icon {
    filter: brightness(0) saturate(100%) invert(48%) sepia(79%) saturate(2476%) hue-rotate(166deg) brightness(98%) contrast(119%);
}

/* Show link icon on card hover for better discoverability */
.qa-item .card-header:hover .link-copy-button {
    opacity: 1;
}

.answer-content {
    background-color: white;
    padding: 1rem;
    border-radius: 0px;
    border-left: none;
}

/* Override any blockquote styling that might be inherited */
.markdown-content {
    color: #405261 !important;
    background-color: transparent !important;
    border-left: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* GitHub-style Markdown Styling */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: #000000 !important;
    background-color: transparent !important;
    border-left: none !important;
    padding-left: 0 !important;
}

.markdown-content h1 {
    font-size: 2rem;
    border-bottom: 1px solid #d1d9e0;
    padding-bottom: 0.5rem;
    color: #000000 !important;
}

.markdown-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #d1d9e0;
    padding-bottom: 0.5rem;
    color: #000000 !important;
}

.markdown-content h3 {
    font-size: 1.25rem;
    color: #000000 !important;
}

.markdown-content h4 {
    font-size: 1rem;
    color: #000000 !important;
}

.markdown-content h5 {
    font-size: 0.875rem;
    color: #000000 !important;
}

.markdown-content h6 {
    font-size: 0.85rem;
    color: #000000 !important;
}

/* Text styling */
.markdown-content strong {
    font-weight: 600;
    color: #405261;
}

.markdown-content em {
    font-style: italic;
    color: #405261;
}

.markdown-content del {
    text-decoration: line-through;
    color: #405261;
}

.markdown-content u {
    text-decoration: underline;
    color: #405261;
}

.markdown-content sup {
    vertical-align: super;
    font-size: smaller;
    color: #405261;
}

.markdown-content sub {
    vertical-align: sub;
    font-size: smaller;
    color: #405261;
}

/* Paragraphs */
.markdown-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #405261 !important;
}

/* Ensure first paragraph is never treated as blockquote */
.markdown-content p:first-child {
    color: #405261 !important;
    background-color: transparent !important;
    border-left: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Links */
.markdown-content a {
    color: #0969da;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Code styling */
.markdown-content code,
.markdown-content .inline-code {
    background-color: #f6f8fa;
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.875em;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color: #1f2328 !important;
    border: 1px solid #d1d9e0;
    font-weight: normal;
    font-style: normal;
}

.markdown-content .code-block {
    margin: 1rem 0;
    background-color: #f6f8fa;
    border-radius: 6px;
    overflow: auto;
}

.markdown-content .code-pre {
    margin: 0;
    padding: 1rem;
    background-color: transparent;
    border: none;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.875em;
    line-height: 1.45;
    color: #1f2328;
}

/* Ensure code inside code blocks doesn't get inline code styling */
.markdown-content .code-block code,
.markdown-content .code-pre code {
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: inherit !important;
}

/* Blockquotes */
.markdown-content blockquote,
.markdown-content .markdown-blockquote {
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 50px;
    padding-left: 15px;
    border-left: 5px solid #4c4c4c;
    display: inline-flex;
    color: #656d76;
}

.markdown-content blockquote span,
.markdown-content .markdown-blockquote span {
    margin-top: -10px;
    margin-bottom: -10px;
}

.markdown-content .markdown-blockquote p {
    margin-bottom: 0;
}

/* Ensure headings are never styled as blockquotes */
.markdown-content blockquote h1,
.markdown-content blockquote h2,
.markdown-content blockquote h3,
.markdown-content blockquote h4,
.markdown-content blockquote h5,
.markdown-content blockquote h6 {
    color: #000000 !important;
    background-color: transparent !important;
    border-left: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Lists */
.markdown-content ul,
.markdown-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.markdown-content li {
    margin: 0.25rem 0;
}

.markdown-content ul ul,
.markdown-content ul ol,
.markdown-content ol ul,
.markdown-content ol ol {
    margin: 0;
}

/* Task lists */
.markdown-content .task-item {
    list-style: none;
    margin-left: -2rem;
    padding-left: 2rem;
}

.markdown-content .task-item input[type="checkbox"] {
    margin-right: 0.5rem;
    vertical-align: middle;
}

.markdown-content .task-item.checked {
    text-decoration: line-through;
    color: #656d76;
}

/* GitHub Alerts */
.markdown-content .github-alert {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border-left: 4px solid;
}

.markdown-content .github-alert .alert-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.markdown-content .github-alert .alert-header i {
    margin-right: 0.5rem;
    font-size: 1rem;
}

.markdown-content .github-alert .alert-header strong {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
}

.markdown-content .github-alert .alert-content {
    margin-top: 0.5rem;
}

.markdown-content .github-alert .alert-content p:last-child {
    margin-bottom: 0;
}

/* Alert type specific styling */
.markdown-content .alert-note {
    background-color: #ddf4ff;
    border-left-color: #0969da;
}

.markdown-content .alert-note .alert-header {
    color: #0969da;
}

.markdown-content .alert-tip {
    background-color: #dcfce7;
    border-left-color: #16a34a;
}

.markdown-content .alert-tip .alert-header {
    color: #16a34a;
}

.markdown-content .alert-important {
    background-color: #fef3cd;
    border-left-color: #f59e0b;
}

.markdown-content .alert-important .alert-header {
    color: #f59e0b;
}

.markdown-content .alert-warning {
    background-color: #fff3cd;
    border-left-color: #f97316;
}

.markdown-content .alert-warning .alert-header {
    color: #f97316;
}

.markdown-content .alert-caution {
    background-color: #fee2e2;
    border-left-color: #dc2626;
}

.markdown-content .alert-caution .alert-header {
    color: #dc2626;
}

/* Images */
.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.5rem 0;
}

/* Tables */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    overflow: hidden;
}

.markdown-content th,
.markdown-content td {
    padding: 0.75rem;
    border-bottom: 1px solid #d1d9e0;
    text-align: left;
}

.markdown-content th {
    background-color: #f6f8fa;
    font-weight: 600;
    border-bottom: 2px solid #d1d9e0;
}

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

/* Footnotes */
.markdown-content .footnote-ref {
    color: #0969da;
    text-decoration: none;
    font-size: 0.875em;
    vertical-align: super;
}

.markdown-content .footnotes {
    margin-top: 2rem;
    border-top: 1px solid #d1d9e0;
    padding-top: 1rem;
    font-size: 0.875rem;
    color: #656d76;
}

/* Horizontal rule */
.markdown-content hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #d1d9e0;
}

/* Escaped characters - ensure proper rendering */
.markdown-content .escaped-char {
    color: inherit;
    font-weight: normal;
    font-style: normal;
}

/* YouTube Embed Styling */
.markdown-content .youtube-embed-container {
    margin: 1.5rem 0;
    text-align: center;
}

.markdown-content .youtube-embed-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 560px;
    height: 0;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.markdown-content .youtube-embed-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none;
    border-radius: 8px;
}

/* Mobile responsive YouTube embeds */
@media (max-width: 768px) {
    .markdown-content .youtube-embed-wrapper {
        max-width: 100%;
        margin: 0 auto;
    }
}

.footer {
    text-align: center;
    padding: 0;
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.powered-by {
    background-color: white;
    height: 35px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 2rem auto 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile footer layout - stack on two lines for screens below 500px */
@media (max-width: 500px) {
    .powered-by {
        height: auto !important;
        padding: 0.5rem !important;
    }

    .footer {
        flex-direction: column !important;
        gap: 0.25rem !important;
        line-height: 1.4 !important;
        align-items: center !important;
        text-align: center !important;
    }

    .footer span,
    .footer a,
    .footer img {
        display: inline !important;
    }
}

/* FAQ View Dynamic Body Styles */
.faq-view-body {
    font-family: var(--faq-font-family);
    background-color: var(--faq-background-color);
    line-height: 1.6;
}

/* Search Functionality Styles */
.faq-search-highlight {
    background-color: var(--faq-primary-color);
    color: white;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
}

.faq-search-result-item:hover {
    background-color: var(--faq-search-bg);
    border-color: var(--faq-primary-color) !important;
}

.faq-search-results .card {
    border: 1px solid var(--faq-border-color);
    box-shadow: 0 0.125rem 0.25rem var(--faq-card-shadow);
}

.faq-search-results .card-header {
    background-color: var(--faq-search-bg);
    border-bottom: 1px solid var(--faq-border-color);
}

#faq-search:focus {
    border-color: var(--faq-primary-color);
    box-shadow: 0 0 0 0.2rem var(--faq-search-shadow);
}

#search-button:hover {
    background-color: var(--faq-primary-hover);
    border-color: var(--faq-primary-hover);
}

/* ========================================= */
/* PREVIEW MODE STYLES                       */
/* ========================================= */

/* Preview banner styles */
.preview-banner {
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 0 !important;
    margin-bottom: 0 !important;
}

/* Question status indicators for preview mode */
.preview-status-indicator {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.question-status-draft {
    background-color: #000000;
    color: #000;
    border: 1px solid #000000;
}

.question-status-review {
    background-color: #EC5852;
    color: #fff;
    border: 1px solid #EC5852;
}

.question-status-archived {
    background-color: #F3B281;
    color: #fff;
    border: 1px solid #F3B281;
    ;
}

/* Preview mode adjustments for layout */
.preview-banner+.faq-container {
    padding-top: calc(var(--spacing-unit) * 1.5);
}

/* Enhanced status styling for preview mode */
.qa-item[data-question-status="draft"] .card-header {
    border-left: 4px solid #000000;
}

.qa-item[data-question-status="review"] .card-header {
    border-left: 4px solid #EC5852;
}

.qa-item[data-question-status="archived"] .card-header {
    border-left: 4px solid #F3B281;
}

.qa-item[data-question-status="publish"] .card-header {
    border-left: 4px solid #5ac0ef;
}

/* Preview mode role indicator styles */
.preview-role-indicator {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-owner {
    background-color: #5ac0ef;
    color: white;
}

.role-contributor {
    background-color: #1a9988ff;
    color: white;
}

.role-read-only {
    background-color: #000000;
    color: white;
}

/* Preview mode table of contents adjustment */
.preview-banner~.faq-container .faq-toc-sidebar {
    top: calc(330px + 60px);
    /* Account for preview banner height */
    max-height: calc(100vh - 410px);
}

/* Preview mode empty state styling */
.preview-empty-state {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    margin: 2rem 0;
}

.preview-empty-state .preview-icon {
    font-size: 4rem;
    color: #adb5bd;
    margin-bottom: 1rem;
}

.preview-empty-state h4 {
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.preview-empty-state p {
    color: #adb5bd;
    margin-bottom: 0;
}

/* Preview mode responsive adjustments */
@media (max-width: 1400px) {
    .preview-banner~.faq-container .faq-toc-sidebar {
        display: none;
        /* Hide TOC on smaller screens to prevent overlap with preview banner */
    }
}

@media (max-width: 768px) {
    .preview-banner {
        position: relative;
        /* Make banner relative on mobile to prevent sticky overlap issues */
    }

    .preview-banner .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .preview-banner .ms-auto {
        margin-left: 0 !important;
        margin-top: 0.25rem;
    }

    .preview-status-indicator {
        margin-left: 0;
        margin-top: 0.25rem;
        display: block;
    }
}

/* Preview mode animation enhancements */
.preview-banner {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.qa-item[data-question-status]:hover .card-header {
    transform: translateX(2px);
    transition: transform 0.2s ease;
}

/* Preview mode focus enhancements */
.preview-banner:focus-within {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.qa-item[data-question-status] .card-header:focus-within {
    box-shadow: 0 0 0 2px rgba(90, 192, 239, 0.25);
}

/* Preview mode print styles */
@media print {
    .preview-banner {
        position: static !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
    }

    .preview-status-indicator {
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
    }

    .faq-toc-sidebar {
        display: none !important;
    }
}