/*
 * Application shell: icon rail + area panel + top bar.
 *
 *   .hz-app            flex row holding navigation and the main column
 *   .hz-nav            rail (.hz-rail) + panel (.hz-panel)
 *   .hz-topbar         breadcrumb, global search and account tools
 *
 * States on <body>:
 *   .hz-panel-collapsed  panel hidden on desktop (rail only)
 *   .hz-nav-open         navigation drawer open on phones/tablets
 */
.hz-app { display: flex; min-height: 100vh; min-height: 100dvh; background: var(--hz-bg); }

/* Navigation column ------------------------------------------------------ */
.hz-nav { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex: none; z-index: 1030; }

.hz-rail {
  width: var(--hz-rail-width); background: var(--hz-rail-bg);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
}
.hz-rail::-webkit-scrollbar { display: none; }
.hz-rail-brand { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; margin-bottom: 8px; flex: none; }
.hz-rail-brand img { width: 34px; height: 34px; object-fit: contain; }
.hz-rail-brand .hz-logo-dark, html[data-theme="dark"] .hz-rail-brand .hz-logo-light { display: none; }
html[data-theme="dark"] .hz-rail-brand .hz-logo-dark { display: block; }
.hz-rail-brand .hz-rail-initial { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--hz-brand); color: var(--hz-brand-ink); font-weight: 800; }
.hz-rail-items, .hz-rail-foot { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.hz-rail-foot { margin-top: auto; padding-top: 8px; }
.hz-rail-btn {
  position: relative; width: 44px; height: 44px; flex: none;
  display: grid; place-items: center; border: 0; border-radius: 12px;
  background: transparent; color: var(--hz-rail-ink); font-size: 1.15rem;
  cursor: pointer; text-decoration: none; transition: background .15s var(--hz-ease), color .15s var(--hz-ease);
}
.hz-rail-btn:hover { background: var(--hz-rail-hover); color: #fff; }
.hz-rail-btn:focus-visible { outline: 2px solid var(--hz-rail-marker); outline-offset: 1px; }
.hz-rail-btn.is-active, .hz-rail-btn[aria-pressed="true"] { background: var(--hz-rail-active); color: #fff; }
.hz-rail-btn.is-current::before {
  content: ""; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--hz-rail-marker);
}
.hz-rail-tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 4px 9px; border-radius: 6px; background: var(--hz-ink); color: var(--hz-bg);
  font-size: 12px; font-weight: 700; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s; z-index: 5;
}
.hz-rail-btn:hover .hz-rail-tip, .hz-rail-btn:focus-visible .hz-rail-tip { opacity: 1; }
.hz-rail-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #2a4a3c; color: #dff5e9; font-weight: 800; font-size: 13px; overflow: hidden;
}
.hz-rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.hz-rail .dropdown-menu { margin-left: 8px !important; }

.hz-panel {
  width: var(--hz-panel-width); background: var(--hz-surface);
  border-right: 1px solid var(--hz-line); display: flex; flex-direction: column; min-height: 0;
  transition: width .18s var(--hz-ease), opacity .18s var(--hz-ease);
}
body.hz-panel-collapsed .hz-panel { width: 0; opacity: 0; overflow: hidden; border-right: 0; }
.hz-panel-section { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.hz-panel-section[hidden] { display: none !important; }
.hz-panel-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 12px 16px; border-bottom: 1px solid var(--hz-line); min-height: var(--hz-topbar-height); }
.hz-panel-head strong { font-size: var(--hz-text-lg); font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-panel-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 20px; display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: var(--hz-line) transparent;
  /* Sombra no pé quando ainda há telas abaixo: o menu não parece cortado. */
  background: linear-gradient(var(--hz-surface) 30%, transparent) center top / 100% 24px no-repeat local,
              linear-gradient(transparent, var(--hz-surface) 70%) center bottom / 100% 24px no-repeat local,
              radial-gradient(farthest-side at 50% 0, rgba(15, 23, 42, .12), transparent) center top / 100% 10px no-repeat scroll,
              radial-gradient(farthest-side at 50% 100%, rgba(15, 23, 42, .12), transparent) center bottom / 100% 10px no-repeat scroll; }
.hz-panel-group { display: flex; flex-direction: column; gap: 1px; }
.hz-panel-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.hz-panel-group-title { margin: 0; padding: 2px 10px; font-family: var(--hz-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--hz-muted); }
.hz-panel-link {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px;
  color: var(--hz-ink-2); text-decoration: none; font-size: 13.5px; font-weight: 600; line-height: 1.3;
}
.hz-panel-link > i:first-child { font-size: 15px; width: 18px; text-align: center; opacity: .8; flex: none; }
.hz-panel-link:hover { background: var(--hz-surface-2); color: var(--hz-ink); }
.hz-panel-link.is-active { background: var(--hz-brand-soft); color: var(--hz-brand-text); }
.hz-panel-link.is-active > i:first-child { opacity: 1; }
.hz-panel-link.is-locked { opacity: .55; pointer-events: none; }
.hz-panel-link .hz-panel-flag { margin-left: auto; font-size: 12px; opacity: .7; }
.hz-panel-foot { border-top: 1px solid var(--hz-line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: var(--hz-text-xs); color: var(--hz-muted); }
.hz-panel-foot label { display: flex; align-items: center; gap: 6px; font-weight: 700; margin: 0; }
.hz-panel-foot select { width: 100%; font: 600 var(--hz-text-sm) var(--hz-font); color: var(--hz-ink); background: var(--hz-surface-2); border: 1px solid var(--hz-line); border-radius: var(--hz-radius-sm); padding: 5px 8px; }
.hz-panel-tenant { display: flex; align-items: center; gap: 8px; color: var(--hz-ink); font-weight: 700; font-size: var(--hz-text-sm); min-width: 0; }
.hz-panel-tenant span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hz-icon-btn {
  width: 34px; height: 34px; flex: none; display: inline-grid; place-items: center;
  border: 1px solid var(--hz-line); border-radius: 8px; background: var(--hz-surface);
  color: var(--hz-ink-2); font-size: 1rem; cursor: pointer; position: relative; text-decoration: none;
}
.hz-icon-btn:hover { background: var(--hz-surface-2); color: var(--hz-ink); }
.hz-icon-btn--ghost { border-color: transparent; background: transparent; }

/* Main column ------------------------------------------------------------ */
.hz-app > .main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; margin: 0; padding: 0; width: auto; background: var(--hz-bg); }
/* Page area. Screens get the standard gutter; a .ui-page inside it only sets
   the max width. Full-screen tools (chat, kanban, PDV, editors) opt out with
   {% block body_class %}hz-full-bleed{% endblock %}. */
.hz-app .content-viewport { flex: 1; min-width: 0; width: 100%; max-width: none; margin: 0; padding: var(--hz-page-pad); display: flex; flex-direction: column; }
.hz-app .content-viewport > .ui-page { padding: 0; }
body.hz-full-bleed .hz-app .content-viewport { padding: 0; }
body.hz-full-bleed .hz-app .content-viewport > .ui-page { padding: var(--hz-page-pad); }

.hz-topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--hz-topbar-height); flex: none;
  display: flex; align-items: center; gap: 10px; padding: 0 16px 0 12px;
  background: color-mix(in srgb, var(--hz-surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--hz-line);
}
.hz-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--hz-text-sm); color: var(--hz-muted); }
.hz-crumbs span { white-space: nowrap; }
.hz-crumbs span:not(:last-child)::after { content: "/"; margin-left: 6px; opacity: .6; }
.hz-crumbs span:last-child { color: var(--hz-ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.hz-topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.hz-search-trigger {
  display: flex; align-items: center; gap: 8px; min-width: 260px; height: 34px; padding: 0 8px 0 10px;
  border: 1px solid var(--hz-line); border-radius: 8px; background: var(--hz-surface-2);
  color: var(--hz-muted); font: 500 var(--hz-text-sm) var(--hz-font); cursor: pointer; text-align: left;
}
.hz-search-trigger:hover { border-color: var(--hz-line-strong); color: var(--hz-ink-2); }
.hz-search-trigger kbd { margin-left: auto; padding: 1px 6px; font: 600 11px var(--hz-mono); color: var(--hz-muted); background: var(--hz-surface); border: 1px solid var(--hz-line-strong); border-radius: 4px; white-space: nowrap; }
.hz-topbar .global-system-tool { position: relative; display: flex; }
.hz-topbar .global-system-tool-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--hz-line); border-radius: 8px; background: var(--hz-surface); color: var(--hz-ink-2); cursor: pointer; text-decoration: none; }
.hz-topbar .global-system-tool-btn:hover { background: var(--hz-surface-2); color: var(--hz-ink); }
.hz-topbar .global-notification-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--hz-danger); color: #fff; font: 700 10px/17px var(--hz-font); text-align: center; }
.hz-topbar .global-food-operation { width: auto; display: inline-flex; gap: 6px; padding: 0 10px; font-size: 12px; font-weight: 800; }
.hz-topbar .global-food-operation.is-open { color: var(--hz-ok); background: var(--hz-ok-bg); border-color: color-mix(in srgb, var(--hz-ok) 35%, transparent); }
.hz-topbar .global-food-operation.is-closed { color: var(--hz-danger); background: var(--hz-danger-bg); border-color: color-mix(in srgb, var(--hz-danger) 35%, transparent); }
.hz-topbar .hz-favorite.is-favorite { color: #d99a00; }
.hz-menu-toggle { display: none; }

/* Server flash messages sit under the top bar. */
.hz-app .server-flash-stack { padding: 12px var(--hz-page-pad) 0; }

/* Banners above the app (billing, platform access) ------------------------ */
.platform-access-bar, .tenant-billing-banner { font-family: var(--hz-font); }

/* Desktop: the navigation is fixed to the viewport, so it never scrolls away
   with long pages (sticky broke whenever a page changed the scroll container).
   The content column reserves the navigation width instead. */
@media (min-width: 992px) {
  body { --hz-nav-offset: calc(var(--hz-rail-width) + var(--hz-panel-width)); }
  body.hz-panel-collapsed, body:not(:has(.hz-panel)) { --hz-nav-offset: var(--hz-rail-width); }
  body:not(:has(.hz-nav)), body.hz-embed { --hz-nav-offset: 0px; }
  .hz-nav { position: fixed; top: 0; bottom: 0; left: 0; height: auto; }
  .hz-app > .main-content, .platform-access-bar, .tenant-billing-banner { margin-left: var(--hz-nav-offset); transition: margin-left .18s var(--hz-ease); }
}

/* Tablet & phone: navigation becomes a drawer ---------------------------- */
.hz-backdrop { display: none; }
@media (max-width: 991.98px) {
  .hz-nav { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s var(--hz-ease); box-shadow: var(--hz-shadow-lg); }
  body.hz-nav-open .hz-nav { transform: none; }
  body.hz-panel-collapsed .hz-panel { width: var(--hz-panel-width); opacity: 1; border-right: 1px solid var(--hz-line); }
  .hz-backdrop { position: fixed; inset: 0; z-index: 1029; border: 0; background: var(--hz-overlay); }
  body.hz-nav-open .hz-backdrop { display: block; }
  .hz-menu-toggle { display: inline-grid; }
  .hz-panel-toggle { display: none; }
  .hz-search-trigger { min-width: 0; width: 34px; padding: 0; justify-content: center; }
  .hz-search-trigger span, .hz-search-trigger kbd { display: none; }
  .hz-topbar { padding: 0 10px; }
  .hz-app .content-viewport { padding: 12px; }
  .hz-crumbs span:not(:last-child) { display: none; }
}
@media (max-width: 575.98px) {
  .hz-topbar .global-food-operation span { display: none; }
  .hz-topbar .global-food-operation { padding: 0; width: 34px; }
}

/* Embedded frames (modal_embed=1) render only the page. */
body.hz-embed .hz-nav, body.hz-embed .hz-topbar, body.hz-embed .hz-backdrop { display: none !important; }
body.hz-embed .content-viewport { padding: 0; }
body.hz-embed:not(.hz-full-bleed) .content-viewport { padding: 16px 20px 24px; }
body.hz-embed .platform-access-bar, body.hz-embed .tenant-billing-banner { display: none !important; }

/* Print: only the page. */
@media print {
  .hz-nav, .hz-topbar, .hz-backdrop, #chatBubble, #chat-widget { display: none !important; }
  .hz-app, .hz-app > .main-content { display: block; }
}
