
/* === Button: + icon text === */
.chip-plus {
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: inherit;
  flex-shrink: 0;
}

.chip-icon-lucide {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* === Title section — separated above editor === */
.ke-title-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.ke-title-label {
  font-size: 12px;
  font-weight: 600;
  color: #71717a;
  letter-spacing: 0.02em;
}

.ke-title-input {
  width: 100%;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  outline: none;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #18181b;
  padding: 9px 13px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.ke-title-input::placeholder {
  color: #c4c4c8;
  font-weight: 400;
}

.ke-title-input:focus {
  border-color: #a1a1aa;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

/* === Knowledge layout === */
.knowledge-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-width: 0;
  height: 480px;
  overflow: hidden;
}

/* .knowledge-sidebar no longer used - tabs live in .knw-nav-col */

.knowledge-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  padding: 0 6px;
}

.knowledge-tabs::-webkit-scrollbar { width: 3px; }
.knowledge-tabs::-webkit-scrollbar-track { background: transparent; }
.knowledge-tabs::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 99px; }

.knowledge-tab {
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #52525b;
  transition: all .12s ease;
  display: flex;
  align-items: center;
  gap: 7px;
}

.knowledge-tab:hover {
  background: #f4f4f5;
  color: #18181b;
}

.knowledge-tab.active {
  background: #f4f4f5;
  color: #000000;
  font-weight: 600;
}

.knowledge-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* === Knowledge page buttons === */
.page-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 110px;
  min-height: 86px;
  background: #ffffff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.page-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
  border-color: #d1d5db;
}
.page-btn.active {
  border-color: #18181b;
  color: #18181b;
  box-shadow: 0 6px 20px rgba(17, 17, 17, 0.12);
}
.page-btn .page-btn-icon {
  width: 22px;
  height: 22px;
  color: currentColor;
  stroke-width: 1.8;
}
.page-btn .page-btn-label {
  color: inherit;
  font-size: 13px;
}

.page-btn.knowledge-tab {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  width: 100%;
  min-width: 0;
  min-height: auto;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #52525b;
  box-shadow: none;
  text-align: left;
  transform: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.page-btn.knowledge-tab:hover {
  transform: none;
  box-shadow: none;
  border-color: transparent;
  background: #f0f0f0;
  color: #18181b;
  transition: background 0.18s ease;
}

.page-btn.knowledge-tab .page-btn-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.page-btn.knowledge-tab .page-btn-label {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-btn.knowledge-tab.active {
  border-color: #d4d4d8;
  background: #ffffff;
  color: #000000;
  font-weight: 600;
}

.page-btn.knowledge-tab.active:hover {
  background: #ffffff;
  border-color: #d4d4d8;
}

#saveContext {
  background-color: #18181b;
  color: #ffffff;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  transition: background 0.15s;
}
#saveContext:hover {
  background-color: #27272a;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.chip-icon svg {
  width: 13px;
  height: 13px;
}

.chip-label {
  display: inline-block;
}

/* === Editor container — altura fija, scroll interno === */
.knowledge-editor {
  position: relative;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 480px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.knowledge-editor-delete {
  position: absolute;
  top: -40px;
  right: 0px;
  z-index: 2;
}

/* === Source URL bar — now inline in footer === */
#knowledgeUrlMeta {
  flex-shrink: 0;
  gap: 5px;
  font-size: 11px;
  color: #a1a1aa;
}

#knowledgeCurrentUrl {
  color: #18181b;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
  display: inline-block;
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 10.5px;
}

/* === Toolbar === */
.rt-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid #e4e4e7;
  background: #fafafa;
  margin: 0;
  flex-shrink: 0;
  border-radius: 0;
}

.rt-group {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
}

.rt-sep {
  width: 1px;
  height: 24px;
  background: #e4e4e7;
}

.rt-btn {
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #3f3f46;
  transition: background .12s ease, border-color .12s ease;
}

.rt-btn svg {
  width: 14px;
  height: 14px;
}

.rt-btn:hover {
  background: #f4f4f5;
  border-color: #e4e4e7;
}

.rt-btn:active {
  transform: translateY(1px);
}

.rt-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(17,24,39,.15);
}

.rt-btn.is-active,
.rt-btn[aria-pressed="true"] {
  background: #18181b;
  border-color: #18181b;
  color: #fff;
}

.rt-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* === Editable area — altura fija, scroll interno === */
.ke-area {
  background: #fff;
  height: 360px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  outline: none;
  font-size: 13.5px;
  line-height: 1.7;
  color: #27272a;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d8 transparent;
}

.ke-area::-webkit-scrollbar { width: 4px; }
.ke-area::-webkit-scrollbar-track { background: transparent; }
.ke-area::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 99px; }

.ke-area:empty:before {
  content: attr(data-placeholder);
  color: #a1a1aa;
}

/* === Editor footer (counter + save) === */
.ke-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid #e4e4e7;
  background: #fafafa;
  flex-shrink: 0;
}

.ke-footer #ctxCounter {
  font-size: 11px;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ke-footer #ctxCounter b {
  font-weight: 600;
  color: #71717a;
}

.ke-counter-sep {
  color: #d4d4d8;
  font-size: 10px;
}

/* === Fix Tailwind preflight para listas y títulos === */
.ke-area ul {
  list-style: disc;
  list-style-position: outside;
  padding-left: 1.25rem;
  margin: 0.35rem 0 0.5rem;
}

.ke-area ol {
  list-style: decimal;
  list-style-position: outside;
  padding-left: 1.25rem;
  margin: 0.35rem 0 0.5rem;
}

.ke-area li {
  margin: 0.15rem 0;
}

.ke-area h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0.65rem 0 0.25rem;
  color: #18181b;
}

.ke-area h3:first-child {
  margin-top: 0;
}

/* === Sidebar URL meta === */
#knowledgeSidebarMeta {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  font-size: 11px;
  color: #71717a;
}

@media (max-width: 900px) {
  .knowledge-layout {
    flex-direction: column;
    gap: 14px;
  }

  .knowledge-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
}

/* === Action buttons (+ Página, + Sitio web) === */
.btn-outline-dark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #d4d4d8;
  background: #fff;
  color: #18181b;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-outline-dark:hover {
  background: #f4f4f5;
  border-color: #a1a1aa;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  background: #18181b;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.btn-primary:hover {
  background: #27272a;
}

/* === Delete button inside tab === */
.page-btn.knowledge-tab {
  position: relative;
}

.kt-delete-btn {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.12s ease, color 0.12s ease;
  padding: 0;
}

.page-btn.knowledge-tab:hover .kt-delete-btn {
  opacity: 1;
}

.kt-delete-btn:hover {
  background: #fee2e2 !important;
  color: #ef4444 !important;
}

.page-btn.knowledge-tab.active .kt-delete-btn {
  color: rgba(255,255,255,0.5);
}

.page-btn.knowledge-tab.active .kt-delete-btn:hover {
  background: rgba(255,255,255,0.15) !important;
  color: #fff !important;
}

/* === Tab delete button (hover reveal) === */
.knowledge-tab-delete {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  padding: 0;
}

.page-btn.knowledge-tab:hover .knowledge-tab-delete {
  opacity: 1;
  pointer-events: auto;
}

.page-btn.knowledge-tab.active .knowledge-tab-delete {
  color: rgba(255,255,255,0.5);
}

.page-btn.knowledge-tab.active:hover .knowledge-tab-delete {
  opacity: 1;
  pointer-events: auto;
}

.knowledge-tab-delete:hover {
  color: #ef4444 !important;
  background: rgba(239,68,68,0.12) !important;
}

.page-btn.knowledge-tab.active .knowledge-tab-delete:hover {
  color: #fca5a5 !important;
  background: rgba(239,68,68,0.25) !important;
}

/* === Source badge === */
.ke-source-box {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 5px 10px;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  font-size: 11px;
  color: #71717a;
  overflow: hidden;
}

.ke-source-label {
  font-weight: 500;
  flex-shrink: 0;
  color: #a1a1aa;
}

.ke-source-box a {
  color: #2563eb;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 10.5px;
}
.ke-source-box a:hover { text-decoration: underline; }

.ke-text-badge {
  justify-content: center;
  color: #71717a;
  font-weight: 500;
}
