/* ============================================
   BRANS BackOffice — Casca compartilhada
   Identidade da suíte (tokens, tipografia, menu lateral e barra superior).
   Carregada por todas as telas do BackOffice; o menu é montado por assets/shell.js.
   Referência: skills/tribux.spec §15 (navy #0D182A, dourado #D4AF37, fundo #F3F1EC,
   Playfair Display / Montserrat / Inter — mono só em número de coluna).
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&family=Montserrat:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* ---- Tokens ---- */
:root {
  /* Marca */
  --navy:       #0D182A;
  --navy-mid:   #142A40;
  --navy-deep:  #07101D;
  --gold:       #D4AF37;
  --gold-dark:  #B8952E;
  --gold-light: #E2C47A;
  --gold-ink:   #8A6D1B;          /* dourado legível como texto sobre branco */
  --gold-dim:   rgba(212,175,55,.12);
  --gold-line:  rgba(212,175,55,.32);

  /* Superfícies e neutros */
  --cream: #F3F1EC;               /* fundo da página */
  --n50:   #F8F6F1;
  --n100:  #E7E3DA;
  --n200:  #CFC9BF;
  --n400:  #8E938F;
  --n600:  #475569;

  /* Estado */
  --success: #15803D;
  --info:    #0C7DB5;
  --warning: #F59E0B;
  --error:   #DC2626;

  --grad-navy: linear-gradient(160deg, #0D182A 0%, #142A40 100%);
  --grad-gold: linear-gradient(135deg, #D4AF37 0%, #E2C47A 100%);

  /* Tipografia */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui:      'Montserrat', sans-serif;
  --font-body:    'Inter', sans-serif;

  --radius:    8px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 3px rgba(13,24,42,.06), 0 1px 2px rgba(13,24,42,.04);
  --shadow-2: 0 4px 16px rgba(13,24,42,.10);
  --shadow-3: 0 10px 32px rgba(13,24,42,.16);

  --sidebar-w: 240px;
  --topbar-h:  56px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--navy);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Menu lateral ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--grad-navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar__brand {
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-link__mark { width: 34px; height: 38px; object-fit: contain; flex-shrink: 0; }
.brand-link__logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 4px;
  line-height: 1;
}
.brand-link__tagline {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 6px;
}

.sidebar__nav { flex: 1; padding: 6px 0 10px; }
.sidebar__divider {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  padding: 18px 22px 6px;
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 22px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.66);
  cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar__item:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar__item.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: rgba(212,175,55,.16);
}
.sidebar__item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar__item.is-disabled { opacity: .38; pointer-events: none; }

/* Troca de módulo — sempre visível em todas as telas */
.sidebar__switch { padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 2px; }
.sidebar__switch .sidebar__item.is-current {
  color: #fff;
  font-weight: 600;
  background: rgba(255,255,255,.07);
}
.sidebar__switch .sidebar__item.is-current svg { color: var(--gold); }
.sidebar__switch .sidebar__item.is-current::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: auto;
  box-shadow: 0 0 8px rgba(212,175,55,.6);
}

.sidebar__footer {
  padding: 14px 22px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-family: var(--font-ui);
  font-size: 10px;
  color: rgba(255,255,255,.34);
  letter-spacing: .5px;
}

/* ---- Barra superior ---- */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--n100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-1);
}
.topbar__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--navy);
}
.topbar__actions { display: flex; align-items: center; gap: 14px; }
.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}
.topbar__user-text { line-height: 1.2; }
.topbar__user-sub {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--n400);
  letter-spacing: .3px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--grad-navy);
  color: var(--gold);
  border: 1.5px solid var(--gold-line);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--n100);
  background: #fff;
  color: var(--n600);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.tb-icon:hover { border-color: var(--gold); color: var(--navy); background: var(--n50); }
.tb-icon svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar__divider { width: 1px; height: 22px; background: var(--n100); }

/* ---- Responsivo ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .brand-link__text, .sidebar__divider, .sidebar__item span, .sidebar__footer,
  .sidebar__switch .sidebar__item.is-current::after { display: none; }
  .sidebar__brand { padding: 18px 0; display: flex; justify-content: center; }
  .sidebar__item { justify-content: center; padding: 12px 0; }
  .topbar { padding: 0 16px; }
  .topbar__user-text { display: none; }
}

/* ---- App no celular (PWA): menu vira gaveta, barra superior com botão de menu ---- */
.tb-hamb { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -6px; border: none; background: none; color: var(--navy); cursor: pointer; border-radius: 8px; flex-shrink: 0; }
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  html, body { overflow-x: hidden; }
  .tb-hamb { display: inline-flex; }
  .sidebar { width: 270px; transform: translateX(-100%); transition: transform .22s ease; z-index: 300; }
  body.menu-aberto .sidebar { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.35); }
  body.menu-aberto::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 250; }
  .brand-link__text, .sidebar__divider, .sidebar__item span, .sidebar__footer { display: revert; }
  .sidebar__brand { padding: 22px 22px 18px; display: block; }
  .sidebar__item { justify-content: flex-start; padding: 12px 22px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__title { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page { padding: 16px 12px; }
  .data-table, .table { display: block; overflow-x: auto; }
  .page-header { flex-wrap: wrap; gap: 8px; }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
