/* documents_kb.css — Document Knowledge Base v1.0 (Phase 64) */

.dkb-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 0 48px 0;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.dkb-loading { padding: 32px; text-align: center; color: #64748b; font-size: 14px; }
.dkb-error { padding: 20px; background: #fef2f2; border-radius: 10px; color: #dc2626; font-size: 14px; }
.dkb-empty { text-align: center; padding: 48px 24px; color: #64748b; }

.dkb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.dkb-title { font-size: 20px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.dkb-subtitle { font-size: 13px; color: #64748b; }

.dkb-stats { display: flex; gap: 20px; flex-shrink: 0; }
.dkb-stat { text-align: center; }
.dkb-stat-num { display: block; font-size: 28px; font-weight: 800; color: #0071e3; line-height: 1; }
.dkb-stat-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }

/* Upload area */
.dkb-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s;
    margin-bottom: 20px;
}
.dkb-upload-area:hover, .dkb-drag-over {
    border-color: #0071e3;
    background: #eff6ff;
}
.dkb-upload-icon { font-size: 36px; margin-bottom: 8px; }
.dkb-upload-title { font-size: 15px; font-weight: 600; color: #1e293b; margin-bottom: 4px; }
.dkb-upload-subtitle { font-size: 12px; color: #94a3b8; }

.dkb-progress-bar-wrap {
    height: 6px; background: #e2e8f0; border-radius: 999px; margin-bottom: 16px; overflow: hidden;
}
.dkb-progress-bar-inner {
    height: 100%; width: 0%; background: #0071e3; border-radius: 999px;
    transition: width 0.4s ease;
}

/* Global search */
.dkb-global-search {
    background: linear-gradient(135deg, #1e3a5f, #0c4a6e);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    color: white;
}
.dkb-global-search-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: #93c5fd; }
.dkb-global-search-row { display: flex; gap: 8px; }
.dkb-ask-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    outline: none;
}
.dkb-ask-input::placeholder { color: rgba(255,255,255,0.5); }
.dkb-ask-input:not(.dkb-global-search *) {
    background: white;
    border-color: #e2e8f0;
    color: #1e293b;
}
.dkb-ask-btn {
    padding: 10px 20px;
    background: #0071e3;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.dkb-ask-btn:hover { background: #005bb5; }
.dkb-ask-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.dkb-ask-result {
    margin-top: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 13px;
    color: #e2e8f0;
    line-height: 1.6;
}
.dkb-ask-result-inner .dkb-ask-answer { color: #f0f9ff; line-height: 1.7; }
.dkb-sources { margin-top: 10px; }
.dkb-source-tag {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    color: #93c5fd;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    margin: 2px;
    cursor: pointer;
}
.dkb-source-tag:hover { background: rgba(255,255,255,0.25); }

/* Document list */
.dkb-doc-list { display: flex; flex-direction: column; gap: 10px; }
.dkb-doc-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.15s;
}
.dkb-doc-card:hover { border-color: #0071e3; box-shadow: 0 2px 12px rgba(0,113,227,0.1); }
.dkb-doc-icon { font-size: 28px; flex-shrink: 0; }
.dkb-doc-info { flex: 1; min-width: 0; }
.dkb-doc-name { font-size: 15px; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.dkb-doc-meta { font-size: 12px; color: #94a3b8; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dkb-doc-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.dkb-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.dkb-badge-ready { background: #ecfdf5; color: #059669; }
.dkb-badge-indexing { background: #fff7ed; color: #d97706; }
.dkb-badge-notext { background: #fef2f2; color: #dc2626; }

.dkb-action-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.dkb-action-btn:hover { opacity: 0.8; }
.dkb-btn-ask { background: #eff6ff; color: #1d4ed8; }
.dkb-btn-quiz { background: #f5f3ff; color: #6d28d9; }
.dkb-btn-delete { background: #fef2f2; color: #dc2626; }
.dkb-btn-sop { background: #ecfdf5; color: #059669; }

/* Document detail */
.dkb-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #0071e3;
    cursor: pointer;
    margin-bottom: 16px;
    font-weight: 500;
}
.dkb-back-btn:hover { text-decoration: underline; }

.dkb-doc-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dkb-text-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.dkb-preview-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.dkb-preview-text { font-size: 12px; color: #475569; line-height: 1.7; max-height: 160px; overflow-y: auto; white-space: pre-wrap; }

.dkb-no-text {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 16px;
}

/* Chat */
.dkb-chat-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px 24px;
}
.dkb-chat-title { font-size: 15px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.dkb-chat-hint { font-size: 12px; color: #64748b; margin-bottom: 12px; }
.dkb-chat-history {
    min-height: 60px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dkb-msg { font-size: 13px; line-height: 1.6; padding: 10px 14px; border-radius: 10px; max-width: 90%; }
.dkb-msg-user { background: #eff6ff; color: #1e293b; align-self: flex-end; }
.dkb-msg-assistant { background: #f8fafc; color: #1e293b; border: 1px solid #e2e8f0; align-self: flex-start; }
.dkb-msg-loading { color: #94a3b8; background: #f8fafc; }
.dkb-source-hint { font-size: 11px; color: #0071e3; }

.dkb-chat-input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.dkb-chat-input-row .dkb-ask-input {
    background: white;
    border-color: #e2e8f0;
    color: #1e293b;
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    outline: none;
}
.dkb-chat-input-row .dkb-ask-input:focus { border-color: #0071e3; }
.dkb-quick-questions { display: flex; gap: 6px; flex-wrap: wrap; }
.dkb-quick-btn {
    padding: 5px 12px;
    background: #f5f5f7;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    font-size: 11px;
    color: #3d3d3f;
    cursor: pointer;
    transition: all 0.15s;
}
.dkb-quick-btn:hover { background: #eff6ff; border-color: #0071e3; color: #0071e3; }

/* Quiz */
.dkb-quiz-header { margin-bottom: 24px; }
.dkb-quiz-container { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }
.dkb-quiz-question {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px 24px;
}
.dkb-quiz-q-num { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.dkb-quiz-q-text { font-size: 15px; font-weight: 600; color: #1e293b; margin-bottom: 14px; line-height: 1.5; }
.dkb-quiz-options { display: flex; flex-direction: column; gap: 8px; }
.dkb-quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: all 0.15s;
}
.dkb-quiz-option:hover { border-color: #0071e3; background: #eff6ff; }
.dkb-quiz-option input { flex-shrink: 0; }
.dkb-opt-correct { background: #ecfdf5 !important; border-color: #10b981 !important; color: #065f46 !important; font-weight: 600; }
.dkb-opt-wrong { background: #fef2f2 !important; border-color: #ef4444 !important; color: #991b1b !important; }

.dkb-quiz-explanation {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.dkb-exp-correct { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.dkb-exp-wrong { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }

.dkb-quiz-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 0;
}
.dkb-quiz-score { font-size: 16px; }

@media (max-width: 600px) {
    .dkb-doc-actions { flex-direction: column; }
    .dkb-header { flex-direction: column; }
    .dkb-doc-header { flex-direction: column; }
    .dkb-global-search-row { flex-direction: column; }
}

/* ── Workflow: Status badges ── */
.dkb-status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.dkb-s-draft    { background: #f1f5f9; color: #64748b; }
.dkb-s-review   { background: #fef3c7; color: #92400e; }
.dkb-s-revision { background: #ffedd5; color: #9a3412; }
.dkb-s-approved { background: #dcfce7; color: #166534; }
.dkb-s-archived { background: #f1f5f9; color: #9ca3af; }

/* ── Filter tabs ── */
.dkb-filter-tabs {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 16px; border-bottom: 1px solid #e2e8f0; padding-bottom: 12px;
}
.dkb-ftab {
    padding: 5px 12px; border-radius: 20px; border: 1px solid #e2e8f0;
    background: white; font-size: 13px; cursor: pointer; color: #475569;
    display: flex; align-items: center; gap: 6px; transition: all 0.15s;
}
.dkb-ftab:hover { border-color: #94a3b8; background: #f8fafc; }
.dkb-ftab.active { background: #1e293b; color: white; border-color: #1e293b; }
.dkb-ftab-alert { border-color: #fca5a5; color: #991b1b; }
.dkb-ftab-alert.active { background: #ef4444; border-color: #ef4444; }
.dkb-ftab-cnt {
    background: rgba(0,0,0,0.12); color: inherit;
    border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700;
}
.dkb-ftab-green { background: #dcfce7; color: #166534; }

/* ── Workflow actions bar ── */
.dkb-workflow-actions {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 16px; background: #f8fafc; border-radius: 10px;
    border: 1px solid #e2e8f0; margin-bottom: 16px;
}
.dkb-btn-precheck { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.dkb-btn-precheck:hover { background: #dbeafe; }
.dkb-btn-review   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.dkb-btn-review:hover { background: #fde68a; }
.dkb-btn-approve  { background: #dcfce7; color: #166534; border-color: #86efac; }
.dkb-btn-approve:hover { background: #bbf7d0; }

/* ── AI Precheck block ── */
.dkb-precheck-block {
    border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 16px; margin-bottom: 16px; background: #fafafa;
}
.dkb-precheck-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
    font-size: 14px; font-weight: 600; color: #1e293b;
}
.dkb-precheck-score { font-size: 22px; font-weight: 800; }
.dkb-precheck-summary { font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.5; }
.dkb-criteria-row {
    display: grid; grid-template-columns: 110px 1fr 45px auto;
    align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px;
}
.dkb-criteria-name { color: #64748b; font-weight: 500; }
.dkb-criteria-bar { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.dkb-criteria-score { color: #1e293b; font-weight: 600; text-align: right; }
.dkb-criteria-comment { color: #64748b; font-size: 11px; }
.dkb-precheck-issues, .dkb-precheck-recs {
    font-size: 13px; margin-top: 10px; padding: 10px 12px;
    border-radius: 8px; line-height: 1.6;
}
.dkb-precheck-issues { background: #fef2f2; color: #991b1b; }
.dkb-precheck-recs   { background: #eff6ff; color: #1e40af; }
.dkb-precheck-issues ul, .dkb-precheck-recs ul { margin: 4px 0 0 16px; padding: 0; }

/* ── Section containers ── */
.dkb-section {
    border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 14px 16px; margin-bottom: 12px; background: white;
}
.dkb-section-title {
    font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 10px;
}
.dkb-hidden { display: none; }

/* ── Reviewers list ── */
.dkb-reviewers-list { display: flex; flex-direction: column; gap: 6px; }
.dkb-reviewer-row {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px; font-size: 13px;
}
.dkb-rv-pending  { background: #fef9c3; }
.dkb-rv-approved { background: #f0fdf4; }
.dkb-rv-rejected { background: #fef2f2; }
.dkb-rv-icon { font-size: 16px; }
.dkb-rv-name { font-weight: 500; color: #1e293b; flex: 1; }
.dkb-rv-date { color: #94a3b8; font-size: 12px; }
.dkb-rv-comment { color: #64748b; font-size: 12px; font-style: italic; }

/* ── Status history ── */
.dkb-history-list { display: flex; flex-direction: column; gap: 8px; }
.dkb-history-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.dkb-history-dot { width: 8px; height: 8px; background: #94a3b8; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dkb-history-status { font-weight: 600; color: #1e293b; }
.dkb-history-who  { color: #64748b; }
.dkb-history-date { color: #94a3b8; }
.dkb-history-comment { color: #475569; font-style: italic; font-size: 12px; margin-top: 2px; }

/* ── Comments ── */
.dkb-comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.dkb-comment {
    border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 10px 12px; background: #fafafa; font-size: 13px;
}
.dkb-comment-resolved { opacity: 0.6; border-style: dashed; }
.dkb-comment-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.dkb-comment-type   { font-size: 15px; }
.dkb-comment-author { font-weight: 600; color: #1e293b; }
.dkb-comment-date   { color: #94a3b8; font-size: 11px; flex: 1; }
.dkb-comment-text   { color: #374151; line-height: 1.5; }
.dkb-resolve-btn {
    padding: 2px 8px; border: 1px solid #d1fae5; border-radius: 4px;
    background: #f0fdf4; color: #166534; font-size: 11px; cursor: pointer;
    margin-left: auto;
}
.dkb-resolve-btn:hover { background: #dcfce7; }
.dkb-resolved-tag { color: #10b981; font-size: 11px; margin-left: auto; }
.dkb-resolved-toggle {
    color: #64748b; font-size: 12px; cursor: pointer; padding: 4px 0;
}
.dkb-resolved-toggle:hover { color: #374151; }
.dkb-comment-input-row {
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.dkb-select-sm {
    padding: 6px 8px; border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: 12px; background: white; color: #374151;
}

/* ── Process Analysis modal ── */
.dkb-pa-process {
    border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px;
    margin-bottom: 8px; background: #fafafa;
}
.dkb-pa-process-name { font-weight: 600; font-size: 13px; color: #1e293b; margin-bottom: 2px; }
.dkb-pa-process-desc { font-size: 12px; color: #64748b; margin-bottom: 6px; }
.dkb-pa-section { margin-top: 14px; }
.dkb-pa-section-title { font-weight: 600; font-size: 13px; color: #374151; margin-bottom: 8px; }
.dkb-pa-kpi-list { display: flex; gap: 6px; flex-wrap: wrap; }
.dkb-pa-missing { font-size: 13px; padding: 6px 10px; background: #fffbeb; border-radius: 6px; margin-bottom: 4px; color: #92400e; }

/* ── Webhooks ── */
.dkb-webhooks-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dkb-webhook-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
    background: #fafafa;
}
.dkb-form-group { margin-bottom: 12px; }
.dkb-form-row { display: flex; gap: 12px; }
.dkb-label { font-size: 12px; font-weight: 600; color: #374151; display: block; margin-bottom: 4px; }
.dkb-textarea {
    width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: 13px; resize: vertical; font-family: inherit; box-sizing: border-box;
}

/* ── Modal overlay ── */
.dkb-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000; padding: 16px;
}
.dkb-modal {
    background: white; border-radius: 16px; padding: 24px;
    max-width: 520px; width: 100%; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.dkb-modal-large { max-width: 720px; }
.dkb-modal-title { font-size: 18px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.dkb-modal-subtitle { font-size: 13px; color: #64748b; margin-bottom: 16px; }
.dkb-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.dkb-btn-primary {
    padding: 8px 18px; border-radius: 8px; border: none;
    background: #1e293b; color: white; font-weight: 600; cursor: pointer; font-size: 14px;
}
.dkb-btn-primary:hover { background: #334155; }
.dkb-btn-cancel {
    padding: 8px 18px; border-radius: 8px; border: 1px solid #e2e8f0;
    background: white; color: #64748b; cursor: pointer; font-size: 14px;
}
.dkb-btn-danger {
    padding: 8px 18px; border-radius: 8px; border: none;
    background: #ef4444; color: white; font-weight: 600; cursor: pointer; font-size: 14px;
}

/* ── Reviewer selection ── */
.dkb-reviewers-select { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.dkb-reviewer-option {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; font-size: 13px; transition: background 0.1s;
}
.dkb-reviewer-option:hover { background: #f8fafc; }
