/* ═══════════════════════════════════════════════════════════════
   KNOWLEDGE BASE LUX - PREMIUM THEME
   ═══════════════════════════════════════════════════════════════ */

.kb-page {
    display: flex;
    flex-direction: column;
    height: calc(100% - 40px);
    margin: 20px;
    background: var(--bg); 
    background: radial-gradient(circle at 50% -20%, var(--bg3) 0%, var(--bg) 100%);
    overflow: hidden;
    color: var(--text);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
}

/* --- TOPBAR --- */
.kb-topbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--surface2-glass);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-bottom: 1px solid var(--border-glass);
    z-index: 1000;
}

.kb-top-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.kb-base-btn {
    padding: 12px 28px;
    border-radius: 16px;
    border: 1px solid var(--border-glass);
    background: var(--surface-glass);
    color: var(--text3);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    letter-spacing: 0.3px;
}
.kb-base-btn:hover { background: var(--surface2-glass); border-color: var(--accent); transform: translateY(-1px); }
.kb-base-btn.active { 
    background: var(--accent); 
    color: #fff; 
    border-color: var(--accent); 
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

/* --- OVERALL PROGRESS --- */
.kb-overall-header {
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    border-radius: 30px;
    padding: 25px 35px;
    margin: 25px 32px 15px;
    backdrop-filter: blur(15px);
}
.kb-oh-pct { font-size: 28px; font-weight: 950; color: var(--accent); font-family: 'Outfit', sans-serif; }
.kb-oh-bar { height: 12px; background: rgba(0,0,0,0.2); border-radius: 20px; margin-top: 18px; overflow: hidden; }
.kb-oh-fill { 
    height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6); 
    background-size: 200% 100%;
    animation: gradientShift 3s linear infinite;
    border-radius: 20px; transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* --- CARDS & GRID --- */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 35px; padding: 25px 32px 80px; }
.kb-card {
    background: var(--surface-glass); 
    backdrop-filter: blur(10px);
    border-radius: 32px;
    border: 1px solid var(--border-glass);
    padding: 35px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.kb-card:hover { 
    transform: translateY(-12px) scale(1.02); 
    border-color: var(--accent); 
    background: var(--surface2-glass); 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); 
}
.kb-card.is-passed { border-color: rgba(16, 185, 129, 0.5); }

.kb-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 30px; }
.kb-card-icon { 
    width: 72px; height: 72px; background: var(--bg2-glass); 
    border-radius: 22px; display: flex; align-items: center; justify-content: center; 
    font-size: 36px; border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-sm);
}

.kb-card-title { font-size: 24px; font-weight: 900; color: #fff; margin-bottom: 14px; letter-spacing: -0.5px; }
.kb-card-desc { color: var(--text3); font-size: 15px; line-height: 1.7; margin-bottom: 30px; height: 51px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; opacity: 0.8; }

.kb-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.kb-card-meta { color: var(--accent); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; }
.kb-card-pct { color: #fff; font-weight: 950; font-size: 16px; font-family: 'Outfit', sans-serif; }

.kb-card-progress { height: 8px; background: rgba(0,0,0,0.2); border-radius: 10px; margin-top: 15px; overflow: hidden; border: 1px solid rgba(255,255,255,0.03); }
.kb-card-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.8s cubic-bezier(0.17, 0.67, 0.83, 0.67); }
.kb-card.is-passed .kb-card-progress-fill { background: linear-gradient(90deg, #10b981, #34d399); }

.kb-card-lock { position: absolute; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 14px; z-index: 10; backdrop-filter: blur(8px); }
.kb-card-badge { position: absolute; right: 25px; top: 25px; background: rgba(16, 185, 129, 0.9); color: #fff; padding: 7px 16px; border-radius: 12px; font-size: 12px; font-weight: 900; box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3); backdrop-filter: blur(5px); }

/* --- BLOCK VIEW --- */
.kb-block-view { max-width: 1200px; margin: 0 auto; padding: 40px 60px 120px; }
.kb-block-header-lux {
    background: radial-gradient(circle at top right, var(--bg3), var(--bg));
    border-radius: 40px;
    border: 1px solid var(--border-glass);
    padding: 80px;
    margin-bottom: 60px;
    position: relative;
    box-shadow: 0 40px 80px -20px rgba(0,0,0,0.6);
}
.kb-block-title { font-size: 56px; font-weight: 950; color: #fff; margin-bottom: 25px; letter-spacing: -3px; line-height: 1; }
.kb-block-desc { color: var(--text3); font-size: 22px; line-height: 1.6; max-width: 85%; opacity: 0.9; }

/* --- SEARCH --- */
.kb-search-container { flex: 1; max-width: 380px; margin: 0 20px; position: relative; }
.kb-search-input { 
    width: 100%; background: var(--bg2) !important; border: 1px solid var(--border) !important; 
    border-radius: 14px !important; padding: 10px 15px 10px 40px !important; color: var(--text) !important; 
}
.kb-search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); opacity: 0.5; color: var(--text); }

/* --- LUXURY ARTICLE VIEW --- */
.kb-article-luxury { display: flex; flex-direction: column; height: 100%; background: var(--bg); position: relative; z-index: 100 }

.kb-article-header-lux {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 40px;
    background: var(--surface2);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.kb-header-left, .kb-header-right { display: flex; align-items: center; }

.kb-article-body { flex: 1; padding: 50px 10%; line-height: 1.8; font-size: 18px; color: var(--text2); }
.kb-article-body h1, .kb-article-body h2, .kb-article-body h3 { color: var(--text); margin: 25px 0 15px; font-weight: 900; }
.kb-article-body p { margin-bottom: 15px; color: var(--text2); line-height: 1.7; }
.kb-article-body strong { color: var(--text); }
.kb-article-body blockquote { border-left: 4px solid var(--accent); background: var(--surface); padding: 15px 20px; border-radius: 10px; margin: 20px 0; font-style: italic; }
.kb-article-body ul { margin: 15px 0 15px 20px; }
.kb-article-body li { margin-bottom: 8px; color: var(--text2); }
.kb-article-body pre { background: var(--bg2); padding: 20px; border-radius: 12px; overflow-x: auto; font-family: var(--mono); border: 1px solid var(--border); }

/* VIDEO SCALING (x4) */
.kb-article-body iframe {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5) !important;
    margin: 40px 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* ACCORDIONS */
details.kb-details { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 10px 20px; margin: 20px 0; transition: 0.3s; }
details.kb-details summary { cursor: pointer; font-weight: 800; color: var(--text); font-size: 16px; outline: none; padding: 10px 0; display: list-item; }
details.kb-details summary:hover { color: var(--accent); }
details.kb-details[open] { background: var(--surface2); border-color: var(--accent); }
details.kb-details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 15px; }

/* FOOTER & BUTTONS */
.kb-article-footer { padding: 40px; border-top: 1px solid var(--border); display: flex; align-items: center; background: var(--surface2); }

/* ATTACHMENTS */
.kb-attachments-section { margin-top: 60px; padding-top: 40px; border-top: 1px solid var(--border); }
.kb-attachments-title { font-size: 14px; font-weight: 900; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; }
.kb-attachment-item { display: flex; justify-content: space-between; align-items: center; background: var(--surface); padding: 15px 25px; border-radius: 14px; text-decoration: none !important; color: var(--text) !important; margin-bottom: 12px; border: 1px solid var(--border); transition: 0.3s; }
/* ATTACHMENTS PILLS IN EDITOR */
.kb-attachment-pill {
    display: flex;
    align-items: center;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #fff;
    gap: 8px;
}
.kb-attachment-pill button {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}
.kb-attachment-pill button:hover { color: #ef4444; }

/* --- EDITOR & MODALS --- */
.kb-modal-lux {
    background: var(--bg);
    background: radial-gradient(circle at top left, var(--bg3), var(--bg));
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    color: var(--text);
}

.kb-editor-title-input {
    width: 100%;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    padding: 20px 30px !important;
    color: var(--text) !important;
    font-size: 32px !important;
    font-weight: 900 !important;
    outline: none !important;
    margin-bottom: 25px !important;
    letter-spacing: -0.5px;
    transition: 0.3s;
}
.kb-editor-title-input:focus {
    background: var(--surface2) !important;
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-sm);
}
.kb-editor-title-input::placeholder { color: var(--text3); opacity: 0.3; }

.kb-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.03);
}

.kb-editor-main {
    display: flex;
    height: 500px;
    background: rgba(0,0,0,0.1);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.kb-editor-area {
    flex: 1;
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 30px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    outline: none;
    border-right: 1px solid rgba(255,255,255,0.05);
}

#edPreview {
    flex: 1;
    background: rgba(0,0,0,0.15);
    padding: 30px;
    overflow-y: auto;
}

/* BUTTONS */
.kb-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    color: #fff !important;
    padding: 12px 32px !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    font-weight: 800 !important;
    cursor: pointer !important;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4) !important;
    transition: 0.3s !important;
    text-transform: uppercase !important;
    font-size: 13px !important;
}
.kb-btn-primary:hover { transform: translateY(-2px) !important; box-shadow: 0 15px 35px rgba(59, 130, 246, 0.5) !important; }

/* ADMIN DASHBOARD / STATS */
.kb-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    transition: 0.3s;
    backdrop-filter: blur(10px);
}
.kb-stat-card:hover { transform: translateY(-5px); background: var(--surface2); border-color: var(--accent); }
.kb-stat-val { font-size: 32px; font-weight: 900; color: var(--text); margin-bottom: 5px; }
.kb-stat-lbl { font-size: 13px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }

.kb-admin-table th { color: var(--text3); text-transform: uppercase; font-size: 11px; font-weight: 900; letter-spacing: 1px; }
.kb-admin-table tr { transition: 0.2s; }
.kb-admin-table tr:hover { background: rgba(59, 130, 246, 0.05); }

/* QUIZ EDITOR */
.kb-quiz-card-editor {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 30px;
    margin-bottom: 25px;
    transition: 0.3s;
}
.kb-quiz-card-editor:hover { background: var(--surface2); border-color: var(--accent); }
.kb-quiz-opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.kb-quiz-opt-item { 
    display: flex; 
    align-items: center; 
    background: var(--bg2); 
    border-radius: 14px; 
    border: 1px solid var(--border);
    overflow: hidden;
    transition: 0.2s;
}
.kb-quiz-opt-item:focus-within { border-color: rgba(59, 130, 246, 0.5); background: rgba(15, 23, 42, 0.6); }

.kb-quiz-mark-correct {
    width: 60px;
    height: 100%;
    border: none;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
    transition: 0.3s;
}
.kb-quiz-mark-correct:hover { background: rgba(59, 130, 246, 0.2); }
.kb-quiz-mark-correct.active { background: #10b981; color: #fff; border-color: #10b981; }

.kb-btn-glass, .kb-btn-glass-small {
    background: var(--surface2) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    padding: 10px 24px !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: 0.3s !important;
    font-size: 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}
.kb-btn-glass:hover, .kb-btn-glass-small:hover { background: rgba(51, 65, 85, 1) !important; transform: translateY(-2px) !important; border-color: rgba(59, 130, 246, 0.4) !important; }

.kb-btn-glass-small { width: 44px; height: 44px; padding: 0; flex-shrink: 0; }

.kb-btn-icon { background: none !important; border: none !important; cursor: pointer; opacity: 0.5; transition: 0.2s; color: #fff; }
.kb-btn-icon:hover { opacity: 1; transform: scale(1.1); color: #3b82f6; }
.kb-btn-icon.danger:hover { color: #ef4444; }

/* MISC */
.kb-art-title { color: #fff; font-weight: 800; font-size: 18px; margin-bottom: 4px; }

/* ANIMATIONS */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.8s ease-out forwards; }
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.kb-card { animation: fadeInUp 0.6s ease-out backwards; }
.kb-grid .kb-card:nth-child(1) { animation-delay: 0.1s; }
.kb-grid .kb-card:nth-child(2) { animation-delay: 0.2s; }
.kb-grid .kb-card:nth-child(3) { animation-delay: 0.3s; }
.kb-grid .kb-card:nth-child(4) { animation-delay: 0.4s; }
.kb-grid .kb-card:nth-child(5) { animation-delay: 0.5s; }
.kb-grid .kb-card:nth-child(n+6) { animation-delay: 0.6s; }

.kb-article-row { animation: fadeInUp 0.4s ease-out backwards; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.kb-articles-list .kb-article-row:nth-child(1) { animation-delay: 0.05s; }
.kb-articles-list .kb-article-row:nth-child(2) { animation-delay: 0.1s; }
.kb-articles-list .kb-article-row:nth-child(3) { animation-delay: 0.15s; }
.kb-articles-list .kb-article-row:nth-child(4) { animation-delay: 0.2s; }
.kb-articles-list .kb-article-row:nth-child(n+5) { animation-delay: 0.25s; }

.kb-breadcrumbs-bar { padding: 15px 32px; font-size: 13px; color: #64748b; font-weight: 700; }
.kb-crumb-link { cursor: pointer; transition: 0.2s; }
.kb-crumb-link:hover { color: #3b82f6; }
