/* NowBusiness v1.0.1 / ND197 — responsividade global, login mobile, sidebar e suporte NowChat. */

html {
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

/* Evita que componentes flex/grid empurrem a página inteira para fora da viewport. */
body.nf-redesign,
body.nd-auth-body,
body.platform-admin-body,
body.support-portal-body,
body.support-staff-body,
body.nb-public-body,
body.driver-pwa-body,
body.pdv-terminal-body,
body.legal-body-public {
  max-width:100%;
  overflow-x:clip;
}

body.nf-redesign :is(.app-main,.content,.card,.page-card,.section-card,.panel,.form-card,.table-wrap,.settings-grid,.form-grid-2,.form-grid-3,.form-grid-4,.dashboard-grid,.metric-grid,.metrics-grid,.page-head,.page-actions,.topbar-left,.topbar-actions),
body.platform-admin-body :is(.platform-workspace,.platform-main,.platform-card,.platform-grid,.platform-form-grid,.platform-table-wrap),
body.nd-auth-body :is(.nd-auth-shell,.nd-auth-form-panel,.nd-auth-form-panel>*,.auth-login-form),
body.support-portal-body :is(.support-portal-main,.support-portal-panel),
body.support-staff-body :is(.support-staff-main,.support-staff-content),
body.nb-public-body :is(main,section,article,form),
body.driver-pwa-body :is(main,section,article,form),
body.pdv-terminal-body :is(main,section,article,form) {
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}

body.nf-redesign :is(img,video,canvas,svg),
body.nd-auth-body :is(img,video,canvas,svg),
body.platform-admin-body :is(img,video,canvas,svg),
body.support-portal-body :is(img,video,canvas,svg),
body.support-staff-body :is(img,video,canvas,svg),
body.nb-public-body :is(img,video,canvas,svg),
body.driver-pwa-body :is(img,video,canvas,svg),
body.pdv-terminal-body :is(img,video,canvas,svg) {max-width:100%;}

body.nf-redesign :is(.table-wrap,.platform-table-wrap,.responsive-table-wrap),
body.platform-admin-body :is(.platform-table-wrap,.table-wrap) {
  overflow-x:auto;
  overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;
}

/* Marca e recolhimento: o botão fica em uma linha própria abaixo da marca. */
body.nf-redesign .sidebar-head {
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:auto auto!important;
  align-items:center!important;
  gap:7px!important;
  padding-bottom:8px!important;
}
body.nf-redesign .sidebar-logo {
  grid-column:1!important;
  grid-row:1!important;
  width:100%!important;
  min-width:0!important;
  overflow:visible!important;
}
body.nf-redesign .sidebar-logo-text {
  min-width:0!important;
  overflow:visible!important;
  white-space:nowrap!important;
}
body.nf-redesign .sidebar-toggle {
  grid-column:1!important;
  grid-row:2!important;
  position:static!important;
  inset:auto!important;
  justify-self:end!important;
  width:40px!important;
  height:34px!important;
  margin:0 2px 0 0!important;
  border-radius:12px!important;
}
body.nf-redesign .app-shell.sidebar-collapsed .sidebar-head {
  display:grid!important;
  grid-template-columns:1fr!important;
  grid-template-rows:auto auto!important;
  justify-items:center!important;
  gap:7px!important;
}
body.nf-redesign .app-shell.sidebar-collapsed .sidebar-logo {justify-content:center!important;width:auto!important;}
body.nf-redesign .app-shell.sidebar-collapsed .sidebar-toggle {justify-self:center!important;margin:0!important;width:46px!important;height:36px!important;}

/* NowChat: launcher local determinístico usando o chat público oficial. */
.nowchat-support-shell {display:contents;}
.nowchat-support-fab {
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:2147483000;
  min-width:52px;
  min-height:52px;
  border:0;
  border-radius:999px;
  padding:13px 17px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  color:#fff;
  background:linear-gradient(135deg,#1861f1,#0ac0fe);
  box-shadow:0 12px 32px rgba(24,97,241,.28);
  font:700 14px Montserrat,Inter,system-ui,sans-serif;
  cursor:pointer;
  touch-action:manipulation;
}
.nowchat-support-fab svg {width:22px;height:22px;flex:0 0 22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.nowchat-support-fab:focus-visible {outline:3px solid color-mix(in srgb,#0ac0fe 58%,#fff);outline-offset:3px;}
.nowchat-support-frame {
  position:fixed;
  right:22px;
  bottom:84px;
  width:min(390px,calc(100vw - 28px));
  height:min(620px,calc(100dvh - 112px));
  max-width:calc(100vw - 28px);
  max-height:calc(100dvh - 112px);
  z-index:2147482999;
  border:0;
  border-radius:20px;
  box-shadow:0 20px 60px rgba(23,43,77,.24);
  background:#fff;
}
.nowchat-support-frame[hidden] {display:none!important;}

/* Modais e drawers nunca ultrapassam a viewport disponível. */
body.nf-redesign :is(.center-modal-card,.modal-card,.dialog-card,.nb-modal-v30__panel),
body.platform-admin-body :is(.center-modal-card,.platform-modal),
body.support-staff-body :is(dialog,.modal-card) {
  /* ND198: preserva a largura específica de cada modal; limita apenas à viewport. */
  max-width:calc(100vw - 24px)!important;
  max-height:calc(var(--nb-visual-viewport-height,100dvh) - 24px)!important;
  overflow:auto;
}

/* Login: Safari/iOS não amplia campo com texto calculado em pelo menos 16px. */
@media (max-width:1180px) {
  body.nd-auth-body {
    min-height:100dvh!important;
    padding:0!important;
    background:var(--nd-surface,var(--nf-surface,#fff))!important;
  }
  body.nd-auth-body .nd-auth-shell {min-height:100dvh!important;width:100%!important;grid-template-columns:1fr!important;}
  body.nd-auth-body .nd-auth-showcase {display:none!important;}
  body.nd-auth-body .nd-auth-form-panel {
    width:100%!important;
    min-height:100dvh!important;
    margin:0!important;
    padding:max(24px,env(safe-area-inset-top,0px)) clamp(18px,5vw,42px) max(28px,env(safe-area-inset-bottom,0px))!important;
    justify-content:center!important;
    box-shadow:none!important;
  }
  body.nd-auth-body .nd-auth-form-panel>* {width:min(100%,560px)!important;margin-inline:auto!important;}
  body.nd-auth-body .nd-auth-mobile-brand {margin-bottom:clamp(26px,6vh,48px)!important;}
  body.nd-auth-body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea,[contenteditable="true"]) {
    font-size:16px!important;
    line-height:1.35!important;
  }
  body.nd-auth-body :is(input,select,textarea,button,a) {touch-action:manipulation;}
}

/* Tablet/notebook: reduz densidade antes de quebrar o conteúdo. */
@media (max-width:1280px) and (min-width:901px) {
  /* ND198: notebook/tablet preserva os breakpoints específicos de cada módulo. */
  body.nf-redesign .content {padding-inline:clamp(18px,2.4vw,26px)!important;}
  body.nf-redesign .topbar-actions {gap:6px!important;}
  body.platform-admin-body .platform-main {padding:26px 22px!important;}
}

@media (max-width:900px) {
  /* Campos de todo o sistema: anti-zoom sem impedir pinch-to-zoom. */
  body.nf-redesign :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea,[contenteditable="true"]),
  body.platform-admin-body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea,[contenteditable="true"]),
  body.support-portal-body :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body.support-staff-body :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body.nb-public-body :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body.driver-pwa-body :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
  body.pdv-terminal-body :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
    font-size:16px!important;
  }

  /* ND198: não reescreve grids de negócio genericamente. Cada módulo mantém seus próprios breakpoints. */

  body.nf-redesign .topbar {padding-inline:12px!important;gap:8px!important;}
  body.nf-redesign .topbar-left {min-width:0!important;flex:1 1 auto!important;}
  body.nf-redesign .topbar-left>div {min-width:0!important;}
  body.nf-redesign .topbar-left strong,
  body.nf-redesign .topbar-left .muted {overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;}
  body.nf-redesign .topbar-actions {flex:0 0 auto!important;gap:5px!important;}
  body.nf-redesign .topbar-actions :is(.icon-btn,.topbar-icon-link,.theme-toggle) {width:40px!important;height:40px!important;min-width:40px!important;padding:0!important;}
  body.nf-redesign .user-chip strong,
  body.nf-redesign .logout-label {display:none!important;}
  body.nf-redesign .content {padding-inline:12px!important;max-width:100%!important;}

  body.nf-redesign .sidebar-head {grid-template-columns:1fr!important;}
  body.nf-redesign .sidebar-toggle {justify-self:end!important;}

  /* O suporte sempre fica acima do dock mobile e aparece mesmo se o script remoto estiver indisponível. */
  .nowchat-support-fab {
    right:12px!important;
    bottom:var(--nb-pwa-floating-base,calc(84px + env(safe-area-inset-bottom,0px) + 14px))!important;
    width:54px!important;
    min-width:54px!important;
    height:54px!important;
    min-height:54px!important;
    padding:0!important;
    border-radius:50%!important;
  }
  .nowchat-support-fab span {display:none!important;}
  .nowchat-support-frame {
    right:12px!important;
    bottom:calc(var(--nb-pwa-floating-base,calc(84px + env(safe-area-inset-bottom,0px) + 14px)) + 64px)!important;
    width:calc(100vw - 24px)!important;
    height:min(620px,calc(var(--nb-visual-viewport-height,100dvh) - var(--nb-pwa-bottom-nav-height,84px) - var(--nb-pwa-safe-bottom,8px) - 96px))!important;
    max-height:calc(var(--nb-visual-viewport-height,100dvh) - var(--nb-pwa-bottom-nav-height,84px) - var(--nb-pwa-safe-bottom,8px) - 96px)!important;
    border-radius:18px!important;
  }
  body.nf-redesign .contextual-intelligence {bottom:calc(var(--nb-pwa-floating-base,106px) + 64px)!important;}
  body.nf-redesign.has-floating-assistants .page-help-fab {bottom:calc(var(--nb-pwa-floating-base,106px) + 128px)!important;}

  body.platform-admin-body .platform-main {padding:18px 12px!important;max-width:100%!important;}
  body.platform-admin-body .platform-topbar {padding-inline:12px!important;}
  body.platform-admin-body .platform-security-chip {display:none!important;}
  body.platform-admin-body .platform-top-actions {gap:6px!important;}

  body.support-portal-body .support-portal-header,
  body.support-staff-body .support-staff-header {padding-inline:14px!important;gap:10px!important;}
  body.support-portal-body .support-portal-main,
  body.support-staff-body .support-staff-main {padding-inline:12px!important;}
}

@media (max-width:620px) {
  body.nd-auth-body .nd-auth-form-panel {padding-inline:18px!important;justify-content:flex-start!important;}
  body.nd-auth-body .nd-auth-mobile-brand {margin-top:4px!important;margin-bottom:28px!important;}
  body.nd-auth-body .nd-auth-mobile-brand img {width:46px!important;height:46px!important;}
  body.nd-auth-body .nd-auth-mobile-brand strong {font-size:21px!important;}
  body.nd-auth-body .auth-login-intro h2,
  body.nd-auth-body .auth-heading h2 {font-size:clamp(27px,9vw,34px)!important;}
  body.nd-auth-body .auth-login-meta {font-size:14px!important;}

  body.nf-redesign :is(.page-head,.section-heading,.card-head,.form-header,.modal-header) {align-items:flex-start!important;flex-direction:column!important;}
  body.nf-redesign :is(.page-actions,.form-footer,.button-row,.action-row) {width:100%;flex-wrap:wrap!important;}
  body.nf-redesign :is(.page-actions,.form-footer,.button-row,.action-row)>.btn,
  body.nf-redesign :is(.page-actions,.form-footer,.button-row,.action-row)>form {max-width:100%;}
  body.nf-redesign .content {padding-left:10px!important;padding-right:10px!important;}
  body.nf-redesign .card {border-radius:18px!important;}

  body.platform-admin-body .platform-hero {padding:22px 18px!important;}
  body.platform-admin-body .platform-hero h1 {font-size:clamp(28px,9vw,36px)!important;}
  body.platform-admin-body .platform-metrics {grid-template-columns:1fr!important;}
  body.platform-admin-body .platform-top-actions .platform-page-help-button span {display:none!important;}
}

@media (max-width:390px) {
  body.nd-auth-body .nd-auth-form-panel {padding-inline:14px!important;}
  body.nf-redesign .content {padding-inline:8px!important;}
  body.nf-redesign .topbar {padding-inline:8px!important;}
  body.nf-redesign .topbar-actions {gap:3px!important;}
  body.nf-redesign .topbar-actions :is(.icon-btn,.topbar-icon-link,.theme-toggle) {width:38px!important;height:38px!important;min-width:38px!important;}
  .nowchat-support-fab {right:10px!important;width:52px!important;min-width:52px!important;height:52px!important;min-height:52px!important;}
  .nowchat-support-frame {right:8px!important;width:calc(100vw - 16px)!important;}
}

@media (min-width:1600px) {
  body.nf-redesign .content {max-width:1680px!important;padding-inline:36px!important;}
  body.platform-admin-body .platform-main {max-width:1680px!important;padding-inline:38px!important;}
}
