/* ============================================================
   БАЗА ЗНАНИЙ
   ============================================================ */

#kbTabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.kb-tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  position: relative;
  border-bottom: 3px solid transparent;
}
.kb-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

#kbList { flex: 1; overflow-y: auto; }

.kb-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.kb-item:active { background: var(--bg-tertiary); }
.kb-item .kbtitle {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 6px;
}
.kb-item .kbtext {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-item .kbmeta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kb-item .kbphotos {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.kb-item .kbphotos img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}
.kb-item .kb-views { color: var(--accent); font-size: 12px; }

#kbView {
  display: none;
  flex-direction: column;
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 7;
  height: 100%;
}
#kbView.active { display: flex; }
#kbViewContent {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.kbv-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 8px;
}
.kbv-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.kbv-text {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 16px;
}
.kbv-photos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.kbv-photos img {
  width: 100%;
  border-radius: 12px;
  cursor: pointer;
}
.kbv-videos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.kbv-videos video {
  width: 100%;
  border-radius: 12px;
  background: #000;
}
.kbv-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.kbv-files a {
  display: block;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.kbv-files a:hover { background: var(--bg-tertiary); }

.kbv-stat-item {
  padding: 8px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.kbv-stat-item:last-child { border-bottom: none; }
.kbv-stat-item .name { font-size: 14px; }
.kbv-stat-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.kbv-stat-item .status { font-size: 18px; }
.kbv-stat-item .count {
  color: var(--accent);
  font-weight: bold;
  font-size: 14px;
}

#kbStatsModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 5000;
  padding: 20px;
}
#kbStatsModal.show { display: flex; }
#kbStatsModal .box {
  background: var(--bg-secondary);
  color: var(--text);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#kbStatsModal .box button {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text);
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
}

.kb-photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kb-photo-list .photo-item {
  position: relative;
  width: 80px;
  height: 80px;
}
.kb-photo-list .photo-item img,
.kb-photo-list .photo-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.kb-photo-list .photo-item .rm {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
}
.photo-upload-btn {
  width: 80px;
  height: 80px;
  border: 2px dashed var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 24px;
  cursor: pointer;
}