/* Identidade dopme.io — Framedraw / Excalidraw (sobrepõe tokens do upstream). */

:root {
  --fd-brand-deep: #4c1d95;
  --fd-brand-violet: #6d28d9;
  --fd-brand-indigo: #6366f1;
  --fd-brand-purple: #a855f7;
  --fd-brand-fuchsia: #e879f9;
  --fd-brand-amber: #f59e0b;
  --fd-footer-height: 3.25rem;
  --fd-footer-row-height: 2.875rem;
  --fd-toolbar-height: 2.875rem;
  --fd-wordmark-gradient: linear-gradient(
    90deg,
    #4c1d95 0%,
    #7c3aed 28%,
    #a855f7 48%,
    #f59e0b 88%,
    #fb923c 100%
  );
}

.framedraw-canvas-wrap,
.framedraw-root,
.fd-host .framedraw-app {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Fundo dopme.io no canvas (substitui grelha quadriculada) */
.framedraw-canvas-wrap {
  background-color: #eef2ff;
  background-image: var(--fd-page-bg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

html[data-theme="dark"] .framedraw-canvas-wrap,
.framedraw-canvas-wrap .excalidraw.theme--dark {
  background-color: #12101c;
  background-image: var(--fd-page-bg-dark);
}

.framedraw-canvas-wrap .excalidraw .excalidraw-container {
  background: transparent !important;
}

.framedraw-canvas-wrap .excalidraw {
  --color-primary: var(--fd-brand-violet);
  --color-primary-darker: #5b21b6;
  --color-primary-darkest: var(--fd-brand-deep);
  --color-primary-light: var(--fd-brand-purple);
  height: 100% !important;
  width: 100% !important;
}

.framedraw-canvas-wrap .excalidraw .excalidraw-container {
  height: 100% !important;
  background: transparent !important;
}

.framedraw-canvas-wrap .excalidraw.theme--dark {
  --color-primary: var(--fd-brand-purple);
  --color-primary-darker: var(--fd-brand-violet);
  --color-primary-darkest: #4c1d95;
  --color-primary-light: var(--fd-brand-fuchsia);
}

.framedraw-canvas-wrap .excalidraw .App-toolbar .ToolIcon_type_radio:checked + .ToolIcon__icon,
.framedraw-canvas-wrap .excalidraw .App-toolbar .ToolIcon_type_button[aria-pressed="true"] .ToolIcon__icon {
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.22) 0%,
    rgba(168, 85, 247, 0.18) 55%,
    rgba(245, 158, 11, 0.12) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.35);
}

.framedraw-canvas-wrap .excalidraw .Island {
  box-shadow:
    0 4px 24px rgba(91, 33, 182, 0.08),
    0 1px 3px rgba(15, 23, 42, 0.06);
}

.framedraw-canvas-wrap .excalidraw .dropdown-menu-button:hover,
.framedraw-canvas-wrap .excalidraw .dropdown-menu-button:active {
  background: linear-gradient(
    90deg,
    rgba(99, 102, 241, 0.12) 0%,
    rgba(168, 85, 247, 0.1) 100%
  );
}

.framedraw-canvas-wrap .fd-welcome-logo {
  font-family: "Inter", system-ui, sans-serif;
  font-style: italic;
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  background: var(--fd-wordmark-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.framedraw-canvas-wrap .excalidraw .welcome-screen-decor {
  color: var(--fd-brand-violet);
}

/* ---------- Layout dopme.io: ocultar menu, biblioteca e ajuda ---------- */

.framedraw-canvas-wrap .excalidraw .main-menu-trigger,
.framedraw-canvas-wrap .excalidraw .layer-ui__wrapper__top-right,
.framedraw-canvas-wrap .excalidraw .sidebar-trigger,
.framedraw-canvas-wrap .excalidraw .default-sidebar-trigger,
.framedraw-canvas-wrap .excalidraw .help-icon,
.framedraw-canvas-wrap .excalidraw .welcome-screen-decor--help,
.framedraw-canvas-wrap .excalidraw .layer-ui__wrapper__footer-left,
.framedraw-canvas-wrap .excalidraw .zoom-actions,
.framedraw-canvas-wrap .excalidraw .undo-redo-buttons,
.framedraw-canvas-wrap .excalidraw .App-menu_top__left > *:not(.selected-shape-actions) {
  display: none !important;
}

/* Barra superior colapsada — toolbar ancorada no rodapé via CSS (permanece na árvore React) */
.framedraw-canvas-wrap .excalidraw .App-menu_top {
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  pointer-events: none;
  border: none !important;
}

/* ---------- Toolbar no rodapé (position: fixed — sem mover DOM) ---------- */

.framedraw-canvas-wrap .excalidraw .shapes-section {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(
    var(--fd-footer-row-center, 2.25rem) - (var(--fd-toolbar-height, 2.875rem) / 2)
  ) !important;
  transform: translateX(-50%) !important;
  z-index: 45 !important;
  width: max-content !important;
  max-width: min(42rem, calc(100vw - 8rem));
  opacity: 1 !important;
  pointer-events: auto !important;
  --ui-pointerEvents: auto;
}

.framedraw-canvas-wrap .excalidraw .shapes-section > div {
  position: static !important;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .HintViewer {
  display: none !important;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .App-toolbar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  box-sizing: border-box;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .App-toolbar-content {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 0.125rem;
  padding: 0 !important;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .Stack_horizontal {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.125rem;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .ToolIcon {
  flex: 0 0 auto;
}

.framedraw-canvas-wrap .excalidraw .shapes-section .Island.App-toolbar {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
}

[data-theme="dark"] .framedraw-canvas-wrap .excalidraw .shapes-section .Island.App-toolbar,
.framedraw-canvas-wrap .excalidraw.theme--dark .shapes-section .Island.App-toolbar {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Mais ferramentas — abrir para cima (toolbar no rodapé) */
.framedraw-canvas-wrap .excalidraw .shapes-section .App-toolbar__extra-tools-dropdown {
  top: auto !important;
  bottom: 100% !important;
  margin-top: 0 !important;
  margin-bottom: 0.375rem !important;
}

/* ---------- Propriedades das formas (painel flutuante e arrastável) ---------- */

html.fd-shape-props-open.fd-shape-props-anchored .framedraw-canvas-wrap .excalidraw section.selected-shape-actions {
  position: fixed !important;
  left: var(--fd-shape-props-left, 50%) !important;
  top: var(--fd-shape-props-top, auto) !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 48 !important;
  width: max-content !important;
  max-width: min(16rem, calc(100vw - 2rem)) !important;
  pointer-events: auto !important;
  display: block !important;
  margin: 0 !important;
}

.framedraw-canvas-wrap .excalidraw section.selected-shape-actions {
  display: none !important;
}

html.fd-shape-props-open .framedraw-canvas-wrap .excalidraw section.selected-shape-actions {
  display: block !important;
}

html.fd-shape-props-open.fd-shape-props-anchored .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  width: 12.5rem !important;
  max-width: min(16rem, calc(100vw - 2rem)) !important;
  background: var(--island-bg-color, rgba(255, 255, 255, 0.96)) !important;
  border: 1px solid var(--default-border-color, rgba(99, 102, 241, 0.14)) !important;
  border-radius: 0.5rem !important;
  box-shadow:
    0 8px 32px rgba(91, 33, 182, 0.12),
    0 2px 8px rgba(15, 23, 42, 0.08) !important;
  max-height: min(70dvh, 28rem) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  cursor: grab;
  touch-action: none;
}

html.fd-shape-props-dragging .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left {
  cursor: grabbing;
}

html.fd-shape-props-open .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left button,
html.fd-shape-props-open .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left input,
html.fd-shape-props-open .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left label,
html.fd-shape-props-open .framedraw-canvas-wrap .excalidraw section.selected-shape-actions .Island.App-menu__left a {
  cursor: pointer;
}

html.fd-shape-props-dragging,
html.fd-shape-props-dragging body {
  user-select: none;
}

html[data-theme="dark"] .framedraw-canvas-wrap .excalidraw .selected-shape-actions .Island.App-menu__left,
.framedraw-canvas-wrap .excalidraw.theme--dark .selected-shape-actions .Island.App-menu__left {
  background: rgba(28, 25, 46, 0.98) !important;
  border-color: rgba(129, 140, 248, 0.22) !important;
}

/* Chevron (drop) — retângulo, losango, elipse e demais ferramentas com painel */
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape.fillable .ToolIcon__icon,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-rectangle"]) .ToolIcon__icon,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-diamond"]) .ToolIcon__icon,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-ellipse"]) .ToolIcon__icon,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-text"]) .ToolIcon__icon {
  position: relative;
}

.framedraw-canvas-wrap .excalidraw .fd-tool-drop-btn {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 3;
  width: 0.6875rem;
  height: 0.6875rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0.125rem;
  background: transparent;
  color: var(--icon-fill-color, currentColor);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0.82;
  -webkit-tap-highlight-color: transparent;
}

.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has(input:checked) .fd-tool-drop-btn {
  color: var(--color-on-primary-container, #312e81);
  opacity: 1;
}

.framedraw-canvas-wrap .excalidraw .fd-tool-drop-btn::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 0.19rem solid transparent;
  border-right: 0.19rem solid transparent;
  border-top: 0.22rem solid currentColor;
}

.framedraw-canvas-wrap .excalidraw .fd-tool-drop-btn:hover,
.framedraw-canvas-wrap .excalidraw .fd-tool-drop-btn:focus-visible {
  background: rgba(99, 102, 241, 0.14);
  outline: none;
  opacity: 1;
}

.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape.fillable:has(.fd-tool-drop-btn) .ToolIcon__keybinding,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-rectangle"]):has(.fd-tool-drop-btn) .ToolIcon__keybinding,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-diamond"]):has(.fd-tool-drop-btn) .ToolIcon__keybinding,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-ellipse"]):has(.fd-tool-drop-btn) .ToolIcon__keybinding,
.framedraw-canvas-wrap .excalidraw .ToolIcon.Shape:has([data-testid="toolbar-text"]):has(.fd-tool-drop-btn) .ToolIcon__keybinding {
  right: 0.9rem;
  bottom: 3px;
}

/* Espaço reservado no rodapé para alinhar visualmente com a toolbar fixa */
.fd-footer-toolbar-slot {
  height: var(--fd-footer-row-height, 2.875rem);
  min-height: var(--fd-footer-row-height, 2.875rem);
  visibility: hidden;
  pointer-events: none;
}

/* Rodapé — modo escuro (data-theme no html) */
html[data-theme="dark"] .fd-footer {
  border-top-color: rgba(129, 140, 248, 0.22);
  background: linear-gradient(
    180deg,
    rgba(28, 25, 46, 0.96) 0%,
    rgba(18, 16, 30, 0.98) 100%
  );
  color: #c4b5fd;
}

@media (max-width: 720px) {
  .framedraw-canvas-wrap .excalidraw .shapes-section {
    max-width: calc(100vw - 5.25rem);
  }

  .framedraw-canvas-wrap .excalidraw .shapes-section .App-toolbar-content {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .framedraw-canvas-wrap .excalidraw .shapes-section .App-toolbar-content::-webkit-scrollbar {
    display: none;
  }
}
