/* Copilot do shell: janela flutuante (assistente geral) ou fixo na lateral direita (Copilot do módulo). */

.bcp-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  width: 380px;
  height: min(640px, calc(100vh - 40px));
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.18), 0 2px 8px rgba(17, 24, 39, 0.08);
  font-family: Inter, system-ui, sans-serif;
  color: #111827;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.bcp-panel.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.bcp-header {
  cursor: move;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid #f1f2f4;
}

.bcp-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bcp-title > .material-icons {
  font-size: 20px;
  color: #1a73e8;
  flex-shrink: 0;
}

.bcp-title strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.bcp-title > div {
  min-width: 0;
}

.bcp-subtitle {
  display: block;
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.bcp-header-actions {
  display: flex;
  gap: 4px;
}

.bcp-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bcp-icon-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.bcp-icon-btn .material-icons {
  font-size: 20px;
}

.bcp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bcp-msg {
  font-size: 13px;
  line-height: 1.5;
  max-width: 100%;
}

.bcp-msg.user {
  display: flex;
  justify-content: flex-end;
}

.bcp-msg.user .bcp-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
  background: #1b3a6b;
  color: #fff;
  word-break: break-word;
}

.bcp-md p {
  margin: 0 0 8px;
}

.bcp-md p:last-child {
  margin-bottom: 0;
}

.bcp-md .bcp-heading {
  font-weight: 600;
  margin-top: 10px;
}

.bcp-md ul,
.bcp-md ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.bcp-md li {
  margin: 2px 0;
}

.bcp-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 4px;
}

.bcp-table-wrap {
  overflow-x: auto;
  margin: 4px 0 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.bcp-table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.bcp-table-wrap th,
.bcp-table-wrap td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #f1f2f4;
  white-space: nowrap;
}

.bcp-table-wrap th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

.bcp-table-wrap tr:last-child td {
  border-bottom: 0;
}

.bcp-chart {
  margin: 8px 0 4px;
  padding: 12px 12px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.bcp-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #6b7280;
}

.bcp-chart figcaption strong {
  font-size: 13px;
  color: #111827;
}

.bcp-chart-total {
  flex-basis: 100%;
  font-weight: 600;
  color: #1b3a6b;
}

.bcp-chart-max {
  font-size: 10px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.bcp-chart-plot {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  border-top: 1px dashed #e5e7eb;
  border-bottom: 1px solid #d1d5db;
}

.bcp-chart-col {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}

.bcp-chart-bar {
  display: block;
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: #1b3a6b;
}

.bcp-chart-col:hover .bcp-chart-bar {
  background: #2d5aa0;
}

.bcp-chart-bar.is-empty {
  height: 0;
}

.bcp-chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: #9ca3af;
}

.bcp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.bcp-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #d2e3fc;
  border-top-color: #1a73e8;
  animation: bcp-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes bcp-spin {
  to {
    transform: rotate(360deg);
  }
}

.bcp-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
}

.bcp-error .material-icons {
  font-size: 18px;
}

.bcp-actions {
  margin-top: 10px;
  border: 1px solid #d2e3fc;
  background: #f4f8fe;
  border-radius: 10px;
  padding: 12px;
}

.bcp-actions.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.bcp-actions.partial {
  border-color: #fecaca;
  background: #fff7f7;
}

.bcp-actions.cancelled {
  border-color: #e5e7eb;
  background: #f9fafb;
  opacity: 0.8;
}

.bcp-actions-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1967d2;
  margin-bottom: 8px;
}

.bcp-actions.done .bcp-actions-title {
  color: #15803d;
}

.bcp-actions ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bcp-actions li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
}

.bcp-actions li .material-icons {
  font-size: 17px;
  color: #8ab4f8;
  margin-top: 1px;
}

.bcp-actions li.ok .material-icons {
  color: #16a34a;
}

.bcp-actions li.fail .material-icons {
  color: #dc2626;
}

.bcp-actions li.skipped .material-icons {
  color: #9ca3af;
}

.bcp-actions li .bcp-action-body {
  flex: 1 1 auto;
  min-width: 0;
}

.bcp-bp {
  padding: 10px 12px 12px;
  border: 1px solid #dbe5f5;
  border-radius: 8px;
  background: #fff;
}

.bcp-bp-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bcp-bp-emoji {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eef3fb;
  font-size: 19px;
  line-height: 1;
}

.bcp-bp-head strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  color: #111827;
}

.bcp-bp-kicker {
  display: block;
  font-size: 11px;
  color: #6b7280;
}

.bcp-bp-desc {
  margin: 8px 0 0;
  font-size: 12px;
  color: #4b5563;
}

.bcp-bp-label {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bcp-bp-phases {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 2px;
}

.bcp-bp-phase {
  padding: 3px 8px;
  border: 1px solid #dbe5f5;
  border-radius: 6px;
  background: #f4f8fe;
  font-size: 12px;
  font-weight: 500;
  color: #1b3a6b;
  white-space: nowrap;
}

.bcp-bp-phase.is-final {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.bcp-actions li .bcp-bp-arrow {
  font-size: 16px;
  margin: 0;
  color: #9ca3af;
}

.bcp-bp-or {
  padding: 0 4px;
  font-size: 11px;
  color: #9ca3af;
}

.bcp-bp-fields {
  border: 1px solid #f1f2f4;
  border-radius: 6px;
}

.bcp-bp-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 8px;
  font-size: 12px;
  color: #111827;
}

.bcp-bp-field + .bcp-bp-field {
  border-top: 1px solid #f1f2f4;
}

.bcp-bp-field em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 11px;
  color: #6b7280;
}

.bcp-bp-req {
  margin-left: 2px;
  color: #dc2626;
  font-weight: 600;
}

.bcp-bp-note {
  margin-top: 8px;
  font-size: 11px;
  color: #6b7280;
}

.bcp-actions li small {
  display: block;
  color: #b91c1c;
  font-size: 12px;
}

.bcp-actions-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.bcp-btn {
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
}

.bcp-btn-ghost {
  background: #fff;
  border-color: #e5e7eb;
  color: #374151;
}

.bcp-btn-ghost:hover {
  background: #f3f4f6;
}

.bcp-btn-primary {
  background: #1b3a6b;
  color: #fff;
}

.bcp-btn-primary:hover {
  background: #142d52;
}

.bcp-actions-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
}

.bcp-actions-note.ok {
  color: #15803d;
  font-weight: 500;
}

.bcp-actions-note.fail {
  color: #b91c1c;
  font-weight: 500;
}

.bcp-empty {
  margin: auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
}

.bcp-empty > .material-icons {
  font-size: 28px;
  color: #1a73e8;
}

.bcp-empty strong {
  font-size: 14px;
}

.bcp-empty p {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6b7280;
  max-width: 320px;
}

.bcp-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.bcp-suggestions button {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-family: inherit;
  color: #374151;
  cursor: pointer;
}

.bcp-suggestions button:hover {
  border-color: #aecbfa;
  background: #f4f8fe;
}

.bcp-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.bcp-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 10px 4px 8px;
  border: 1px solid #dbe5f5;
  border-radius: 999px;
  background: #f4f8fe;
  color: #1b3a6b;
  font: 500 12px/1.3 inherit;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.bcp-source:hover {
  border-color: #aecbfa;
  background: #e8f0fd;
}

.bcp-source .material-icons {
  font-size: 15px;
  color: #1a73e8;
  flex-shrink: 0;
}

.bcp-article {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.bcp-article-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f2f4;
}

.bcp-article-title {
  font-size: 14px;
  line-height: 1.3;
  min-width: 0;
}

.bcp-article-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 20px;
  font-size: 13px;
  line-height: 1.55;
}

.bcp-article-body .bcp-md .bcp-heading {
  margin-top: 16px;
  font-size: 13.5px;
}

.bcp-article-body .bcp-md .bcp-heading.is-target {
  color: #1a73e8;
}

.bcp-memories-hint {
  margin: 0 0 14px;
  color: #5f6368;
}

.bcp-memories-empty,
.bcp-memories-count {
  margin: 0;
  color: #80868b;
  font-size: 12px;
}

.bcp-memories-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.bcp-memories-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #f1f3f4;
}

.bcp-memories-list li:last-child {
  border-bottom: 1px solid #f1f3f4;
}

.bcp-memories-list li span:first-child {
  flex: 1;
  padding-top: 4px;
}

.bcp-memories .bcp-error {
  margin-bottom: 12px;
}

.bcp-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 14px;
  padding: 6px 6px 6px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  transition: border-color 0.15s;
}

.bcp-composer:focus-within {
  border-color: #1b3a6b;
  box-shadow: 0 0 0 3px #e6eef7;
}

.bcp-composer textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 20px;
  padding: 5px 0;
  box-sizing: border-box;
  height: 30px;
  min-height: 30px;
  max-height: 160px;
  overflow-y: auto;
  background: transparent;
  color: #111827;
}

.bcp-send {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: #1b3a6b;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bcp-send:disabled {
  background: #cbd5e1;
  cursor: default;
}

.bcp-send .material-icons {
  font-size: 18px;
}

.bcp-footnote {
  margin: 6px 0 12px;
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
}


.bcp-open-board {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 10px;
}

.bcp-actions li .bcp-open-board .material-icons {
  font-size: 14px;
  color: inherit;
  margin: 0;
}

.sidebar-btn.sidebar-copilot-btn.is-open {
  background-color: rgba(255, 255, 255, 0.2);
}

.sidebar-copilot-tag {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.sidebar-copilot-tag.hidden {
  display: none;
}

html.aidesk-sidebar-collapsed .sidebar-copilot-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  padding: 0;
  font-size: 0;
  box-shadow: 0 0 0 1.5px var(--primary-color);
}

/* Alças de redimensionar: bordas e cantos. */
.bcp-resize {
  position: absolute;
  z-index: 2;
  touch-action: none;
}

.bcp-resize-n,
.bcp-resize-s {
  left: 12px;
  right: 12px;
  height: 6px;
  cursor: ns-resize;
}

.bcp-resize-n { top: 0; }
.bcp-resize-s { bottom: 0; }

.bcp-resize-e,
.bcp-resize-w {
  top: 12px;
  bottom: 12px;
  width: 6px;
  cursor: ew-resize;
}

.bcp-resize-e { right: 0; }
.bcp-resize-w { left: 0; }

.bcp-resize-ne,
.bcp-resize-nw,
.bcp-resize-se,
.bcp-resize-sw {
  width: 14px;
  height: 14px;
}

.bcp-resize-ne { top: 0; right: 0; cursor: nesw-resize; }
.bcp-resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.bcp-resize-nw { top: 0; left: 0; cursor: nwse-resize; }
.bcp-resize-se { bottom: 0; right: 0; cursor: nwse-resize; }

/* Durante o arrasto: sem animação e sem os iframes "roubarem" o ponteiro. */
body.bcp-dragging .bcp-panel {
  transition: none;
}

body.bcp-dragging,
body.bcp-dragging * {
  user-select: none;
}

body.bcp-dragging iframe {
  pointer-events: none;
}

/* Copilot do módulo: fixo na lateral direita, encolhe a tela em vez de cobrir. */
.bcp-panel.is-docked {
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: var(--bcp-dock-width, 340px);
  height: 100vh;
  max-width: none;
  border: 0;
  border-left: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: none;
  transform: translateX(16px);
  transform-origin: right center;
}

.bcp-panel.is-docked.open {
  transform: none;
}

.bcp-panel.is-docked .bcp-header {
  cursor: default;
}

.bcp-panel.is-docked .bcp-subtitle {
  max-width: none;
}

.bcp-panel.is-docked .bcp-resize:not(.bcp-resize-w) {
  display: none;
}

.bcp-panel.is-docked .bcp-resize-w {
  top: 0;
  bottom: 0;
}

body.bcp-docked .aidesk-module-host {
  margin-right: var(--bcp-dock-width, 340px);
}

@media (max-width: 760px) {
  .bcp-resize {
    display: none;
  }

  body.bcp-docked .aidesk-module-host {
    margin-right: 0;
  }

  .bcp-panel.is-docked {
    width: 100vw;
    border-left: 0;
  }

  .bcp-header {
    cursor: default;
  }

  .bcp-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
  }
}
