/* EXATA ERP — V34.9.205 — Fundação Global UI/UX R1
 * Shell Global: sidebar, topbar, área de trabalho e barra de janelas.
 * Camada visual aditiva sobre R0 e css/styles.css.
 * Não altera regras de negócio, eventos, permissões, banco, fiscal ou PDV.
 */

:root {
  --exata-shell-sidebar-w: 236px;
  --exata-shell-sidebar-collapsed-w: 72px;
  --exata-shell-topbar-h: 60px;
  --exata-shell-sidebar-bg: #07182e;
  --exata-shell-sidebar-bg-2: #0b2444;
  --exata-shell-topbar-bg: #081b33;
  --exata-shell-topbar-border: rgba(255, 255, 255, 0.08);
  --exata-shell-nav-text: #c8d5e5;
  --exata-shell-nav-muted: #7990ac;
  --exata-shell-nav-hover: rgba(255, 255, 255, 0.07);
  --exata-shell-nav-active: rgba(37, 99, 235, 0.22);
  --exata-shell-nav-active-line: #60a5fa;
  --exata-shell-topbar-text: #f8fafc;
  --exata-shell-topbar-muted: #9fb1c7;
}

#appRoot,
#masterRoot {
  background: var(--exata-bg);
  color: var(--exata-text);
  font-family: var(--exata-font);
}

#appRoot > .sidebar,
#masterRoot > .sidebar {
  width: var(--exata-shell-sidebar-w);
  min-width: var(--exata-shell-sidebar-w);
  padding: 12px 10px 10px;
  background:
    radial-gradient(circle at 12% 0%, rgba(37, 99, 235, 0.18), transparent 31%),
    linear-gradient(180deg, var(--exata-shell-sidebar-bg-2), var(--exata-shell-sidebar-bg));
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 6px 0 24px rgba(7, 24, 46, 0.08);
  color: var(--exata-shell-nav-text);
  transition: width .18s ease, min-width .18s ease, padding .18s ease;
  overflow-x: hidden;
}

#appRoot > .sidebar .brand,
#masterRoot > .sidebar .brand {
  min-height: 54px;
  margin: 0 2px 10px;
  padding: 7px 8px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  color: #fff;
  white-space: nowrap;
}

#appRoot > .sidebar .brand .brand-mark,
#masterRoot > .sidebar .brand .brand-mark {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

#appRoot > .sidebar .brand .brand-mark img,
#masterRoot > .sidebar .brand .brand-mark img {
  width: 34px !important;
  height: 34px !important;
  object-fit: cover;
  border-radius: 9px !important;
}

#appRoot > .sidebar .brand strong,
#appRoot > .sidebar .brand > span:last-child,
#masterRoot > .sidebar .brand strong,
#masterRoot > .sidebar .brand > span:last-child {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .01em;
}

#appRoot > .sidebar .brand small,
#masterRoot > .sidebar .brand small {
  margin-top: 2px;
  color: #8fa4bd;
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .01em;
}

#appRoot > .sidebar nav,
#masterRoot > .sidebar nav {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#appRoot > .sidebar nav button,
#masterRoot > .sidebar nav button {
  position: relative;
  width: 100%;
  min-height: 38px;
  margin: 1px 0;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--exata-shell-nav-text);
  font-family: var(--exata-font);
  font-size: .81rem;
  font-weight: 550;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

#appRoot > .sidebar nav button:hover,
#masterRoot > .sidebar nav button:hover {
  background: var(--exata-shell-nav-hover);
  color: #fff;
}

#appRoot > .sidebar nav button.active,
#appRoot > .sidebar nav button[aria-current="page"],
#masterRoot > .sidebar nav button.active,
#masterRoot > .sidebar nav button[aria-current="page"] {
  background: var(--exata-shell-nav-active);
  border-color: rgba(96, 165, 250, .18);
  color: #fff;
}

#appRoot > .sidebar nav button.active::before,
#appRoot > .sidebar nav button[aria-current="page"]::before,
#masterRoot > .sidebar nav button.active::before,
#masterRoot > .sidebar nav button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: var(--exata-shell-nav-active-line);
}

#appRoot > .sidebar nav .icon,
#masterRoot > .sidebar nav .icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #fff;
  font-size: .8rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

#appRoot > .sidebar .nav-group-title,
#masterRoot > .sidebar .nav-group-title {
  padding: 13px 8px 5px;
  color: var(--exata-shell-nav-muted);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .075em;
  text-transform: uppercase;
}

#appRoot > .sidebar .sidebar-footer,
#masterRoot > .sidebar .sidebar-footer {
  margin-top: auto;
  padding: 10px 6px 2px;
  border-top: 1px solid rgba(255,255,255,.08);
}

#appRoot > .sidebar .app-build-badge,
#masterRoot > .sidebar .app-build-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: var(--exata-radius-pill);
  background: rgba(255,255,255,.05);
  color: #8fa4bd;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .02em;
}

#appRoot > .content-col,
#masterRoot > .content-col {
  min-width: 0;
  background: var(--exata-bg);
}

#appRoot > .content-col > main,
#masterRoot > .content-col > main {
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 20px 22px;
}

#appRoot > .content-col > .topbar,
#masterRoot > .content-col > .topbar {
  min-height: var(--exata-shell-topbar-h);
  height: var(--exata-shell-topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background:
    linear-gradient(90deg, rgba(21, 94, 239, .08), transparent 35%),
    var(--exata-shell-topbar-bg);
  border-bottom: 1px solid var(--exata-shell-topbar-border);
  box-shadow: 0 2px 12px rgba(7, 24, 46, .12);
  color: var(--exata-shell-topbar-text);
  z-index: 30;
}

#appRoot .topbar .empresa,
#masterRoot .topbar .empresa {
  min-width: 0;
  max-width: min(440px, 38vw);
  color: var(--exata-shell-topbar-text);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#appRoot .topbar .empresa small,
#masterRoot .topbar .empresa small {
  display: block;
  margin-top: 2px;
  color: var(--exata-shell-topbar-muted);
  font-size: .66rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#appRoot .topbar .spacer,
#masterRoot .topbar .spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

#appRoot .topbar-actions,
#masterRoot .topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

#appRoot .top-icon-btn,
#masterRoot .top-icon-btn,
#appRoot .window-indicator,
#masterRoot .window-indicator {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: #d9e3ee;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

#appRoot .top-icon-btn:hover,
#masterRoot .top-icon-btn:hover,
#appRoot .window-indicator:hover,
#masterRoot .window-indicator:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.18);
  color: #fff;
}

#appRoot .top-search-btn,
#masterRoot .top-search-btn {
  min-height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  color: #e4ecf5;
  font-family: var(--exata-font);
  cursor: pointer;
}

#appRoot .top-search-btn:hover,
#masterRoot .top-search-btn:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
}

#appRoot .top-search-btn b,
#masterRoot .top-search-btn b {
  font-size: .75rem;
  font-weight: 650;
}

#appRoot .top-search-btn kbd,
#masterRoot .top-search-btn kbd {
  padding: 3px 5px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px;
  background: rgba(0,0,0,.12);
  color: #9fb1c7;
  font: 600 .62rem/1 var(--exata-font);
}

#appRoot .connection-status,
#masterRoot .connection-status {
  min-height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--exata-radius-pill);
  background: rgba(255,255,255,.04);
  color: #b8c8d9;
  font-family: var(--exata-font);
}

#appRoot .connection-status > span,
#masterRoot .connection-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148,163,184,.12);
}

#appRoot .connection-status.online > span,
#masterRoot .connection-status.online > span {
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,.13);
}

#appRoot .connection-status b,
#masterRoot .connection-status b {
  font-size: .68rem;
  font-weight: 700;
}

#appRoot .topbar .usuario,
#masterRoot .topbar .usuario {
  min-height: 36px;
  padding: 3px 8px 3px 4px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--exata-radius-pill);
  background: rgba(255,255,255,.04);
  color: #dbe5ef;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

#appRoot .topbar .avatar,
#masterRoot .topbar .avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #155eef);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}

#appRoot .btn-logout,
#masterRoot .btn-logout,
#appRoot .topbar-secondary,
#masterRoot .topbar-secondary {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  background: transparent;
  color: #b9c8d8;
  font: 600 .7rem/1 var(--exata-font);
  cursor: pointer;
}

#appRoot .btn-logout:hover,
#masterRoot .btn-logout:hover,
#appRoot .topbar-secondary:hover,
#masterRoot .topbar-secondary:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

#appRoot .window-indicator {
  position: relative;
}

#appRoot .window-indicator [data-window-count] {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--exata-shell-topbar-bg);
  border-radius: var(--exata-radius-pill);
  background: var(--exata-blue-600);
  color: #fff;
  font-size: .58rem;
  font-weight: 800;
}

#barra-janelas {
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  background: #0a203b;
  border-top: 1px solid rgba(255,255,255,.07);
  overflow-x: auto;
  scrollbar-width: thin;
}

#barra-janelas:empty {
  display: none;
}

#barra-janelas .barra-item {
  position: relative;
  min-width: 0;
  max-width: 220px;
  height: 34px;
  padding: 0 9px 0 5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
  background: transparent;
  color: #9eb0c4;
  font: 600 .7rem/1 var(--exata-font);
  cursor: pointer;
}

#barra-janelas .barra-item:hover {
  background: rgba(255,255,255,.06);
  color: #e8eef5;
}

#barra-janelas .barra-item.active {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.08);
  color: #fff;
}

#barra-janelas .barra-item.active::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 0;
  height: 2px;
  border-radius: 99px;
  background: var(--window-accent, var(--exata-blue-600));
}

#barra-janelas .barra-item.minimized {
  opacity: .72;
}

#barra-janelas .barra-item .icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-size: .66rem;
}

#barra-janelas .barra-item > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.sidebar-collapsed #appRoot > .sidebar,
body.sidebar-collapsed #masterRoot > .sidebar {
  width: var(--exata-shell-sidebar-collapsed-w);
  min-width: var(--exata-shell-sidebar-collapsed-w);
  padding-inline: 8px;
}

body.sidebar-collapsed #appRoot > .sidebar .brand,
body.sidebar-collapsed #masterRoot > .sidebar .brand {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed #appRoot > .sidebar .brand > span:last-child,
body.sidebar-collapsed #masterRoot > .sidebar .brand > span:last-child,
body.sidebar-collapsed #appRoot > .sidebar .nav-group-title,
body.sidebar-collapsed #masterRoot > .sidebar .nav-group-title,
body.sidebar-collapsed #appRoot > .sidebar .sidebar-footer,
body.sidebar-collapsed #masterRoot > .sidebar .sidebar-footer {
  display: none;
}

body.sidebar-collapsed #appRoot > .sidebar nav button,
body.sidebar-collapsed #masterRoot > .sidebar nav button {
  justify-content: center;
  gap: 0;
  padding-inline: 0;
  font-size: 0;
}

body.sidebar-collapsed #appRoot > .sidebar nav button .icon,
body.sidebar-collapsed #masterRoot > .sidebar nav button .icon {
  font-size: .8rem;
}

#appRoot > .sidebar nav button:focus-visible,
#masterRoot > .sidebar nav button:focus-visible,
#appRoot .topbar button:focus-visible,
#masterRoot .topbar button:focus-visible,
#barra-janelas .barra-item:focus-visible {
  outline: none;
  box-shadow: var(--exata-focus);
}

@media (max-width: 1100px) {
  #appRoot .top-search-btn b,
  #masterRoot .top-search-btn b {
    display: none;
  }

  #appRoot .top-search-btn,
  #masterRoot .top-search-btn {
    min-width: 36px;
    padding-inline: 8px;
  }

  #appRoot .topbar .empresa,
  #masterRoot .topbar .empresa {
    max-width: 31vw;
  }
}

@media (max-width: 820px) {
  #appRoot > .sidebar,
  #masterRoot > .sidebar {
    width: min(82vw, 290px);
    min-width: min(82vw, 290px);
  }

  #appRoot > .content-col > .topbar,
  #masterRoot > .content-col > .topbar {
    min-height: 54px;
    height: 54px;
    padding-inline: 9px;
    gap: 6px;
  }

  #appRoot > .content-col > main,
  #masterRoot > .content-col > main {
    padding: 14px 12px;
  }

  #appRoot .topbar .empresa,
  #masterRoot .topbar .empresa {
    max-width: 44vw;
    font-size: .75rem;
  }

  #appRoot .topbar .empresa small,
  #masterRoot .topbar .empresa small,
  #appRoot .connection-status b,
  #masterRoot .connection-status b,
  #appRoot .top-search-btn kbd,
  #masterRoot .top-search-btn kbd,
  #appRoot .topbar .usuario > span:not(.avatar),
  #masterRoot .topbar .usuario > span:not(.avatar),
  #appRoot .btn-logout,
  #masterRoot .btn-logout {
    display: none;
  }

  #appRoot .connection-status,
  #masterRoot .connection-status,
  #appRoot .topbar .usuario {
    width: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
  }

  #appRoot .topbar .usuario {
    border-color: transparent;
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  #appRoot > .sidebar,
  #masterRoot > .sidebar,
  #appRoot > .sidebar nav button,
  #masterRoot > .sidebar nav button,
  #appRoot .topbar button,
  #masterRoot .topbar button {
    transition: none !important;
  }
}
