/* ============================================================
   The Tech Pad — Admin AI settings & knowledge base
   Companion stylesheet for admin-ai.js. Matches the admin
   page + dashboard design system (green #087552, mint #badfce,
   borders #dfe7e3, white cards).
   ============================================================ */

.admin-ai {
  margin-top: 22px;
}

.admin-ai .section-heading {
  margin-bottom: 14px;
}

.admin-ai-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #dfe7e3;
  border-radius: 12px;
}

/* Active workspace (read-only label) — the switcher itself lives in the
   left menu (workspace-ui.css / .ws-switch); this page only confirms which
   workspace the AI settings below belong to. */
.ai-ws-current {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #50625b;
  background: #f5faf7;
  border: 1px solid #d8ebe2;
  border-radius: 999px;
}
.ai-ws-current b {
  font-size: 13.5px;
  font-weight: 800;
  color: #0d2b22;
}

.admin-ai-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-ai-grid {
    grid-template-columns: 1fr;
  }
}

.admin-ai-card {
  background: #fff;
  border: 1px solid #dfe7e3;
  border-radius: 12px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}

.admin-ai-card h3 {
  margin: 0;
  font-size: 15px;
  color: #10251e;
}

.admin-ai-card label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #50625b;
}

.admin-ai-card label small {
  font-weight: 400;
  color: #7d8a85;
}

.admin-ai-card input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.admin-ai-card select,
.admin-ai-card textarea {
  width: 100%;
  padding: 11px;
  font: inherit;
  font-size: 13px;
  color: #10251e;
  background: #fff;
  border: 1px solid #d4ded9;
  border-radius: 9px;
}

.admin-ai-card .ai-model-custom {
  margin-top: 8px;
}

.admin-ai-card textarea {
  resize: vertical;
  min-height: 70px;
}

.admin-ai-card input:focus,
.admin-ai-card select:focus,
.admin-ai-card textarea:focus {
  border-color: #28a977;
  box-shadow: 0 0 0 3px rgba(40, 169, 119, 0.09);
  outline: none;
}

.admin-ai-card button.primary {
  border: 0;
  background: #0d2b22;
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  align-self: start;
  justify-self: start;
}

.admin-ai-card button.primary:hover:not(:disabled) {
  background: #0a392d;
}

.admin-ai-card button.primary:disabled,
.admin-ai-card input:disabled,
.admin-ai-card select:disabled,
.admin-ai-card textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- enable toggle ---- */
.ai-toggle-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 9px !important;
  padding: 9px 11px;
  background: #f5faf7;
  border: 1px solid #d8ebe2;
  border-radius: 10px;
  cursor: pointer;
}

.ai-toggle-row input {
  width: 17px;
  height: 17px;
  accent-color: #0d392e;
  cursor: pointer;
}

/* ---- hints & status ---- */
.ai-key-hint {
  margin: 0;
  font-size: 12px;
  color: #7d8a85;
}

.ai-key-hint.ok {
  color: #087552;
  font-weight: 600;
}

.ai-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ai-status {
  font-size: 12px;
  font-weight: 600;
  color: #7d8a85;
}

.ai-status.ok {
  color: #087552;
}

.ai-status.error {
  color: #b3261e;
}

/* ---- knowledge base ---- */
.ai-kb-sub {
  margin: 0;
  font-size: 12px;
  color: #7d8a85;
}

.ai-kb-add {
  border: 1px solid #dfe7e3;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfdfc;
}

.ai-kb-add summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: #087552;
}

.ai-kb-add-form {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.ai-kb-import-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.ai-kb-import-url {
  flex: 1;
}

.ai-kb-import-row button {
  border: 1px solid #bfd3cc;
  background: #fff;
  color: #285e4e;
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ai-kb-import-row button:hover:not(:disabled) {
  background: #eefaf4;
}

/* ---- website crawl + file upload ---- */
.ai-kb-site-note {
  margin: -2px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #7d8a85;
}

.ai-kb-field {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #50625b;
}

.ai-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-file-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfd3cc;
  background: #fff;
  color: #285e4e;
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ai-file-btn:hover {
  background: #eefaf4;
}

.ai-file-btn input[type="file"] {
  display: none;
}

.ai-file-name {
  font-size: 12px;
  font-weight: 400;
  color: #7d8a85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-kb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.ai-kb-empty,
.ai-kb-loading {
  padding: 14px;
  text-align: center;
  font-size: 12.5px;
  color: #7d8a85;
  background: #fbfdfc;
  border: 1px dashed #dfe7e3;
  border-radius: 10px;
}

.ai-kb-warnbox {
  padding: 12px 14px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: #9a6700;
  background: #fff8e1;
  border: 1px solid #f0d98c;
  border-radius: 10px;
  list-style: none;
}

.ai-kb-item {
  padding: 10px 12px;
  background: #fbfdfc;
  border: 1px solid #e4ece8;
  border-radius: 10px;
  display: grid;
  gap: 4px;
}

.ai-kb-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-kb-head b {
  font-size: 13px;
  color: #10251e;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-kb-src {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0b5f40;
  background: #e2f5ec;
  border: 1px solid #badfce;
  border-radius: 999px;
  padding: 2px 8px;
}

.ai-kb-del {
  border: 0;
  background: transparent;
  color: #b3261e;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.ai-kb-del:hover {
  background: #fdeceb;
}

.ai-kb-url {
  font-size: 11px;
  color: #087552;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-kb-preview {
  margin: 0;
  font-size: 12px;
  color: #4a5a54;
  line-height: 1.45;
}

.ai-kb-date {
  font-size: 10.5px;
  color: #9aa8a2;
}

/* spinner while loading knowledge list */
.ai-kb-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 2px solid #cfe9dd;
  border-top-color: #087552;
  border-radius: 50%;
  animation: adminAiSpin 0.7s linear infinite;
}

@keyframes adminAiSpin {
  to { transform: rotate(360deg); }
}

/* Jump-link pill at the top of the admin page */
.ai-admin-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
  padding: 10px 18px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  background: #0d2b22;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.ai-admin-jump:hover {
  background: #0a392d;
}

.ai-status.warn {
  color: #9a6700;
}

/* Dedicated /wa/ai-settings route: hide the native dashboard content the
   SPA renders for unknown /wa/* paths (the overlay section IS the page),
   but keep the .topbar — on mobile it carries the hamburger that opens the
   sidebar drawer, so hiding it left the page with no way to navigate. */
body.ttp-ai-page .dashboard > *:not(#ttp-ai-root):not(.topbar) { display: none !important; }
#ttp-ai-root.ttp-ai-root { align-self: flex-start; max-width: 920px; width: 100%; }

/* ---- API key lock (write-only after save) ---- */
.ai-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ai-key-row input {
  flex: 1;
  min-width: 0;
}
.ai-key:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f2f6f4;
}
.ai-key-change {
  border: 1px solid #bfd3cc;
  background: #fff;
  color: #285e4e;
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.ai-key-change:hover {
  background: #eef5f2;
}

/* ---- KB page grouping (crawled pages) ---- */
.ai-kb-count {
  font-size: 10px;
  font-weight: 800;
  color: #74827c;
  background: #eef3f1;
  border: 1px solid #dfe8e4;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.ai-kb-recrawl {
  border: 1px solid #badfce;
  background: #e2f5ec;
  color: #0b5f40;
  border-radius: 999px;
  padding: 3px 10px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.ai-kb-recrawl:hover {
  background: #d0ecdf;
}
.ai-kb-page .ai-kb-preview {
  font-size: 11.5px;
  color: #5c6d66;
}
