/* BeeBot — moldura comum (redesenho U1). Servida estática em /ui/moldura.css (backend/src/ui/servir.js).
   Só forma: tokens da Central (backend/src/central/central.css, B30/B33), topo como o da Central com o menu colmeia
   (o /central/nav.js da Central, sem alterações; D-02, 02/12/2026), barra de baixo no telemóvel.
   Vem DEPOIS do <style> do painel, por isso os tokens daqui ganham (mesma especificidade, mais tarde).
   A ponte faz os tokens antigos (--bb-* e os de 2024: --bg2, --border, --accent…) apontarem para os da Central:
   as telas ainda não redesenhadas mudam de cor com o tema sem se mexer no CSS delas. */

/* ── Tokens da Central (claro) — os mesmos valores de central.css ─────────── */
:root {
  color-scheme: light;
  --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #F7F8FA; --raised: #FFFFFF;
  --line: #E5E7EB; --line-strong: #D1D5DB;
  --text: #111827; --muted: #6B7280; --faint: #9CA3AF;
  --honey: #B7791F; --honey-bright: #E5A00D; --honey-soft: rgba(229, 160, 13, .14); --honey-line: rgba(229, 160, 13, .38);
  --turf: #059669; --turf-soft: rgba(5, 150, 105, .12); --turf-line: rgba(5, 150, 105, .32);
  --flare: #DC2626; --flare-soft: rgba(220, 38, 38, .10); --flare-line: rgba(220, 38, 38, .32);
  --sky: #1C6FB4; --sky-soft: rgba(28, 111, 180, .12); --sky-line: rgba(28, 111, 180, .3);
  --steel-soft: rgba(107, 114, 128, .12);
  --backdrop: rgba(17, 24, 39, .32);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 32px -16px rgba(16, 24, 40, .18);
  --on-honey: #1B1300;
}
/* O painel abre em escuro por omissão (como sempre foi) até todas as telas estarem redesenhadas (U10); o botão do
   topo troca e a escolha fica no navegador, com a mesma chave da Central (moldura.js põe data-theme no <html>). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0D11; --surface: #13161B; --surface-2: #181C22; --raised: #1C2128;
  --line: #252A32; --line-strong: #343B45;
  --text: #F3F4F6; --muted: #9CA3AF; --faint: #6B7280;
  --honey: #F5B83D; --honey-bright: #FFC857; --honey-soft: rgba(245, 184, 61, .14); --honey-line: rgba(245, 184, 61, .4);
  --turf: #34D399; --turf-soft: rgba(52, 211, 153, .13); --turf-line: rgba(52, 211, 153, .34);
  --flare: #F87171; --flare-soft: rgba(248, 113, 113, .13); --flare-line: rgba(248, 113, 113, .36);
  --sky: #7FC8FF; --sky-soft: rgba(127, 200, 255, .13); --sky-line: rgba(127, 200, 255, .32);
  --steel-soft: rgba(156, 163, 175, .12);
  --backdrop: rgba(0, 0, 0, .6);
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, .8);
  --on-honey: #1B1300;
}

/* ── Ponte: tokens antigos → Central ───────────────────────────────────────── */
:root {
  --bb-bg-app: var(--bg); --bb-bg-sidebar: var(--surface); --bb-bg-card: var(--surface);
  --bb-bg-card-hover: var(--surface-2); --bb-bg-elevated: var(--raised); --bb-bg-input: var(--surface-2);
  --bb-border: var(--line); --bb-border-strong: var(--line-strong); --bb-border-subtle: var(--line);
  --bb-text: var(--text); --bb-text-2: var(--muted); --bb-text-3: var(--faint); --bb-text-4: var(--faint);
  --bb-accent: var(--honey-bright); --bb-accent-hover: var(--honey); --bb-accent-dim: var(--honey);
  --bb-accent-bg: var(--honey-soft); --bb-accent-border: var(--honey-line);
  --bb-success: var(--turf); --bb-success-bg: var(--turf-soft); --bb-success-border: var(--turf-line);
  --bb-warning: var(--honey-bright); --bb-warning-bg: var(--honey-soft); --bb-warning-border: var(--honey-line);
  --bb-danger: var(--flare); --bb-danger-bg: var(--flare-soft); --bb-danger-border: var(--flare-line);
  --bb-info: var(--sky); --bb-info-bg: var(--sky-soft); --bb-info-border: var(--sky-line);
  --bb-font-head: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bb-font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bb-sh-card: none; --bb-sh-elev: var(--shadow);
  --bb-sh-glow-accent: 0 0 0 1px var(--honey-line);
  --bb-sidebar-w: 0px; --bb-sidebar-w-open: 0px; --bb-h-header: 60px;
  /* os de 2024 (primeira linha do <style> do painel) */
  --bg2: var(--surface); --bg3: var(--surface-2); --border: var(--line);
  --accent: var(--honey-bright); --accent2: var(--honey-bright);
  --green: var(--turf); --red: var(--flare); --amber: var(--honey-bright);
  --sans: 'Manrope', system-ui, sans-serif;
  --num: 'Saira Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
}
body { background: var(--bg); color: var(--text); font-family: var(--bb-font-body); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--honey-bright); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ── Sem menu lateral: a navegação é o menu colmeia do topo (D-02). A barra lateral continua no HTML, escondida: o
   aplicarPermissoes do painel mostra e esconde os itens dela, e o menu colmeia e a barra de baixo lêem-na e carregam
   nos itens (fazem exactamente o que o clique fazia). ── */
.layout { grid-template-columns: 1fr !important; }
.sidebar, .nav-overlay, #mobile-menu-btn { display: none !important; }

/* ── Topo, como o da Central ───────────────────────────────────────────────── */
.topbar { background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); gap: 12px; padding: 0 20px 0 12px; }
.tb-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.15; min-width: 0; font-family: var(--bb-font-head); }
.tb-brand b { font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.tb-brand b em { font-style: normal; color: var(--honey-bright); }
.tb-brand span { color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { gap: 10px; margin-left: auto; }
.topbar-status { font-family: var(--bb-font-body); font-size: 12px; color: var(--muted); }
.tb-icon-btn { border: 1px solid var(--line-strong); color: var(--muted); border-radius: 8px; background: transparent; }
.tb-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.tb-user { background: var(--surface); border-color: var(--line); cursor: default; }
.tb-user-av { background: var(--honey-soft); color: var(--honey); border: 1px solid var(--honey-line); }
.tb-user-name { color: var(--text); font-weight: 600; }
.tb-user-role { color: var(--faint); text-transform: lowercase; }
.bb-sair { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 600 12.5px var(--bb-font-body); cursor: pointer; }
.bb-sair:hover { color: var(--flare); border-color: var(--flare-line); background: var(--flare-soft); }
.bb-sair i { font-size: 16px; }

/* ── Conteúdo ──────────────────────────────────────────────────────────────── */
.main { background: var(--bg); }
.page-title, .page-head h1 { font-family: var(--bb-font-head); font-weight: 800; letter-spacing: -.015em; color: var(--text); }
.page-sub { color: var(--muted); }

/* ── Telemóvel e tablet (≤900px): barra de baixo ───────────────────────────── */
.bb-tabbar { display: none; }
@media (max-width: 900px) {
  .topbar { padding: 0 12px 0 6px !important; }
  .tb-brand span { display: none; }
  .tb-user-info { display: none; }
  .bb-sair span { display: none; }
  .bb-sair { padding: 0 10px; }
  .main { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
  .bb-tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .bb-tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none;
    color: var(--faint); font: 600 10.5px var(--bb-font-body); cursor: pointer; border-radius: 10px; position: relative; min-height: 44px; }
  .bb-tabbar button[hidden] { display: none; }
  .bb-tabbar button i { font-size: 21px; line-height: 1; }
  .bb-tabbar button.ativo { color: var(--honey); background: var(--honey-soft); }
  :root[data-theme="dark"] .bb-tabbar button.ativo { color: var(--honey-bright); }
  .bb-tabbar .bb-tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: var(--flare); color: #fff; font: 700 10px/16px var(--bb-font-body); }
}
@media (max-width: 900px) {
  /* O botão flutuante do agente (admin/gerente) sobe para cima da barra de baixo (tapava o "Menu"). */
  #agente-btn { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
  #agente-panel { bottom: calc(148px + env(safe-area-inset-bottom, 0px)) !important; max-height: calc(100vh - 220px) !important; }
  /* A barra fixa do "Enviar" (Envio de pedidos) cola acima da barra de baixo, em vez de ficar tapada por ela. */
  .action-bar { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
}
@media (max-width: 900px) and (display-mode: standalone) {
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ── Rede de segurança: se o menu colmeia não carregar (o /central/nav.js é servido pelo registo do V2), o moldura.js
   põe .bb-sem-colmeia no <html> e a barra lateral antiga volta, para nenhum setor ficar sem entrada (REGRAS 20). ── */
html.bb-sem-colmeia { --bb-sidebar-w: 72px; --bb-sidebar-w-open: 236px; }
html.bb-sem-colmeia .layout { grid-template-columns: var(--bb-sidebar-w) 1fr !important; }
html.bb-sem-colmeia .sidebar { display: flex !important; }
html.bb-sem-colmeia #hiveBtn { display: none !important; }
@media (max-width: 900px) {
  html.bb-sem-colmeia .layout { grid-template-columns: 1fr !important; }
  html.bb-sem-colmeia #mobile-menu-btn { display: flex !important; align-items: center; justify-content: center; }
  html.bb-sem-colmeia .nav-overlay.open { display: block !important; position: fixed; inset: 0; z-index: 299; background: var(--backdrop); }
}
@media (max-width: 420px) { .tb-brand b { font-size: 15px; } .topbar-status { display: none; } }
