/* ───────────────────────────────────────────────
   BOT-EDITOR ADD-ONS • Forms / Knowledge / Logs
   (No global layout / modal / tab overrides)
───────────────────────────────────────────────── */

/* ========= 1. SETTINGS FORM & INPUTS ========== */

.cb-settings-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  padding: 26px 16px 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(80, 140, 200, 0.06);
  margin-bottom: 18px;
  width: 100%;
  flex: 1 0 auto;
  min-height: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.cb-row-top4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 18px;
}

.cb-row-hdrpreview {
  display: flex;
  align-items: flex-start;
  gap: 44px;
  margin-bottom: 22px;
}

.cb-hdrcolors-col {
  flex: 1 1 400px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.cb-hdrcolors-col label.cb-form-label {
  width: 100%;
}

.cb-hdrcolors-row {
  display: flex;
  gap: 22px;
  margin-top: 7px;
}

.cb-bot-preview-wrap {
  flex: 0 0 340px;
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
}

.cb-row-wide {
  width: 100%;
  margin-bottom: 18px;
}

.cb-row-wide:last-child {
  margin-bottom: 0;
}

.cb-form-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 600;
  color: #25374c;
  font-size: 1.09em;
  margin-bottom: 0;
}

.cb-field,
.cb-field-color {
  border: 1.6px solid #ccd6e3;
  border-radius: 8px;
  background: #f7fafd;
  font-size: 1.05rem;
  transition: border 0.14s, box-shadow 0.14s;
  padding: 13px 16px;
  margin-top: 3px;
  margin-bottom: 0;
}

.cb-field:focus,
.cb-field-color:focus {
  border-color: var(--cb-accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(26, 188, 156, 0.18);
  outline: none;
}

.cb-field-color {
  width: 60px;
  height: 38px;
  padding: 0 2px;
  border-radius: 7px;
  box-shadow: 0 0 0 1.5px #d0e3e8 inset;
  cursor: pointer;
  margin-right: 12px;
}

.cb-field-color:hover {
  box-shadow: 0 0 0 3px var(--cb-accent, #2563eb)55 inset;
}

.cb-color-wrap {
  display: flex;
  align-items: center;
  gap: 0.6em;
  flex: 1;
}

.cb-color-sample {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: var(--cb-accent, #2563eb);
  display: inline-block;
  margin-left: 0.5em;
}

.cb-save-btn {
  background: #468ef9;
  color: #fff;
  border: none;
  padding: 16px 54px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.13rem;
  cursor: pointer;
  box-shadow: 0 1px 8px rgba(70, 142, 249, 0.12);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.12s;
  display: block;
  margin: 30px auto 0 auto;
}

.cb-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 24px rgba(70, 142, 249, 0.17);
}

.cb-save-btn:active {
  transform: translateY(1.5px) scale(0.97);
  box-shadow: 0 2px 6px rgba(70, 142, 249, 0.07);
  filter: brightness(0.96);
}

/* Responsive layout for top row / preview */
@media (max-width: 900px) {
  .cb-row-top4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }

  .cb-row-hdrpreview {
    flex-direction: column;
    gap: 18px;
  }

  .cb-bot-preview-wrap {
    max-width: 100%;
    width: 100%;
    min-width: 0;
    margin-top: 16px;
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .cb-row-top4 {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .cb-hdrcolors-row {
    flex-direction: column;
    gap: 11px;
  }
}

/* Small helper text */
.cb-form-label small {
  color: #7a7d88;
  font-size: 0.97em;
  margin-top: 3px;
  display: block;
}

/* Welcome Message input */
.cb-welcome-msg-row {
  margin-bottom: 14px;
}

.cb-welcome-msg-input,
.cb-settings-form input[name='welcome_message'].cb-field {
  width: 100%;
  border: 1.5px solid #ccd6e3;
  border-radius: 8px;
  background: #f7fafd;
  padding: 12px 16px;
  font-size: 1.05rem;
  transition: border 0.14s, box-shadow 0.14s, background 0.14s;
  box-sizing: border-box;
}

.cb-settings-form input[name='welcome_message'].cb-field {
  padding: 8px 12px;
}

.cb-welcome-msg-input:focus,
.cb-settings-form input[name='welcome_message'].cb-field:focus {
  border-color: var(--cb-accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(26, 188, 156, 0.18);
  background: #fff;
  outline: none;
}

/* ========= 2. BOT PREVIEW CARD ========== */

.cb-bot-preview {
  border: 1px solid #e5e9f2;
  border-radius: 8px;
  max-width: 320px;
  width: 100%;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  font-size: 14px;
  overflow: hidden;
  background: #fff;
}

.cb-bot-preview .cb-header {
  background: var(--header-color, var(--cb-accent, #2563eb));
  color: #fff;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
}

.cb-bot-preview .cb-body {
  background: #fff;
}

.cb-bot-preview .cb-input input {
  width: 100%;
  border: 0;
  padding: 0.5rem 0.75rem;
  font-size: inherit;
}

.cb-bot-preview .msg {
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  margin: 0.3rem 0.75rem 0.3rem 1rem;
}

.cb-bot-preview .msg.bot {
  background: #f2f4f7;
}

.cb-bot-preview .msg.user {
  background: var(--button-color, var(--cb-accent, #2563eb));
  color: #fff;
  margin-left: 0.75rem;
  margin-right: 1rem;
}

/* ========= 3. AVATAR ROW PATCHES ========== */

#cb-avatar-group .cb-field[type='url'] {
  margin-right: 6px;
}

#cb-avatar-group {
  display: flex !important;
  align-items: center !important;
  gap: 15px !important;
  width: 100% !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
}

#cb-avatar-group .cb-form-label {
  width: 100% !important;
}

#cb-avatar-group > label > div,
#cb-avatar-group > .cb-form-label > div {
  display: flex !important;
  gap: 15px !important;
  align-items: center !important;
  width: 100% !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
}

#cb-avatar-group input[name='avatar_url'] {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

#cb-avatar-group .cb-set-default-avatar {
  flex: 0 0 auto !important;
}

#cb-avatar-preview {
  flex: 0 0 auto !important;
  width: 40px !important;
  height: 40px !important;
}

/* Bot avatar URL field */
.cb-settings-form input[name='avatar_url'].cb-field[type='url'] {
  border: 1.5px solid #c3c8d1;
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 1.05em;
  background: #fafbfc;
  transition: border 0.17s, background 0.17s;
  min-width: 0;
}

.cb-settings-form input[name='avatar_url'].cb-field[type='url']:focus {
  border-color: var(--cb-accent, #2563eb);
  background: #fff;
  outline: none;
}

/* Default Avatar Button */
.cb-set-default-avatar {
  border: 1.5px solid #c3c8d1;
  background: #f8fafd;
  color: #166765;
  font-weight: 500;
  border-radius: 7px;
  padding: 6px 16px 6px 13px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.15s, border 0.17s, color 0.16s;
  margin-left: 2px;
  box-shadow: 0 1px 4px rgba(24, 140, 126, 0.04);
}

.cb-set-default-avatar:hover,
.cb-set-default-avatar:focus {
  background: #e2fcf6;
  border-color: var(--cb-accent, #2563eb);
  color: #138d80;
  outline: none;
}

/* ========= 4. S3 TOGGLE / NOTICE / INPUTS ========== */

.cb-s3-toggle-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
}

.cb-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  margin-right: 10px;
  vertical-align: middle;
}

.cb-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cb-switch .slider {
  position: absolute;
  inset: 0;
  background: #ccd1dc;
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 0 0 1px #ddd1;
}

.cb-switch .slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 4px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.22s cubic-bezier(0.55, 1.4, 0.7, 1), background 0.17s;
  box-shadow: 0 1px 6px #0001;
}

.cb-switch input:checked + .slider {
  background: var(--cb-accent, #2563eb);
}

.cb-switch input:checked + .slider:before {
  transform: translateX(22px);
  background: #fff;
}

.cb-switch-label {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  width: 100%;
  font-weight: 500;
}

.cb-s3-global-indicator {
  color: #198b52;
  background: #eafdf5;
  border-radius: 8px;
  padding: 9px 13px;
  margin: 10px 0 0;
  font-weight: 600;
  font-size: 0.97em;
  text-align: center;
}

.cb-s3-fields {
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

.cb-s3-fields-inner {
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 22px 14px 18px 14px;
  border: 1.5px solid #e5e9f2;
  border-radius: 12px;
  background: #f8fafb;
  min-width: 0;
  max-width: 390px;
  width: 100%;
  margin-top: 3px;
}

.cb-s3-fields-inner label {
  font-weight: 600;
  color: #264158;
  font-size: 1.05em;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cb-s3-fields-inner input {
  margin-top: 2px;
  border: 1.2px solid #ccd6e3;
  border-radius: 7px;
  padding: 11px 13px;
  background: #fff;
  font-size: 1.04em;
  transition: border 0.13s;
}

.cb-s3-fields-inner input:focus {
  border: 1.5px solid var(--cb-accent, #2563eb);
  outline: none;
}

.cb-s3-save-btn {
  margin-top: 16px;
  background: #468ef9;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-weight: 700;
  font-size: 1.09em;
  padding: 12px 36px;
  cursor: pointer;
  box-shadow: 0 1px 8px rgba(70, 142, 249, 0.11);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.12s;
  align-self: flex-end;
}

.cb-s3-save-btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 3px 12px rgba(70, 142, 249, 0.15);
}

.cb-s3-save-btn:active {
  transform: scale(0.97);
  box-shadow: 0 1px 3px rgba(70, 142, 249, 0.1);
  filter: brightness(0.96);
}

/* ========= 5. KNOWLEDGE CENTER TABLE & UPLOAD ========== */

.cb-doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.01rem;
}

.cb-doc-table th,
.cb-doc-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e8f0;
}

.cb-doc-table th {
  font-weight: 600;
  text-align: left;
  color: #495666;
}

.cb-doc-table .cb-icon {
  text-align: center;
  font-size: 1.18rem;
}

.cb-doc-table .cb-del {
  text-align: center;
  cursor: pointer;
  color: #ff5a5f;
}

.cb-doc-table .cb-del:hover {
  color: #d82f3d;
}

.cb-button-upload {
  background: var(--cb-accent, #2563eb);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-weight: 700;
  padding: 9px 19px;
  font-size: 1.06em;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(26, 188, 156, 0.09);
  transition: background 0.13s, box-shadow 0.13s;
}

.cb-button-upload:hover {
  background: #179a7c;
  box-shadow: 0 4px 16px rgba(26, 188, 156, 0.18);
}

.cb-dropzone {
  background: #f6f9fa;
  border: 2.2px dashed var(--cb-accent, #2563eb);
  border-radius: 9px;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 12px;
  position: relative;
}

.cb-dropzone-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60px;
  font-size: 1.08em;
  color: #289e8b;
  font-weight: 600;
  pointer-events: none;
}

.cb-dropzone-hover {
  outline: 2.5px dashed #468ef9;
  background: #eaf4ff;
}

.cb-dropzone-hint {
  display: none;
  text-align: center;
  color: #468ef9;
  font-weight: 600;
}

.cb-upload-message {
  background-color: #f2f2f2;
  padding: 15px;
  border: 1px solid #ccc;
  margin-top: 20px;
  font-size: 14px;
  color: #f39c12;
}

.cb-api-key-status {
  margin-left: 10px;
  color: #19aa5a;
  font-weight: 600;
}

.cb-field.cb-has-key {
  border-color: #19aa5a;
}

/* Overlay for blocking uploads (but not delete) */
.cb-dropzone-overlay-blocked {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
  pointer-events: none;
}

.cb-dropzone.cb-dropzone-blocked .cb-dropzone-overlay-blocked {
  display: block;
}

.cb-dropzone-blocked {
  pointer-events: auto !important;
}

/* Doc icon + delete button style */
.cb-doc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f5faff;
  border-radius: 7px;
  border: 1px solid #e1eefa;
  width: 32px;
  height: 32px;
  box-shadow: 0 1px 3px #21c99c13;
  margin-right: 2px;
}

.cb-doc-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff6f5;
  border: 1.5px solid #efc4c2;
  color: #d83c3c;
  border-radius: 7px;
  padding: 6px 12px 6px 10px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, border 0.15s, color 0.13s;
  margin: 0 2px;
}

.cb-doc-del-btn:hover {
  background: #ffeaea;
  border-color: #d83c3c;
  color: #b11515;
  box-shadow: 0 2px 8px #fbeaea99;
}

.cb-doc-del-btn svg {
  margin: 0 0 -2px 0;
  pointer-events: none;
}

/* Icon buttons with SVG */
.cb-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 1.05em;
  border-radius: 7px;
  transition: background 0.15s, box-shadow 0.15s, color 0.13s;
}

.cb-button-primary.cb-btn-icon svg,
.cb-button-danger.cb-btn-icon svg {
  color: #fff;
}

.cb-btn-icon svg {
  display: inline-block;
  margin-right: 7px;
  margin-left: 0;
  height: 20px;
  width: 20px;
}

/* Website crawl editor Save/Delete sizing */
#cb-doc-save.cb-button-primary.cb-btn-icon,
#cb-doc-del.cb-button-danger.cb-btn-icon {
  padding: 6px 16px !important;
  font-size: 1em !important;
  border-radius: 7px !important;
  min-width: 0 !important;
  width: auto !important;
  margin: 0 6px 0 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
  box-sizing: border-box !important;
  border: none !important;
  cursor: pointer !important;
  transition: background 0.13s, box-shadow 0.15s, color 0.13s;
}

#cb-doc-save.cb-button-primary.cb-btn-icon {
  background: #21b899 !important;
  color: #fff !important;
}

#cb-doc-save.cb-button-primary.cb-btn-icon:hover {
  background: #179a7c !important;
}

#cb-doc-del.cb-button-danger.cb-btn-icon {
  background: #d64e3c !important;
  color: #fff !important;
}

#cb-doc-del.cb-button-danger.cb-btn-icon:hover {
  background: #b63224 !important;
}

#cb-doc-save.cb-button-primary.cb-btn-icon:active {
  background: #17806d !important;
  filter: brightness(0.97);
  transform: scale(0.97);
}

#cb-doc-del.cb-button-danger.cb-btn-icon:active {
  background: #a32519 !important;
  filter: brightness(0.97);
  transform: scale(0.97);
}

/* ========= 6. CHAT LOGS / ANALYTICS TAB ========== */

.cb-chatlogs-tab {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  height: 100%;
}

.cb-logs-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 36px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 20px !important;
  background: #fff !important;
  border-radius: 16px !important;
  box-shadow: 0 1px 12px rgba(24, 120, 120, 0.07) !important;
}

.cb-stat-block {
  background: #f7fafb;
  border: 1.5px solid #e0e7ef;
  border-radius: 9px;
  padding: 22px 36px 14px 36px;
  font-size: 1.15em;
  font-weight: 700;
  color: #196c56;
  min-width: 170px;
  box-shadow: 0 2px 9px rgba(30, 184, 140, 0.08);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.cb-stat-block .cb-stat-label {
  font-size: 0.99em;
  color: #455f66;
  font-weight: 500;
  margin-top: 3px;
}

.cb-chart-wrap {
  flex: 1 1 390px;
  background: #fff;
  border-radius: 9px;
  border: 1.5px solid #e0e7ef;
  box-shadow: 0 2px 8px rgba(30, 184, 140, 0.05);
  min-height: 230px;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 24px;
}

.cb-chart-wrap canvas {
  width: 100% !important;
  max-width: 100%;
  height: 280px !important;
  max-height: 340px;
}

.cb-session-table,
.cb-msg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.06em;
  margin-bottom: 18px;
  background: #fafbfd;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(70, 142, 249, 0.06);
}

.cb-session-table th,
.cb-session-table td,
.cb-msg-table th,
.cb-msg-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #e5e8f0;
}

.cb-session-table th,
.cb-msg-table th {
  font-weight: 600;
  background: #f5f9fa;
  color: #25856c;
  text-align: left;
}

.cb-session-table tr:last-child td,
.cb-msg-table tr:last-child td {
  border-bottom: none;
}

.cb-msg-table .cb-msg-role {
  font-weight: 700;
  color: #138b6b;
  padding-right: 7px;
  min-width: 62px;
  display: inline-block;
}

.cb-msg-table .cb-msg-user {
  color: #1a6ad8;
}

.cb-msg-table .cb-msg-bot {
  color: var(--cb-accent, #2563eb);
}

.cb-msg-table .cb-msg-rag {
  background: #e8fbe7;
  color: #176a32;
  font-size: 0.96em;
  border-radius: 5px;
  padding: 2px 7px;
  margin-left: 8px;
  font-weight: 500;
}

.cb-msg-table .cb-msg-fallback {
  background: #fff3e2;
  color: #d89317;
  font-size: 0.96em;
  border-radius: 5px;
  padding: 2px 7px;
  margin-left: 8px;
  font-weight: 500;
}

.cb-session-table tr.cb-session-row {
  cursor: pointer;
  transition: background 0.12s;
}

.cb-session-table tr.cb-session-row:hover {
  background: #eafaf4;
}

.cb-log-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.cb-log-search {
  border: 1.5px solid #ccd6e3;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 1.03em;
  background: #f8fafd;
  min-width: 170px;
}

.cb-log-sort {
  border: 1.3px solid #ccd6e3;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 1em;
  background: #fafbfd;
  color: #196c56;
}

.cb-log-pager {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
}

.cb-log-pager button {
  background: #e8f9f2;
  color: #15b47b;
  border: 1px solid #c2e6da;
  border-radius: 6px;
  padding: 4px 13px;
  font-weight: 600;
  font-size: 1.04em;
  margin: 0 1px;
  cursor: pointer;
  transition: background 0.11s, color 0.11s;
}

.cb-log-pager button:disabled {
  opacity: 0.55;
  background: #f3f3f3;
  color: #a1a1a1;
  cursor: not-allowed;
}

.cb-log-pager .cb-page-info {
  margin: 0 7px;
  font-size: 0.98em;
  color: #557;
}

@media (max-width: 900px) {
  .cb-logs-summary {
    flex-direction: column;
    gap: 19px;
  }

  .cb-chart-wrap {
    max-width: 100%;
    min-width: 0;
    padding: 18px 3vw;
  }
}

@media (max-width: 650px) {
  .cb-chatlogs-tab {
    gap: 11px;
  }

  .cb-logs-summary,
  .cb-stat-block,
  .cb-chart-wrap {
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
    max-width: 100vw;
    padding: 12px 6px;
  }

  .cb-session-table,
  .cb-msg-table {
    font-size: 0.98em;
    padding: 0 1px;
  }
}

/* ========= 7. MISC ========= */

.cb-usage-banner div {
  line-height: 1.4;
}

/* Extra breathing room for settings action row (mobile too) */
.cb-settings-actions-row {
  padding-bottom: 30px !important;
}

/* ========= 8. FULL-WIDTH TAB CONTENT FIX ========= */
/* Make all tab panels use the full available width in the editor content area */

.cb-editor-tabs,
.cb-editor-content,
.cb-tab-panel,
.cb-panel-inner {
  width: 100% !important;
  max-width: 100% !important;
}

/* Remove auto-centering and give consistent horizontal padding */
.cb-panel-inner {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 32px !important;
  padding-right: 32px !important;
  box-sizing: border-box !important;
}

/* Slightly tighter padding on small screens */
@media (max-width: 700px) {
  .cb-panel-inner {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}
/* test styling */
.cb-modal.cb-editor {
  position: fixed !important;
  inset: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
}

.cb-modal.cb-editor .cb-modal-body {
  display: flex !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  box-sizing: border-box;
}

.cb-modal.cb-editor .cb-modal-layout {
  display: flex !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
}

/* ───────────────────────────────────────────────
   BOT LAYOUT OVERRIDES
   (replace previous cb-layout-form overrides)
───────────────────────────────────────────────── */

/* Make the entire editor content area gray on the tab that has the bot layout */
.cb-panel-inner:has(.cb-layout-form) {
  background: #efefef;
}

/* Bot Layout form: transparent (so we see the gray behind it),
   plus some padding inside */
.cb-layout-form {
  background: transparent;
  padding: 18px 18px 24px;
  margin: 0;
}

/* Stretch form to full height of panel so gray fills down to the bottom */
.cb-panel-inner .cb-layout-form {
  min-height: calc(100vh - 160px);
}

/* Remove outer border/background from the first layout section
   (the wrapper around Launcher + Chat Widget) so only the inner
   cards have outlines */
.cb-layout-form > .cb-layout-section:first-of-type {
  border: none !important;
  background: transparent !important;
  padding-left: 0;
  padding-right: 0;
}

/* Make the first row's columns (launcher + chat) stretch to the same height */
.cb-layout-form .cb-layout-section:first-of-type > div {
  align-items: stretch !important;
}

/* Inner cards for Launcher and Chat: equal height + subtle shadow */
.cb-layout-form .cb-launcher-col > div,
.cb-layout-form .cb-chat-col > div {
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ------------------------------------------------------------------
 * v4.6.2 editor layout fail-safe
 * ------------------------------------------------------------------
 * The legacy /chat-bot-management page can be wrapped by themes/builders.
 * These rules keep the editor modal and grouped settings form full-width and
 * fully styled even when the surrounding page has narrow containers.
 */
body.core-bots-dashboard-context .cb-modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 2147483000 !important;
  background: rgba(15,18,20,.6) !important;
}
body.core-bots-dashboard-context .cb-modal-overlay > .cb-modal.cb-editor,
body.core-bots-dashboard-context .cb-modal.cb-editor {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  border-radius: 0 !important;
  background: #fff !important;
  z-index: 2147483001 !important;
}
body.admin-bar.core-bots-dashboard-context .cb-modal-overlay > .cb-modal.cb-editor,
body.admin-bar.core-bots-dashboard-context .cb-modal.cb-editor {
  top: 32px !important;
  height: calc(100vh - 32px) !important;
}
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-modal-layout,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-modal-body,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-content,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-tabs,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-tab-panel,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-panel-inner,
body.core-bots-dashboard-context .cb-modal.cb-editor #cb-bot-settings-form {
  max-width: none !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-modal-body {
  overflow: auto !important;
  -webkit-overflow-scrolling: touch !important;
}
@media (max-width: 782px) {
  body.admin-bar.core-bots-dashboard-context .cb-modal-overlay > .cb-modal.cb-editor,
  body.admin-bar.core-bots-dashboard-context .cb-modal.cb-editor {
    top: 46px !important;
    height: calc(100vh - 46px) !important;
  }
}

/* ------------------------------------------------------------------
 * v4.6.2.1 secondary editor navigation fail-safe
 * ------------------------------------------------------------------
 * The secondary bot editor menu is injected by assets/bot-editor.js.
 * Some themes/page builders reset button/nav defaults aggressively, which can
 * make the menu render as raw browser buttons at the top of the page. These
 * scoped rules keep the editor navigation styled and anchored inside the Core
 * Bots editor modal.
 */
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-modal-layout {
  display: grid !important;
  grid-template-columns: 248px minmax(0, 1fr) !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
  background: #f7fafc !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav.cb-desktop-nav {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  width: 248px !important;
  min-width: 248px !important;
  max-width: 248px !important;
  height: 100% !important;
  padding: 24px 14px !important;
  margin: 0 !important;
  border-right: 1px solid #e5edf5 !important;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%) !important;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.04) !important;
  position: relative !important;
  z-index: 2 !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-btn,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav button.cb-tab-btn {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 48px !important;
  padding: 12px 14px !important;
  margin: 0 !important;
  border: 1px solid transparent !important;
  border-radius: 16px !important;
  background: transparent !important;
  color: #334155 !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  text-align: left !important;
  text-decoration: none !important;
  box-shadow: none !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-btn:hover {
  background: var(--cb-accent-softest, #eff6ff) !important;
  color: var(--cb-accent-text, #1e40af) !important;
  border-color: var(--cb-accent-border, #bfdbfe) !important;
  transform: translateX(2px) !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-btn.active {
  background: #ffffff !important;
  color: var(--cb-accent-text, #1e40af) !important;
  border-color: var(--cb-accent-border, #bfdbfe) !important;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.12) !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  border-radius: 10px !important;
  background: #eef2f7 !important;
  color: currentColor !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-btn.active .cb-tab-icon,
body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-btn:hover .cb-tab-icon {
  background: #dff8f2 !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav .cb-tab-icon svg {
  width: 18px !important;
  height: 18px !important;
  display: block !important;
  stroke: currentColor !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-tab-indicator {
  display: none !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-content {
  min-width: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  background: #ffffff !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-tabs {
  height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  background: #ffffff !important;
}

body.core-bots-dashboard-context .cb-modal.cb-editor .cb-mobile-nav {
  display: none !important;
}

@media (max-width: 900px) {
  body.core-bots-dashboard-context .cb-modal.cb-editor .cb-modal-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }

  body.core-bots-dashboard-context .cb-modal.cb-editor .cb-editor-nav.cb-desktop-nav {
    display: none !important;
  }

  body.core-bots-dashboard-context .cb-modal.cb-editor .cb-mobile-nav {
    position: sticky !important;
    top: 0 !important;
    z-index: 4 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 10px 12px !important;
    margin: 0 !important;
    overflow-x: auto !important;
    background: rgba(255, 255, 255, .96) !important;
    border-bottom: 1px solid #e5edf5 !important;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06) !important;
    box-sizing: border-box !important;
  }

  body.core-bots-dashboard-context .cb-modal.cb-editor .cb-mobile-nav .cb-mobile-nav-btn {
    appearance: none !important;
    -webkit-appearance: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    min-width: max-content !important;
    padding: 9px 11px !important;
    border: 1px solid #dbe6ef !important;
    border-radius: 999px !important;
    background: #fff !important;
    color: #334155 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05) !important;
  }

  body.core-bots-dashboard-context .cb-modal.cb-editor .cb-mobile-nav .cb-mobile-nav-btn.active {
    background: #10b981 !important;
    border-color: #10b981 !important;
    color: #fff !important;
  }
}
