/* Sythax IA Dock — vanilla (espelha @sythax/ia-dock React) */

/* —— Layout split (app PME): workspace scroll + painel IA fixo na viewport —— */
.ss-app-workspace-row {
  display: block;
  flex: 1;
  min-width: 0;
}

.ss-app-workspace-main {
  min-width: 0;
  transition: margin-right 0.22s ease;
}

body.ss-ia-dock-split-open .ss-app-workspace-main {
  margin-right: min(440px, 42vw);
}

/* Painel fixo: da topbar até a base da TELA (viewport), independente do scroll da página */
.ss-ia-dock-slot {
  display: none;
}

body.ss-ia-dock-split-open .ss-ia-dock-slot {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: calc(var(--ss-utility-bar-h) + var(--ss-topbar-h));
  right: 0;
  bottom: 0;
  width: min(440px, 42vw);
  height: calc(100dvh - var(--ss-utility-bar-h) - var(--ss-topbar-h));
  max-height: calc(100dvh - var(--ss-utility-bar-h) - var(--ss-topbar-h));
  z-index: 85;
  border-left: 1px solid rgba(226, 232, 240, 0.95);
  background: #fff;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

#ss-ia-dock-root.ss-ia-dock-root--split {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.ss-ia-dock-panel--split {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  z-index: 1;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  box-shadow: none;
  border-left: 0;
}

/* —— FAB (help / overlay) —— */
.ss-ia-dock-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 999px;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.22);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.ss-ia-dock-fab:hover {
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.28);
  transform: translateY(-1px);
}

.ss-ia-dock-fab-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  font-size: 1rem;
}

.ss-ia-dock-fab.is-processing .ss-ia-dock-fab-icon {
  animation: ss-ia-spin 0.8s linear infinite;
}

@keyframes ss-ia-spin {
  to { transform: rotate(360deg); }
}

/* —— Painel overlay (help) —— */
.ss-ia-dock-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9001;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  max-height: 100dvh;
  border-left: 1px solid rgba(226, 232, 240, 0.95);
  background: #fff;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.06);
}

.ss-ia-dock-panel[hidden] {
  display: none !important;
}

.ss-ia-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.ss-ia-dock-header-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ss-ia-dock-header-main strong {
  display: block;
  font-size: 0.875rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-ia-dock-header-main small {
  display: block;
  font-size: 10px;
  color: #64748b;
}

.ss-ia-dock-header-actions {
  display: flex;
  gap: 2px;
}

.ss-ia-dock-header-actions button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  color: #64748b;
  cursor: pointer;
}

.ss-ia-dock-header-actions button:hover {
  background: #f1f5f9;
  color: #7c3aed;
}

.ss-ia-dock-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.ss-ia-dock-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 8px 12px 10px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
}

.ss-ia-dock-tab.is-active {
  border-bottom-color: #7c3aed;
  color: #6d28d9;
}

.ss-ia-dock-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ss-ia-dock-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ss-ia-dock-empty {
  border: 1px solid #ede9fe;
  border-radius: 16px;
  background: rgba(237, 233, 254, 0.45);
  padding: 16px;
  text-align: center;
}

.ss-ia-dock-empty strong {
  display: block;
  margin-top: 8px;
  font-size: 0.875rem;
  color: #1e293b;
}

.ss-ia-dock-empty p {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: #64748b;
}

.ss-ia-dock-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ss-ia-dock-msg--user {
  margin-left: auto;
  background: #7c3aed;
  color: #fff;
}

.ss-ia-dock-msg--assistant {
  background: #f1f5f9;
  color: #1e293b;
}

.ss-ia-dock-msg-meta {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.65;
}

.ss-ia-dock-suggestions {
  border-top: 1px solid #f8fafc;
  padding: 8px 16px;
  flex-shrink: 0;
}

.ss-ia-dock-suggestions p {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.ss-ia-dock-suggestions div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ss-ia-dock-suggestions button {
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  background: #f5f3ff;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  color: #4c1d95;
  cursor: pointer;
}

.ss-ia-dock-suggestions button:hover {
  background: #ede9fe;
}

.ss-ia-dock-compose {
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
  padding: 12px;
  background: #fff;
}

.ss-ia-dock-compose-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.85);
  padding: 8px 12px;
}

.ss-ia-dock-compose textarea {
  flex: 1;
  min-height: 44px;
  max-height: 112px;
  border: 0;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 0.875rem;
  color: #1e293b;
  outline: none;
}

.ss-ia-dock-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
}

.ss-ia-dock-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ss-ia-dock-footer {
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
  padding: 8px 16px;
  text-align: center;
  font-size: 10px;
  line-height: 1.4;
  color: #94a3b8;
}

.ss-ia-dock-history {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.ss-ia-dock-history-item {
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.ss-ia-dock-history-item:hover {
  border-color: #ddd6fe;
  background: rgba(237, 233, 254, 0.35);
}

.ss-ia-dock-history-item strong {
  display: block;
  font-size: 0.8125rem;
  color: #1e293b;
}

.ss-ia-dock-history-item small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}

.ss-ia-dock-error {
  margin: 8px 16px 0;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fef2f2;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #b91c1c;
  flex-shrink: 0;
}

body.ss-ia-dock-open .ss-ia-dock-fab {
  display: none;
}

body.ss-ia-dock-split .ss-ia-dock-fab {
  display: none !important;
}

/* Topbar — botão Sythax IA */
.ss-topbar-ia-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(99, 102, 241, 0.06));
  color: #5b21b6;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.ss-topbar-ia-btn:hover {
  border-color: rgba(124, 58, 237, 0.55);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.ss-topbar-ia-btn.is-active {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
}

.ss-topbar-ia-glyph {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.15);
  font-size: 0.75rem;
}

.ss-topbar-ia-btn.is-active .ss-topbar-ia-glyph {
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 900px) {
  .ss-topbar-ia-label {
    display: none;
  }

  body.ss-ia-dock-split-open .ss-ia-dock-slot {
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
  }

  body.ss-ia-dock-split-open .ss-app-workspace-main {
    margin-right: 0;
  }
}

@media (max-width: 640px) {
  .ss-ia-dock-fab-label {
    display: none;
  }
}
