/* Dash.io: layout e temas, tudo escopado em #dsh-app, prefixo .dsh-, tokens --dsh-*. 05/09/2026 */

.content {
  padding: 0 0;
}

#dsh-app {
  --dsh-fundo: #f4f5f7;
  --dsh-widget-bg: #ffffff;
  --dsh-borda: #e3e6ec;
  --dsh-raio: 10px;
  --dsh-sombra: 0 1px 2px rgba(20, 25, 40, .06);
  --dsh-ink: #1a1f2e;
  --dsh-muted: #6b7280;
  --dsh-acento: #1d4ed8;
  --dsh-fonte: "Inter", Arial, sans-serif;

  display: flex;
  flex-direction: column;
  height: calc(100vh - 1px);
  background: var(--dsh-fundo);
  color: var(--dsh-ink);
  font-family: var(--dsh-fonte);
}

#dsh-app[data-tema="operacional"] {
  --dsh-fundo: #eaf1fb;
  --dsh-widget-bg: #ffffff;
  --dsh-borda: #c3d4e8;
  --dsh-raio: 2px;
  --dsh-sombra: none;
  --dsh-ink: #10151f;
  --dsh-muted: #4b5563;
  --dsh-acento: #1d4ed8;
}

#dsh-app[data-tema="operacional"] .dsh-toolbar,
#dsh-app[data-tema="operacional"] .dsh-palette,
#dsh-app[data-tema="operacional"] .dsh-props {
  background: #dbe6f5;
}

#dsh-app[data-tema="executivo"] {
  --dsh-fundo: #0f1115;
  --dsh-widget-bg: #181b21;
  --dsh-borda: #262a33;
  --dsh-raio: 14px;
  --dsh-sombra: none;
  --dsh-ink: #f4f5f7;
  --dsh-muted: #9aa1af;
  --dsh-acento: #60a5fa;
}

#dsh-app * { box-sizing: border-box; }

#dsh-app .material-symbols-outlined svg {
  width: 1em; height: 1em; display: block; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Toolbar ---------- */

.dsh-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--dsh-widget-bg);
  border-bottom: 1px solid var(--dsh-borda);
}

.dsh-toolbar__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.dsh-title-icon { width: 24px; height: 24px; color: var(--dsh-acento); }

.dsh-title { font-size: 1.1rem; font-weight: 700; margin-right: 4px; }

.dsh-dashboard-name {
  border: 1px solid transparent;
  background: transparent;
  font-size: .95rem;
  font-weight: 600;
  color: var(--dsh-ink);
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 160px;
}

.dsh-dashboard-name:hover, .dsh-dashboard-name:focus {
  border-color: var(--dsh-borda);
  outline: none;
}

.dsh-select-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dsh-muted);
  font-size: .85rem;
}

.dsh-select-inline select {
  border: 1px solid var(--dsh-borda);
  background: var(--dsh-widget-bg);
  color: var(--dsh-ink);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: .85rem;
}

.dsh-btn {
  align-items: center;
  gap: 6px;
  border: 1px solid var(--dsh-borda);
  background: var(--dsh-widget-bg);
  color: var(--dsh-ink);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

.dsh-btn:not([hidden]) { display: inline-flex; align-items: center; }

.dsh-btn .material-symbols-outlined { display: inline-flex; }

.dsh-btn--ghost:hover { background: var(--dsh-fundo); }

.dsh-btn--primary {
  background: var(--dsh-acento);
  border-color: var(--dsh-acento);
  color: #fff;
}

.dsh-btn--primary:hover { filter: brightness(1.08); }

.dsh-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--dsh-muted);
  border-radius: 6px;
  cursor: pointer;
}

.dsh-iconbtn:hover { background: var(--dsh-fundo); color: var(--dsh-ink); }

.dsh-menu { position: relative; }

/* driver.js força overflow:hidden no pai do elemento destacado (evita scroll);
   isso corta o .dsh-menu__list, que vaza pra fora via position:absolute. 05/09/2026 */
.dsh-menu:has(> .driver-active-element) {
  overflow: visible !important;
}

.dsh-menu__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 200px;
  background: var(--dsh-widget-bg);
  border: 1px solid var(--dsh-borda);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 25, 40, .12);
  overflow: hidden;
}

.dsh-menu__list:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.dsh-menu__list button {
  border: none;
  background: transparent;
  color: var(--dsh-ink);
  text-align: left;
  padding: 9px 12px;
  font-size: .85rem;
  cursor: pointer;
}

.dsh-menu__list button:hover { background: var(--dsh-fundo); }

/* ---------- Corpo: paleta / canvas / propriedades ---------- */

.dsh-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.dsh-palette {
  width: 168px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-right: 1px solid var(--dsh-borda);
  background: var(--dsh-widget-bg);
  overflow-y: auto;
}

.dsh-palette__item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dsh-ink);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: .85rem;
  cursor: grab;
  text-align: left;
}

.dsh-palette__item:hover { background: var(--dsh-fundo); border-color: var(--dsh-borda); }

.dsh-canvas-wrap {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.dsh-canvas { min-height: 100%; }

.dsh-empty {
  position: absolute;
  inset: 16px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--dsh-muted);
  border: 2px dashed var(--dsh-borda);
  border-radius: var(--dsh-raio);
}

.dsh-empty:not([hidden]) { display: flex; }

.dsh-empty .material-symbols-outlined { width: 40px; height: 40px; }

.dsh-props {
  width: 260px;
  flex: 0 0 auto;
  border-left: 1px solid var(--dsh-borda);
  background: var(--dsh-widget-bg);
  overflow-y: auto;
  padding: 14px;
}

.dsh-props__empty { color: var(--dsh-muted); font-size: .85rem; }

.dsh-props__form:not([hidden]) { display: flex; flex-direction: column; gap: 14px; }

.dsh-props__section { display: flex; flex-direction: column; gap: 8px; }

.dsh-props__section h4 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--dsh-muted);
  font-weight: 700;
}

.dsh-field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; }

.dsh-field span { color: var(--dsh-muted); }

.dsh-field input, .dsh-field select, .dsh-field textarea {
  border: 1px solid var(--dsh-borda);
  background: var(--dsh-fundo);
  color: var(--dsh-ink);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: .85rem;
  font-family: inherit;
}

.dsh-field--row { flex-direction: row; align-items: center; justify-content: space-between; }

/* ---------- Widgets no grid ---------- */

.dsh-widget {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--dsh-widget-bg);
  border: 1px solid var(--dsh-borda);
  border-radius: var(--dsh-raio);
  box-shadow: var(--dsh-sombra);
  overflow: hidden;
}

.grid-stack-item.dsh-widget-selected > .grid-stack-item-content .dsh-widget {
  outline: 2px solid var(--dsh-acento);
  outline-offset: -1px;
}

.dsh-widget--sem-card {
  background: transparent;
  border: none;
  box-shadow: none;
}

.dsh-widget--sem-card .dsh-widget__head {
  position: absolute;
  top: 0; right: 0;
  padding: 2px;
  background: var(--dsh-widget-bg);
  border-radius: var(--dsh-raio);
}

.dsh-widget--sem-card .dsh-widget__titulo { display: none; }

.dsh-widget--sem-card .dsh-widget__body { padding: 0; }

/* Handles de resize sem ícone; só a borda acende no hover. 05/09/2026 */
.grid-stack-item > .ui-resizable-handle { background-image: none !important; }

.grid-stack-item:hover > .grid-stack-item-content .dsh-widget {
  outline: 2px solid var(--dsh-acento);
  outline-offset: -1px;
}

/* Desktop: o cabeçalho inteiro é o handle do GridStack — cursor sinaliza isso. 05/09/2026 */
.dsh-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--dsh-muted);
  cursor: grab;
}

.dsh-widget__head:active { cursor: grabbing; }

.dsh-widget__head-tools { display: flex; align-items: center; gap: 2px; }

.dsh-widget__actions { display: none; gap: 2px; cursor: default; }

.grid-stack-item.dsh-widget-selected .dsh-widget__actions { display: flex; }

.dsh-widget__drag { cursor: grab; touch-action: none; }

.dsh-widget__drag:active { cursor: grabbing; }

.dsh-widget__body { flex: 1; min-height: 0; padding: 6px 10px 10px; overflow: auto; }

.dsh-widget__body canvas { max-width: 100%; }

.dsh-kpi { display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 2px; }

.dsh-kpi__valor { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }

.dsh-kpi__desc { font-size: .78rem; color: var(--dsh-muted); }

.dsh-tabela { width: 100%; border-collapse: collapse; font-size: .8rem; }

.dsh-tabela th, .dsh-tabela td { padding: 5px 8px; border-bottom: 1px solid var(--dsh-borda); text-align: left; }

.dsh-tabela tbody tr:nth-child(even) { background: var(--dsh-fundo); }

.dsh-texto { height: 100%; overflow: auto; display: flex; flex-direction: column; }

.dsh-imagem { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.dsh-imagem img { max-width: 100%; max-height: 100%; }

/* ---------- Apresentação ---------- */

.dsh-apresentacao .dsh-toolbar,
.dsh-apresentacao .dsh-palette,
.dsh-apresentacao .dsh-props,
.dsh-apresentacao .dsh-mobile-fab,
.dsh-apresentacao .dsh-mobile-backdrop,
.dsh-apresentacao .dsh-widget__head-tools { display: none !important; }

.dsh-apresentacao .dsh-canvas-wrap { padding: 8px; }

.dsh-exit-presentacao {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  padding: 16px;
}

.dsh-exit-presentacao .dsh-btn {
  opacity: 0;
  transition: opacity .15s ease;
}

.dsh-exit-presentacao:hover .dsh-btn,
.dsh-exit-presentacao .dsh-btn:focus-visible {
  opacity: 1;
}

.dsh-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 45;
}

/* ---------- Modais / toasts ---------- */

.dsh-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, .5);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.dsh-modal-overlay:not([hidden]) { display: flex; }

.dsh-modal {
  width: min(720px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--dsh-widget-bg);
  color: var(--dsh-ink);
  border-radius: var(--dsh-raio);
  overflow: hidden;
}

.dsh-modal--sm { width: min(420px, 92vw); }

.dsh-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--dsh-borda);
}

.dsh-modal__body { padding: 16px; overflow-y: auto; }

.dsh-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--dsh-borda);
}

.dsh-toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.dsh-toast {
  background: var(--dsh-ink);
  color: var(--dsh-widget-bg);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

.dsh-toast--erro { background: #dc2626; color: #fff; }

/* ---------- Mobile: FAB e gaveta (mesmo padrão do Gram.io) ---------- */

.dsh-mobile-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--dsh-acento);
  color: #fff;
  box-shadow: 0 6px 18px rgba(20, 25, 40, .28);
  z-index: 8020;
  cursor: pointer;
}

.dsh-mobile-fab:not([hidden]) { display: flex; }

.dsh-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, .4);
  z-index: 8000;
}

.dsh-mobile-backdrop:not([hidden]) { display: block; }

/* ---------- Responsividade ---------- */

@media (max-width: 1100px) {
  .dsh-toolbar { flex-direction: column; align-items: stretch; }

  .dsh-toolbar__group:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .dsh-toolbar__group:last-child .dsh-select-inline { grid-column: 1 / -1; width: 100%; }

  .dsh-toolbar__group:last-child .dsh-select-inline select { flex: 1; width: 100%; }

  .dsh-toolbar__group:last-child .dsh-btn,
  .dsh-toolbar__group:last-child .dsh-menu { width: 100%; }

  .dsh-toolbar__group:last-child .dsh-btn { justify-content: center; }

  /* Dropdown centralizado sob o botão: em 2 colunas, left:0 vazaria da tela nos botões da coluna direita. 05/09/2026 */
  .dsh-toolbar__group:last-child .dsh-menu__list {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: min(200px, 90vw);
  }

  /* Painéis viram gaveta (bottom sheet); some enquanto fechada, abre por cima do backdrop. 05/09/2026 */
  .dsh-palette, .dsh-props {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: min(70vh, 520px);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(20, 25, 40, .2);
    transform: translateY(100%);
    transition: transform .2s ease;
    z-index: 8010;
  }

  #dsh-app.dsh-mobile-sheet--widgets .dsh-palette,
  #dsh-app.dsh-mobile-sheet--props .dsh-props {
    transform: translateY(0);
  }

  /* Mobile: card sem espaço vago pro vizinho (grid.js usa float:false) — só a
     alça sul de resize fica visível, redimensiona só a altura. 05/09/2026 */
  .grid-stack-item > .ui-resizable-e,
  .grid-stack-item > .ui-resizable-se,
  .grid-stack-item > .ui-resizable-sw,
  .grid-stack-item > .ui-resizable-w,
  .grid-stack-item > .ui-resizable-n,
  .grid-stack-item > .ui-resizable-ne,
  .grid-stack-item > .ui-resizable-nw {
    display: none !important;
  }

  /* Mobile: só o ícone arrasta, então o cabeçalho não deve sinalizar arrasto. 05/09/2026 */
  .dsh-widget__head, .dsh-widget__head:active { cursor: default; }
}
