/* ══════════════════════════════════════════════════════════════════════════
   Modo embutido (Nextcloud › External sites) — ver embed.js.

   Tudo aqui está sob `html.embed`, classe que o embed.js só coloca quando a
   página roda dentro de um iframe. Fora dele nenhuma regra se aplica — menos o
   diálogo (.u2-dialog-*), que só existe no DOM em modo embutido.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Barra do topo: abas + conteúdo da página + botão de relatórios ───────── */
html.embed .embed-header {
  height: 44px;
  padding-left: 12px;
  padding-right: 12px;
  gap: 14px;
  box-shadow: none;
  justify-content: flex-start;
}
html.embed .embed-header > * { min-width: 0; }

html.embed .embed-tabs {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  flex-shrink: 0;
  gap: 2px;
  padding-right: 14px;
  border-right: 1px solid var(--u2-line);
}
html.embed .embed-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--u2-gray);
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
html.embed .embed-tab:hover { color: var(--u2-white); }
html.embed .embed-tab-active {
  color: var(--u2-white);
  border-bottom-color: var(--u2-red);
}

html.embed .embed-reports-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--u2-gray-light);
  background: var(--u2-panel-2);
  border: 1px solid var(--u2-line);
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
html.embed .embed-reports-btn:hover,
html.embed.embed-panel-open .embed-reports-btn {
  color: var(--u2-white);
  border-color: var(--u2-red);
}

/* ── A barra lateral vira um painel que desliza pela direita ──────────────── */
html.embed aside.embed-panel {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  width: 280px;
  max-width: 88vw;
  height: 100%;
  z-index: 60;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
  border-left: 1px solid var(--u2-line);
  box-shadow: -18px 0 40px rgba(0, 0, 0, .45);
}
html.embed.embed-panel-open aside.embed-panel {
  transform: none;
  visibility: visible;
  transition: transform .2s ease, visibility 0s;
}
/* antes de o embed.js montar o painel a barra lateral não pode piscar na tela */
html.embed body > aside:not(.embed-panel) { display: none; }

html.embed aside.embed-panel > div:has(> img) { display: none; }   /* logo: a marca já está no Nextcloud */
html.embed aside.embed-panel .embed-hidden { display: none; }
html.embed aside.embed-panel nav { padding-top: 4px; }
html.embed aside.embed-panel .embed-first { padding-top: 0; }
html.embed aside.embed-panel .embed-first > .border-t { display: none; }

html.embed .embed-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 44px;
  padding: 0 8px 0 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--u2-white);
  border-bottom: 1px solid var(--u2-line);
}
html.embed .embed-panel-close {
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  color: var(--u2-gray);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
html.embed .embed-panel-close:hover { color: var(--u2-white); background: var(--u2-panel-2); }

html.embed .embed-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
html.embed.embed-panel-open .embed-backdrop { opacity: 1; pointer-events: auto; }

/* ── Mobile (Nextcloud no celular) ────────────────────────────────────────────
   A página mobile aberta num iframe fica sob a barra do Nextcloud, então cada
   pixel de altura conta. Como no desktop: a marca já está na moldura, o cabeçalho
   encolhe e quem está a ver aparece no menu. A navegação continua no menu em
   gaveta — uma barra de abas fixa embaixo foi tentada e brigava com a caixa de
   texto do assistente. */
html.embed .mob-header > img { display: none; }
html.embed body { padding-top: 0 !important; }   /* o entalhe é do Nextcloud, não do iframe */
html.embed .mob-header { height: 44px; padding: 0 8px; gap: 8px; }
html.embed .mob-main { padding-top: 8px; }
html.embed .mob-drawer-title { display: flex; align-items: baseline; gap: 10px; }
html.embed .mob-drawer-title .embed-user {
  margin-left: 0;
  max-width: none;
  font-size: 12px;
  font-weight: 500;
}

/* ── Diálogo (substitui prompt/confirm dentro do iframe) ──────────────────── */
.u2-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .6);
}
.u2-dialog {
  width: 100%;
  max-width: 380px;
  padding: 20px;
  font-family: var(--u2-font, system-ui, sans-serif);
  color: var(--u2-white, #f4f4f2);
  background: var(--u2-panel, #161618);
  border: 1px solid var(--u2-line, #2a2a2e);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.u2-dialog-message { margin: 0 0 14px; font-size: 14px; line-height: 1.45; }
.u2-dialog-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--u2-white, #f4f4f2);
  background: var(--u2-black, #0a0a0b);
  border: 1px solid var(--u2-line, #2a2a2e);
  border-radius: 8px;
  outline: none;
}
.u2-dialog-input:focus { border-color: var(--u2-red, #e8262a); }
.u2-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.u2-dialog-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--u2-gray-light, #c9c9cf);
  background: var(--u2-panel-2, #1c1c20);
  border: 1px solid var(--u2-line, #2a2a2e);
  border-radius: 8px;
  cursor: pointer;
}
.u2-dialog-btn-primary {
  color: #fff;
  background: var(--u2-red, #e8262a);
  border-color: var(--u2-red, #e8262a);
}

/* o título do painel já diz "Relatórios": do cabeçalho da seção fica só o PT/EN */
html.embed aside.embed-panel .embed-first p { display: none; }
html.embed aside.embed-panel .embed-first > div:last-child { justify-content: flex-end; }

/* com a busca na barra, é ela que empurra para a direita; o botão vem colado */
html.embed #global-search + .embed-reports-btn { margin-left: 0; }

/* quem está a ver, segundo o token do Nextcloud */
html.embed .embed-user {
  flex-shrink: 1;
  min-width: 0;
  max-width: 180px;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--u2-gray);
}
html.embed #global-search + .embed-user { margin-left: 0; }
html.embed .embed-user + .embed-reports-btn { margin-left: 0; }

/* ── Idioma (i18n.js): seletor PT | EN e espera pela tradução ─────────────── */
html.i18n-pending body { visibility: hidden; }   /* evita o lampejo em português */

.u2-lang {
  display: inline-flex;
  flex-shrink: 0;
  margin-left: auto;
  padding: 2px;
  gap: 2px;
  background: var(--u2-panel-2, #1c1c20);
  border: 1px solid var(--u2-line, #2a2a2e);
  border-radius: 8px;
}
#global-search + .u2-lang { margin-left: 10px; }
.u2-lang-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--u2-gray, #8b8b93);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.u2-lang-btn:hover { color: var(--u2-white, #f4f4f2); }
.u2-lang-active { color: #fff; background: var(--u2-red, #e8262a); cursor: default; }
html.embed .u2-lang ~ .embed-user,
html.embed .u2-lang ~ .embed-reports-btn { margin-left: 0; }
.mob-header .u2-lang { margin-left: auto; margin-right: 8px; }
