/* CRM footer — match SaaS bar. Do NOT restyle page-wrapper as flex (breaks tables). */

#main-wrapper:has(.nx-saas-content-footer) {
  display: flow-root;
}

body.loggedin:not(.settings):has(.nx-midnight-right-panel .aur-doc--reader) #main-wrapper,
body.loggedin:not(.settings):has(.nx-midnight-right-panel .saas-kb-doc-shell) #main-wrapper {
  display: flow-root !important;
}

/* Kill midnight container bottom pad (same selector weight as custom.css) */
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin:not(.settings)
  .page-wrapper
  > .container-fluid,
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin:not(.settings)
  .page-wrapper
  .container-fluid {
  padding-bottom: 0 !important;
}

/*
 * Theme .page-wrapper { padding-bottom: 60px; min-height: calc(100vh...) }.
 * Footer is a sibling of .page-wrapper (under .nx-midnight-right-panel).
 * Zero min-height so short pages do not leave a void under the bar.
 */
body.loggedin:not(.settings) .nx-midnight-right-panel:has(> .nx-saas-content-footer) > .page-wrapper,
body.loggedin:not(.settings):has(> #main-wrapper > .nx-saas-content-footer) .page-wrapper,
body.loggedin:not(.settings) .page-wrapper:has(+ .nx-saas-content-footer) {
  padding-bottom: 0 !important;
  min-height: 0 !important;
}

/* Settings: footer is moved onto the panel — keep last actions (Добавить) above the bar */
body.settings.loggedin .nx-midnight-right-panel:has(> .nx-saas-content-footer) > #settings-wrapper.page-wrapper {
  min-height: 0 !important;
  max-height: calc(100vh - 1rem - 3.5rem - 2.6rem);
  overflow-y: auto !important;
  padding-bottom: 1.5rem !important;
}

/* Last content row card — no 30px theme margin above footer */
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin:not(.settings)
  .page-wrapper
  > .container-fluid
  > .row:not(:has(~ .row))
  .card {
  margin-bottom: 0 !important;
}

html.app-admin.midnight[data-bs-theme="midnight"] body.loggedin.nx-midnight-premium-shell:not(.settings) .nx-midnight-right-panel:has(.aur-doc--reader) > .nx-saas-content-footer,
html.app-admin.midnight[data-bs-theme="midnight"] body.loggedin.nx-midnight-premium-shell:not(.settings) .nx-midnight-right-panel:has(.saas-kb-doc-shell) > .nx-saas-content-footer {
  padding: 0 1px 1px !important;
  margin-top: 0 !important;
}

body.loggedin:not(.settings) .nx-midnight-right-panel:has(.aur-doc--reader) > .page-wrapper,
body.loggedin:not(.settings) .nx-midnight-right-panel:has(.saas-kb-doc-shell) > .page-wrapper {
  padding-bottom: 0 !important;
  min-height: 0 !important;
  margin-bottom: 0 !important;
}

body.loggedin:not(.settings) .nx-midnight-right-panel:has(.saas-kb-doc-shell) > .nx-saas-content-footer {
  margin-top: 0 !important;
}

/* Bar geometry = SaaS landlord footer */
.nx-saas-content-footer {
  display: block;
  width: 100%;
  margin: 0;
  padding: 1.25rem 1px 1px;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.nx-saas-content-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.7rem 1.25rem;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 calc(0.75rem - 1px) calc(0.75rem - 1px);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 42%, rgba(0, 0, 0, 0.22) 100%),
    #141414;
  color: rgba(226, 232, 240, 0.55);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  box-sizing: border-box;
}

.nx-saas-content-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: rgba(245, 247, 250, 0.78);
}

.nx-saas-content-footer__mark {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 3px;
  object-fit: cover;
}

.nx-saas-content-footer__ver {
  font-weight: 500;
  color: rgba(226, 232, 240, 0.48);
}

.nx-saas-content-footer__copy {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  color: rgba(226, 232, 240, 0.42);
}

.nx-saas-content-footer__studio {
  color: #c5cdd8;
  font-weight: 600;
  letter-spacing: 0.02em;
}

html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__inner {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  color: rgba(15, 23, 42, 0.55);
}

html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__brand {
  color: rgba(15, 23, 42, 0.72);
}

html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__copy {
  color: rgba(15, 23, 42, 0.45);
}

html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__studio {
  color: rgba(15, 23, 42, 0.78);
}

html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__ver {
  color: rgba(15, 23, 42, 0.42);
}

.print-page .nx-saas-content-footer {
  display: none !important;
}

@media print {
  .nx-saas-content-footer {
    display: none !important;
  }
}

/* Mobile footer — compact, same plane as content (CRM + Settings) */
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin.settings
  .page-wrapper
  > .container-fluid,
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin.settings
  .page-wrapper
  .container-fluid,
:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin.settings
  #settings-wrapper.page-wrapper
  .container-fluid {
  padding-bottom: 0 !important;
}

:is(html[data-bs-theme="midnight"], html.midnight:not(.AUR):not(.aur))
  body.loggedin.settings
  .page-wrapper
  > .container-fluid
  > .row:not(:has(~ .row))
  .card {
  margin-bottom: 0 !important;
}

@media (max-width: 767.98px) {
  .nx-saas-content-footer {
    /* no inset above bar — kills black gap over footer on phone */
    padding: 0 !important;
  }

  .nx-saas-content-footer__inner {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
    min-height: 0 !important;
    padding: 0.55rem 0.9rem !important;
    text-align: left !important;
    border-radius: 0 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: #121212 !important;
    color: rgba(226, 232, 240, 0.5) !important;
    font-size: 0.6875rem !important;
    line-height: 1.3 !important;
  }

  /* Phone: studio left · icon + AUR II + version right */
  .nx-saas-content-footer__copy-lead,
  .nx-saas-content-footer__copy-meta {
    display: none !important;
  }

  .nx-saas-content-footer__product {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: rgba(245, 247, 250, 0.78) !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
  }

  .nx-saas-content-footer__copy {
    justify-content: flex-start !important;
    gap: 0 !important;
    min-width: 0 !important;
    color: rgba(226, 232, 240, 0.42) !important;
  }

  .nx-saas-content-footer__brand {
    justify-content: flex-end !important;
    gap: 0.35rem !important;
    margin-left: auto !important;
    font-size: 0.6875rem !important;
    color: rgba(245, 247, 250, 0.62) !important;
  }

  .nx-saas-content-footer__mark {
    width: 14px !important;
    height: 14px !important;
    flex-basis: 14px !important;
    opacity: 0.85;
  }

  .nx-saas-content-footer__studio {
    color: #c5cdd8 !important;
    font-weight: 600 !important;
  }

  .nx-saas-content-footer__ver {
    color: rgba(226, 232, 240, 0.5) !important;
  }

  html:not([data-bs-theme="midnight"]):not(.midnight) .nx-saas-content-footer__inner {
    background: #fff !important;
  }
}

