/* =============================================
   Knowledge Base Panel - Native Sidebar Component
   ============================================= */

.kb-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
}

/* Panel Header */
.kb-panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.kb-panel-header svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    flex-shrink: 0;
}

.kb-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 1;
}

.kb-header-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.kb-header-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.kb-header-link svg {
    width: 10px;
    height: 10px;
    stroke: currentColor;
}

/* Content Area */
.kb-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-3);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) transparent;
}

.kb-panel-content::-webkit-scrollbar {
    width: 6px;
}

.kb-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.kb-panel-content::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

.kb-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Empty / Loading States */
.kb-panel-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: var(--space-4);
    color: var(--text-muted);
}

.kb-panel-placeholder svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    margin-bottom: var(--space-3);
    opacity: 0.5;
}

.kb-panel-placeholder p {
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Loading Spinner */
.kb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.kb-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: kb-spin 0.8s linear infinite;
}

@keyframes kb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Article Content Styles */
.kb-article {
    animation: kb-fadeIn 0.25s ease-out;
}

@keyframes kb-fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Article Title */
.kb-article-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
    line-height: 1.3;
}

/* Sections */
.kb-section {
    margin-bottom: var(--space-4);
}

.kb-section:last-child {
    margin-bottom: 0;
}

.kb-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.kb-section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 10px;
    background: var(--accent);
    border-radius: 2px;
}

/* Paragraphs */
.kb-section p {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.kb-section p:last-child {
    margin-bottom: 0;
}

.kb-section strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Lists */
.kb-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kb-list li {
    position: relative;
    padding-left: var(--space-4);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.kb-list li:last-child {
    margin-bottom: 0;
}

.kb-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 5px;
    height: 5px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.7;
}

.kb-list li strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Tables */
.kb-table-container {
    overflow-x: auto;
    margin-bottom: var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.kb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.kb-table th,
.kb-table td {
    padding: var(--space-2);
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    line-height: 1.4;
}

.kb-table th {
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kb-table tr:last-child td {
    border-bottom: none;
}

.kb-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.kb-table td strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Collapsible Sections */
.kb-section.collapsible .kb-section-title {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.kb-section.collapsible .kb-section-title:hover {
    color: var(--text-primary);
}

.kb-section.collapsible .kb-section-title::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform var(--transition-fast);
}

.kb-section.collapsible.collapsed .kb-section-title::after {
    transform: rotate(-90deg);
}

.kb-section.collapsible .kb-section-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
}

.kb-section.collapsible.collapsed .kb-section-content {
    max-height: 0;
    opacity: 0;
}

/* Highlight/Tip Box */
.kb-tip {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding: var(--space-2) var(--space-3);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: var(--space-3) 0;
}

.kb-tip p {
    font-size: 0.75rem;
    margin: 0;
}

/* Open Full Article Link */
.kb-full-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    margin-top: var(--space-3);
    padding: var(--space-2);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-decoration: none;
    border-top: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.kb-full-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.kb-full-link svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}