/* ==========================================
   Knowledge Base Pro - Main Stylesheet
   ========================================== */

:root {
    --kb-primary: #0a2a6e;
    --kb-secondary: #061a4a;
    --kb-accent: #dce8ff;
    --kb-text: #0d1b3e;
    --kb-text-muted: #4a6080;
    --kb-bg: #f0f4fb;
    --kb-card-bg: #ffffff;
    --kb-border: #c8d8f0;
    --kb-radius: 12px;
    --kb-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --kb-shadow-hover: 0 10px 25px rgba(0,0,0,0.12);
    --kb-transition: 0.2s ease;
}

/* ---- Base ---- */
.kb-wrapper * {
    box-sizing: border-box;
}
.kb-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--kb-text);
    line-height: 1.6;
}

/* ---- Header ---- */
.kb-header {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
    background: linear-gradient(135deg, var(--kb-primary) 0%, var(--kb-secondary) 100%);
    border-radius: var(--kb-radius);
    margin-bottom: 2rem;
    color: white;
}
.kb-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    letter-spacing: -0.5px;
}

/* ---- Search ---- */
.kb-search-container {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    max-width: 700px;
    margin: 0 auto;
}
.kb-search-box {
    position: relative;
    flex: 1;
    min-width: 260px;
}
.kb-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    pointer-events: none;
}
.kb-search-input {
    width: 100%;
    padding: 0.85rem 2.8rem 0.85rem 3rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    font-size: 1rem;
    background: rgba(255,255,255,0.95);
    color: var(--kb-text);
    transition: all var(--kb-transition);
    outline: none;
}
.kb-search-input:focus {
    border-color: white;
    background: white;
    box-shadow: 0 0 0 4px rgba(255,255,255,0.2);
}
.kb-search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--kb-text-muted);
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 50%;
}
.kb-search-clear:hover { background: var(--kb-border); }

/* ---- Layout ---- */
.kb-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 768px) {
    .kb-layout { grid-template-columns: 1fr; }
    .kb-sidebar { display: none; }
    .kb-sidebar.mobile-open { display: block; }
}

/* ---- Sidebar ---- */
.kb-sidebar {
    position: sticky;
    top: 20px;
}
.kb-category-nav {
    background: var(--kb-card-bg);
    border: 1px solid var(--kb-border);
    border-radius: var(--kb-radius);
    padding: 1.25rem;
    box-shadow: var(--kb-shadow);
}
.kb-category-nav h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--kb-text-muted);
    margin: 0 0 1rem;
}
.kb-category-list,
.kb-subcategory-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.kb-subcategory-list {
    padding-left: 1rem;
    margin-top: 0.25rem;
}
.kb-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--kb-text);
    font-size: 0.9rem;
    transition: all var(--kb-transition);
    margin-bottom: 2px;
}
.kb-category-link:hover,
.kb-category-link.active {
    background: var(--kb-accent);
    color: var(--kb-primary);
    text-decoration: none;
}
.kb-cat-count {
    background: var(--kb-border);
    color: var(--kb-text-muted);
    font-size: 0.75rem;
    padding: 1px 7px;
    border-radius: 50px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}
.kb-category-link.active .kb-cat-count {
    background: var(--kb-primary);
    color: white;
}

/* ---- Main Content ---- */
.kb-results-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--kb-text-muted);
    font-size: 0.9rem;
    min-height: 1.5rem;
}
.kb-active-category {
    background: var(--kb-accent);
    color: var(--kb-primary);
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 500;
}

/* ---- Articles Grid ---- */
.kb-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ---- Article Card ---- */
.kb-article-card {
    background: var(--kb-card-bg);
    border: 1px solid var(--kb-border);
    border-radius: var(--kb-radius);
    overflow: hidden;
    box-shadow: var(--kb-shadow);
    transition: all var(--kb-transition);
    display: flex;
    flex-direction: column;
}
.kb-article-card:hover {
    box-shadow: var(--kb-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--kb-primary);
}
.kb-card-image {
    overflow: hidden;
    background: var(--kb-bg);
    line-height: 0;
}
.kb-card-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease;
}
.kb-article-card:hover .kb-card-image img {
    transform: scale(1.05);
}
.kb-card-body {
    padding: 1.1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.kb-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0.6rem;
}
.kb-tag {
    background: var(--kb-accent);
    color: var(--kb-primary);
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--kb-transition);
}
.kb-tag:hover {
    background: var(--kb-primary);
    color: white;
}
.kb-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    line-height: 1.4;
}
.kb-card-title a {
    color: var(--kb-text);
    text-decoration: none;
    transition: color var(--kb-transition);
}
.kb-card-title a:hover { color: var(--kb-primary); }
.kb-card-excerpt {
    color: var(--kb-text-muted);
    font-size: 0.88rem;
    margin: 0 0 0.75rem;
    flex: 1;
    line-height: 1.5;
}
.kb-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--kb-border);
}
.kb-card-date {
    color: var(--kb-text-muted);
    font-size: 0.78rem;
}
.kb-card-actions {
    display: flex;
    gap: 4px;
}
.kb-action-btn {
    background: none;
    border: 1px solid var(--kb-border);
    border-radius: 6px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--kb-transition);
}
.kb-action-btn:hover { background: var(--kb-bg); border-color: var(--kb-primary); }

/* ---- Empty State ---- */
.kb-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--kb-text-muted);
    font-size: 1.1rem;
    background: var(--kb-card-bg);
    border: 2px dashed var(--kb-border);
    border-radius: var(--kb-radius);
}

/* ---- Loading ---- */
.kb-loading {
    text-align: center;
    padding: 2rem;
    color: var(--kb-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}
.kb-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--kb-border);
    border-top-color: var(--kb-primary);
    border-radius: 50%;
    animation: kb-spin 0.7s linear infinite;
}
@keyframes kb-spin { to { transform: rotate(360deg); } }

/* ---- AI Result ---- */
.kb-ai-result {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-left: 4px solid var(--kb-primary);
    border-radius: var(--kb-radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}
.kb-ai-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.kb-ai-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--kb-primary);
}
.kb-ai-badge {
    background: var(--kb-primary);
    color: white;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 50px;
    margin-left: auto;
}
.kb-ai-response-text {
    color: var(--kb-text);
    line-height: 1.7;
    white-space: pre-wrap;
}
.kb-ai-disclaimer {
    font-size: 0.78rem;
    color: var(--kb-text-muted);
    margin: 1rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid #bae6fd;
}

/* ---- Pagination ---- */
.kb-pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}
.kb-page-btn {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--kb-border);
    border-radius: 8px;
    background: var(--kb-card-bg);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--kb-transition);
    color: var(--kb-text);
}
.kb-page-btn:hover,
.kb-page-btn.active {
    background: var(--kb-primary);
    color: white;
    border-color: var(--kb-primary);
}

/* ---- Buttons ---- */
.kb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--kb-transition);
    text-decoration: none;
}
.kb-btn-primary {
    background: white;
    color: var(--kb-primary);
    border: 2px solid rgba(255,255,255,0.7);
}
.kb-btn-primary:hover {
    background: var(--kb-primary);
    color: white;
    border-color: var(--kb-primary);
}
/* When button is inside main (not header) */
.kb-main .kb-btn-primary,
#kb-editor-modal .kb-btn-primary {
    background: var(--kb-primary);
    color: white;
    border: 2px solid var(--kb-primary);
}
.kb-main .kb-btn-primary:hover {
    background: var(--kb-secondary);
    border-color: var(--kb-secondary);
}
.kb-btn-secondary {
    background: var(--kb-bg);
    color: var(--kb-text);
    border: 1px solid var(--kb-border);
}
.kb-btn-secondary:hover { background: var(--kb-border); }
.kb-btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.kb-btn-danger:hover { background: #dc2626; color: white; }

/* ---- Modal ---- */
.kb-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

body.kb-media-frame-open .kb-modal {
    z-index: 159000;
}

body.kb-media-frame-open .kb-modal-overlay,
body.kb-media-frame-open .kb-modal-content {
    pointer-events: none;
}

.media-modal-backdrop {
    z-index: 159500 !important;
}

.media-modal {
    z-index: 160000 !important;
}
.kb-modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
}
.kb-modal-content {
    position: relative;
    background: white;
    border-radius: var(--kb-radius);
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.kb-modal-sm .kb-modal-content { max-width: 440px; }
.kb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--kb-border);
    background: var(--kb-bg);
}
.kb-modal-header h2, .kb-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}
.kb-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--kb-text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--kb-transition);
}
.kb-modal-close:hover { background: var(--kb-border); color: var(--kb-text); }
.kb-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}
.kb-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--kb-border);
    background: var(--kb-bg);
}

.kb-editor-status {
    flex: 1;
    font-size: 0.9rem;
    color: var(--kb-text-muted);
    align-self: center;
}
.kb-editor-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
@media (max-width: 768px) {
    .kb-modal-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .kb-editor-actions {
        justify-content: stretch;
    }
    .kb-editor-actions .kb-btn {
        width: 100%;
    }
}

/* ---- Form Elements ---- */
.kb-form-group {
    margin-bottom: 1.25rem;
}
.kb-form-group label {
    display: block;
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--kb-text);
    margin-bottom: 0.4rem;
}
.kb-form-group input[type="text"],
.kb-form-group input[type="url"],
.kb-form-group textarea,
.kb-form-group select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--kb-border);
    border-radius: 8px;
    font-size: 0.92rem;
    color: var(--kb-text);
    background: white;
    transition: border-color var(--kb-transition);
    outline: none;
    font-family: inherit;
}
.kb-form-group input:focus,
.kb-form-group textarea:focus {
    border-color: var(--kb-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.kb-category-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.kb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--kb-border);
    border-radius: 6px;
    transition: all var(--kb-transition);
}
.kb-checkbox-label:hover { border-color: var(--kb-primary); background: var(--kb-accent); }
.kb-checkbox-label input[type="checkbox"]:checked + * { color: var(--kb-primary); }

/* ---- Thumbnail ---- */
.kb-thumbnail-preview {
    min-height: 100px;
    border: 2px dashed var(--kb-border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kb-text-muted);
    font-size: 0.9rem;
    background: var(--kb-bg);
}
.kb-thumbnail-preview img {
    width: 100%;
    height: auto;
    display: block;
}
.kb-thumbnail-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Content Editor ---- */
.kb-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 0.5rem;
    background: var(--kb-bg);
    border: 1.5px solid var(--kb-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}
.kb-toolbar-btn {
    padding: 4px 9px;
    border: 1px solid var(--kb-border);
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--kb-transition);
    color: var(--kb-text);
    min-width: 30px;
    text-align: center;
}
.kb-toolbar-btn:hover { background: var(--kb-primary); color: white; border-color: var(--kb-primary); }
.kb-toolbar-separator { width: 1px; height: 20px; background: var(--kb-border); margin: 0 2px; }
.kb-toolbar-select {
    padding: 4px 6px;
    border: 1px solid var(--kb-border);
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
}
.kb-content-editor {
    min-height: 220px;
    padding: 0.85rem;
    border: 1.5px solid var(--kb-border);
    border-radius: 0 0 8px 8px;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.7;
    font-family: inherit;
    color: var(--kb-text);
    overflow-y: auto;
}
.kb-content-editor:focus { border-color: var(--kb-primary); }
.kb-content-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--kb-text-muted);
    pointer-events: none;
}

.kb-content-editor img,
.kb-content-editor figure img,
.kb-article-content img,
.kb-article-content figure img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    margin: 12px 0;
    border-radius: 8px;
}

.kb-content-editor figure,
.kb-article-content figure,
.kb-content-editor .wp-caption,
.kb-article-content .wp-caption,
.kb-content-editor .wp-block-image,
.kb-article-content .wp-block-image {
    max-width: 100%;
}

.kb-content-editor figure,
.kb-article-content figure {
    margin: 1rem 0;
}

.kb-content-editor .alignleft,
.kb-article-content .alignleft {
    float: left;
    margin: 0.35rem 1rem 0.75rem 0;
}

.kb-content-editor .alignright,
.kb-article-content .alignright {
    float: right;
    margin: 0.35rem 0 0.75rem 1rem;
}

.kb-content-editor .aligncenter,
.kb-article-content .aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.kb-content-editor::after,
.kb-article-content::after {
    content: "";
    display: block;
    clear: both;
}

@media (max-width: 768px) {
    .kb-content-editor .alignleft,
    .kb-content-editor .alignright,
    .kb-article-content .alignleft,
    .kb-article-content .alignright {
        float: none;
        display: block;
        margin: 0.9rem auto;
    }
}

/* ---- Admin Toggle ---- */
.kb-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}
.kb-toggle input { display: none; }
.kb-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--kb-transition);
}
.kb-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 4px; top: 4px;
    background: white;
    border-radius: 50%;
    transition: all var(--kb-transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.kb-toggle input:checked + .kb-toggle-slider { background: var(--kb-primary); }
.kb-toggle input:checked + .kb-toggle-slider::before { transform: translateX(20px); }

/* ---- Admin styles ---- */
.kb-admin-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    margin-top: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) {
    .kb-admin-grid { grid-template-columns: 1fr; }
}
.kb-settings-card {
    background: white;
    border: 1px solid var(--kb-border);
    border-radius: var(--kb-radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--kb-shadow);
}
.kb-settings-card h2 {
    font-size: 1rem;
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--kb-border);
}

/* ---- Toast Notification ---- */
#kb-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 200000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}
#kb-toast.show {
    transform: translateY(0);
    opacity: 1;
}
#kb-toast.success { background: #16a34a; }
#kb-toast.error { background: #dc2626; }

/* ---- AI Button & Panel ---- */
.kb-btn-ai {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    font-weight: 600;
    position: relative;
    transition: all var(--kb-transition);
}
.kb-btn-ai:hover {
    background: linear-gradient(135deg, #6d28d9, #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124,58,237,0.4);
}
.kb-btn-ai.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

/* AI expandable panel – sits between header and layout */
.kb-ai-panel {
    margin-bottom: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-bottom 0.3s ease;
}
.kb-ai-panel.kb-ai-panel-open {
    max-height: 300px;
    margin-bottom: 1.25rem;
}
.kb-ai-panel-inner {
    background: var(--kb-card-bg);
    border: 1.5px solid var(--kb-primary);
    border-radius: var(--kb-radius);
    padding: 1.1rem 1.25rem;
    box-shadow: 0 4px 20px rgba(10,42,110,0.12);
}
.kb-ai-panel-input-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
}
.kb-ai-question {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--kb-border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: var(--kb-bg);
    color: var(--kb-text);
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color var(--kb-transition);
}
.kb-ai-question:focus {
    border-color: var(--kb-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(10,42,110,0.08);
}
.kb-btn-send {
    background: linear-gradient(135deg, var(--kb-primary), var(--kb-secondary));
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--kb-transition);
    flex-shrink: 0;
    height: 44px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kb-btn-send:hover {
    opacity: 0.85;
    transform: scale(1.05);
}
.kb-btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.kb-ai-panel-hint {
    font-size: 0.78rem;
    color: var(--kb-text-muted);
    margin: 0.6rem 0 0;
    text-align: center;
}

/* AI result close button */
.kb-ai-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--kb-text-muted);
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 5px;
    margin-left: auto;
    transition: all var(--kb-transition);
}
.kb-ai-close:hover { background: var(--kb-border); color: var(--kb-text); }

/* ---- Import ---- */
.kb-import-dropzone {
    border: 2.5px dashed var(--kb-border);
    border-radius: var(--kb-radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--kb-bg);
    transition: all var(--kb-transition);
    cursor: pointer;
}
.kb-import-dropzone.drag-over {
    border-color: var(--kb-primary);
    background: var(--kb-accent);
}
.kb-dropzone-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
}
.kb-dropzone-inner p {
    color: var(--kb-text-muted);
    margin: 0.3rem 0;
}
.kb-dropzone-formats {
    font-size: 0.8rem !important;
    color: var(--kb-text-muted) !important;
    margin-top: 0.5rem !important;
}
.kb-import-file-list {
    margin-top: 1rem;
    background: var(--kb-bg);
    border: 1px solid var(--kb-border);
    border-radius: 8px;
    padding: 1rem;
}
.kb-import-file-list h4 {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    color: var(--kb-text-muted);
}
#kb-import-files-ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
#kb-import-files-ul li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.88rem;
    margin-bottom: 4px;
    background: white;
    border: 1px solid var(--kb-border);
}
#kb-import-files-ul li .kb-file-size {
    color: var(--kb-text-muted);
    font-size: 0.78rem;
}
#kb-import-files-ul li .kb-file-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--kb-text-muted);
    font-size: 1rem;
    padding: 0 4px;
}
#kb-import-files-ul li .kb-file-remove:hover { color: #dc2626; }

/* Progress bar */
.kb-import-progress-bar {
    height: 8px;
    background: var(--kb-border);
    border-radius: 50px;
    overflow: hidden;
    margin: 1rem 0 0.5rem;
}
.kb-import-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--kb-primary), var(--kb-secondary));
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 50px;
}
#kb-import-progress-text {
    font-size: 0.85rem;
    color: var(--kb-text-muted);
    margin: 0;
}

/* Import results */
.kb-import-results {
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
}
.kb-import-result-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--kb-border);
}
.kb-import-result-item:last-child { border-bottom: none; }
.kb-import-result-item.success { background: #f0fdf4; }
.kb-import-result-item.error   { background: #fef2f2; }
.kb-import-result-item .kb-result-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.kb-import-result-item .kb-result-info { flex: 1; }
.kb-import-result-item .kb-result-info strong { display: block; }
.kb-import-result-item .kb-result-info a {
    color: var(--kb-primary);
    font-size: 0.82rem;
}
.kb-import-info {
    color: var(--kb-text-muted);
    font-size: 0.9rem;
    margin: 0 0 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .kb-title { font-size: 1.6rem; }
    .kb-modal-content { max-height: 100vh; border-radius: 0; }
    .kb-articles-grid { grid-template-columns: 1fr; }
}

/* ---- Reset search button ---- */
.kb-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.85rem;
    background: var(--kb-accent);
    color: var(--kb-primary);
    border: 1px solid var(--kb-border);
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}
.kb-reset-btn:hover {
    background: var(--kb-primary);
    color: white;
    border-color: var(--kb-primary);
}

/* ---- AI Internet search result ---- */
.kb-ai-sources {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #bae6fd;
}
.kb-ai-sources h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--kb-primary);
    margin: 0 0 0.5rem;
}
.kb-ai-sources ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.kb-ai-sources li a {
    display: inline-block;
    padding: 3px 10px;
    background: white;
    border: 1px solid #bae6fd;
    border-radius: 50px;
    font-size: 0.78rem;
    color: var(--kb-primary);
    text-decoration: none;
    transition: all 0.2s;
}
.kb-ai-sources li a:hover {
    background: var(--kb-primary);
    color: white;
    border-color: var(--kb-primary);
}

/* Fact-check warning banner */
.kb-ai-fact-check-banner {
    margin-top: 1rem;
    padding: 0.65rem 1rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #92400e;
    font-weight: 500;
}

/* AI actions */
.kb-ai-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}
.kb-btn-create-article {
    background: linear-gradient(135deg, var(--kb-primary), var(--kb-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.kb-btn-create-article:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10,42,110,0.3);
}

/* AI response text formatting */
.kb-ai-response-text h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--kb-primary);
    margin: 1rem 0 0.4rem;
}
.kb-ai-response-text h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.8rem 0 0.3rem;
}
.kb-ai-response-text p { margin: 0 0 0.7rem; }
.kb-ai-response-text ul { margin: 0.5rem 0 0.7rem 1.25rem; }
.kb-ai-response-text li { margin-bottom: 0.3rem; }
.kb-ai-response-text a { color: var(--kb-primary); }
.kb-ai-response-text strong { font-weight: 700; }
.kb-ai-response-text em { font-style: italic; color: #4a6080; }

/* ---- Back to start bar ---- */
.kb-back-to-start-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--kb-accent);
    border: 1px solid var(--kb-border);
    border-left: 4px solid var(--kb-primary);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
}
.kb-reset-btn-main {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    background: var(--kb-primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.kb-reset-btn-main:hover {
    background: var(--kb-secondary);
    transform: translateX(-2px);
}
.kb-back-hint {
    font-size: 0.82rem;
    color: var(--kb-text-muted);
    font-style: italic;
}

/* ---- SEO: Breadcrumbs ---- */
.kb-breadcrumbs {
    font-size: 0.82rem;
    color: var(--kb-text-muted);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}
.kb-breadcrumbs a {
    color: var(--kb-primary);
    text-decoration: none;
}
.kb-breadcrumbs a:hover { text-decoration: underline; }
.kb-breadcrumbs span[aria-current] { color: var(--kb-text); font-weight: 500; }

/* Drafts panel */
.kb-drafts-panel {
    margin: 0 0 24px;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}
.kb-drafts-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}
.kb-drafts-panel-header h3 {
    margin: 0 0 4px;
}
.kb-drafts-panel-header p {
    margin: 0;
    color: #64748b;
}
.kb-drafts-count {
    min-width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.1);
    color: var(--kb-primary);
    font-weight: 700;
}
.kb-drafts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.kb-draft-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    background: #f8fafc;
}
.kb-draft-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.kb-draft-status {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.kb-draft-status-draft {
    background: #fef3c7;
    color: #92400e;
}
.kb-draft-status-pending {
    background: #dbeafe;
    color: #1d4ed8;
}
.kb-draft-date {
    font-size: 13px;
    color: #64748b;
}
.kb-draft-title {
    margin: 0 0 8px;
    font-size: 18px;
}
.kb-draft-excerpt {
    margin: 0 0 14px;
    color: #475569;
}
.kb-draft-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.kb-drafts-empty {
    padding: 12px 0 4px;
    color: #64748b;
}
@media (max-width: 767px) {
    .kb-drafts-panel-header {
        align-items: stretch;
        flex-direction: column;
    }
}

/* ── v2.3.0 premium hero ─────────────────────────────────────────── */
.kb-header {
    position: relative;
    overflow: hidden;
    padding: 3.2rem 1.25rem 2.35rem;
    box-shadow: 0 22px 55px rgba(6, 26, 74, 0.22);
}
.kb-header::before {
    content: '';
    position: absolute;
    inset: -40% -20% auto auto;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255,255,255,0.26), rgba(255,255,255,0));
    pointer-events: none;
}
.kb-header::after {
    content: '';
    position: absolute;
    inset: auto auto -36% -18%;
    width: 360px;
    height: 360px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(220,232,255,0.22), rgba(220,232,255,0));
    pointer-events: none;
}
.kb-hero-copy,
.kb-search-container { position: relative; z-index: 1; }
.kb-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.8rem;
    border: 1px solid rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.88);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.85rem;
}
.kb-title {
    font-size: clamp(2.15rem, 4vw, 3.8rem);
    line-height: 1.04;
    margin-bottom: 0.8rem;
}
.kb-subtitle {
    max-width: 760px;
    margin: 0 auto 1.25rem;
    color: rgba(255,255,255,0.82);
    font-size: 1.05rem;
}
.kb-hero-metrics {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin: 0 auto 1.5rem;
}
.kb-hero-metrics span {
    display: inline-flex;
    align-items: baseline;
    gap: 0.42rem;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.86);
    font-size: 0.82rem;
    backdrop-filter: blur(10px);
}
.kb-hero-metrics strong {
    color: #fff;
    font-size: 0.96rem;
    font-weight: 800;
}
.kb-search-container {
    max-width: 920px;
    padding: 0.35rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(12px);
}
.kb-article-card {
    position: relative;
}
.kb-article-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.46), rgba(255,255,255,0));
    opacity: 0;
    transition: opacity var(--kb-transition);
}
.kb-article-card:hover::before { opacity: 1; }
.kb-card-title a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.kb-action-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
@media (max-width: 640px) {
    .kb-header { padding: 2.35rem 0.85rem 1.75rem; }
    .kb-search-container { border-radius: 24px; }
    .kb-hero-metrics span { width: 100%; justify-content: center; }
}

/* ---- Smal modal (länkinfogning) ---- */
.kb-modal-content.kb-modal-small {
    max-width: 460px;
}
.kb-modal-small .kb-modal-body .kb-form-group:last-child {
    margin-bottom: 0;
}
