/* PDFdostD4_3 direct embedded app layout - stable final common fix.
   This file is loaded last by every /apps/<tool>/ page. It removes the runtime shell-fetch screen
   and uses a real header + workspace layout so app content cannot slide below the header. */
:root {
  --pdfdost-direct-header-height: 74px;
  --pdfdost-direct-main-pad-x: 20px;
  --pdfdost-direct-main-pad-y: 12px;
}

html.pdfdost-direct-embedded,
html[data-pdfdost-shell="classic"] {
  height: 100%;
  min-height: 100%;
  scroll-padding-top: 12px !important;
}

body[data-pdfdost-standalone-app="true"],
body[data-pdfdost-single-app="true"] {
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background:
    radial-gradient(circle at 86% 8%, rgba(255,153,51,.10), transparent 30rem),
    linear-gradient(135deg, #fffaf4 0%, #fff4e6 45%, #fffdf9 100%) !important;
}

body[data-pdfdost-standalone-app="true"] .topbar.tool-topbar,
body[data-pdfdost-single-app="true"] .topbar.tool-topbar,
body[data-pdfdost-standalone-app="true"].pdfdost-header-compact .topbar.tool-topbar,
body[data-pdfdost-single-app="true"].pdfdost-header-compact .topbar.tool-topbar,
html.pdfdost-header-compact body[data-pdfdost-standalone-app="true"] .topbar.tool-topbar,
html.pdfdost-header-compact body[data-pdfdost-single-app="true"] .topbar.tool-topbar {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  flex: 0 0 var(--pdfdost-direct-header-height) !important;
  height: var(--pdfdost-direct-header-height) !important;
  min-height: var(--pdfdost-direct-header-height) !important;
  max-height: var(--pdfdost-direct-header-height) !important;
  width: 100% !important;
  display: grid !important;
  grid-template-columns: minmax(210px, 330px) minmax(0, 1fr) !important;
  align-items: center !important;
  gap: clamp(12px, 2vw, 28px) !important;
  padding: 6px clamp(18px, 3vw, 44px) !important;
  margin: 0 !important;
  overflow: visible !important;
  z-index: 1000 !important;
  background: rgba(255,255,255,.985) !important;
  border-bottom: 1px solid rgba(233,179,122,.55) !important;
  box-shadow: 0 8px 22px rgba(120,65,0,.08) !important;
}

body[data-pdfdost-standalone-app="true"] .topbar-main,
body[data-pdfdost-single-app="true"] .topbar-main {
  grid-column: 1 !important;
  height: calc(var(--pdfdost-direct-header-height) - 12px) !important;
  min-height: 0 !important;
  max-height: calc(var(--pdfdost-direct-header-height) - 12px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
}

body[data-pdfdost-standalone-app="true"] .pdfbuddy-brand-block,
body[data-pdfdost-single-app="true"] .pdfbuddy-brand-block,
body[data-pdfdost-standalone-app="true"] .brand-block,
body[data-pdfdost-single-app="true"] .brand-block {
  width: min(330px, 34vw) !important;
  max-width: min(330px, 34vw) !important;
  height: calc(var(--pdfdost-direct-header-height) - 14px) !important;
  min-height: 0 !important;
  max-height: calc(var(--pdfdost-direct-header-height) - 14px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
}

body[data-pdfdost-standalone-app="true"] .brand-logo,
body[data-pdfdost-single-app="true"] .brand-logo,
body[data-pdfdost-standalone-app="true"] .pdfbuddy-brand-block .brand-logo,
body[data-pdfdost-single-app="true"] .pdfbuddy-brand-block .brand-logo {
  display: block !important;
  width: auto !important;
  max-width: min(330px, 34vw) !important;
  height: calc(var(--pdfdost-direct-header-height) - 16px) !important;
  max-height: calc(var(--pdfdost-direct-header-height) - 16px) !important;
  min-height: 0 !important;
  object-fit: contain !important;
  object-position: left center !important;
  transform: none !important;
}

body[data-pdfdost-standalone-app="true"] .brand-text-fallback,
body[data-pdfdost-single-app="true"] .brand-text-fallback {
  display: none !important;
}

body[data-pdfdost-standalone-app="true"] .tool-nav,
body[data-pdfdost-single-app="true"] .tool-nav {
  grid-column: 2 !important;
  width: 100% !important;
  height: auto !important;
  max-height: calc(var(--pdfdost-direct-header-height) - 12px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 7px !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;
}

body[data-pdfdost-standalone-app="true"] .tool-nav > .tab-btn,
body[data-pdfdost-standalone-app="true"] .tool-group-btn,
body[data-pdfdost-standalone-app="true"] .nav-offline-btn,
body[data-pdfdost-standalone-app="true"] .dashboard-home-link,
body[data-pdfdost-single-app="true"] .tool-nav > .tab-btn,
body[data-pdfdost-single-app="true"] .tool-group-btn,
body[data-pdfdost-single-app="true"] .nav-offline-btn,
body[data-pdfdost-single-app="true"] .dashboard-home-link {
  width: auto !important;
  min-width: 0 !important;
  height: 31px !important;
  min-height: 31px !important;
  max-height: 31px !important;
  padding: 6px 11px !important;
  margin: 0 !important;
  border-radius: 999px !important;
  line-height: 1.05 !important;
  font-size: .78rem !important;
  white-space: nowrap !important;
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body[data-pdfdost-standalone-app="true"] .nav-offline-btn,
body[data-pdfdost-single-app="true"] .nav-offline-btn {
  max-width: 230px !important;
  padding-inline: 14px !important;
}

body[data-pdfdost-standalone-app="true"] .tool-group,
body[data-pdfdost-single-app="true"] .tool-group,
body[data-pdfdost-standalone-app="true"] .tool-menu,
body[data-pdfdost-single-app="true"] .tool-menu {
  overflow: visible !important;
}

body[data-pdfdost-standalone-app="true"] .tool-menu,
body[data-pdfdost-single-app="true"] .tool-menu {
  z-index: 999999 !important;
  max-height: min(76vh, 580px) !important;
  overflow-y: auto !important;
}

body[data-pdfdost-standalone-app="true"] #mainLayout.layout.tool-layout,
body[data-pdfdost-single-app="true"] #mainLayout.layout.tool-layout,
body[data-pdfdost-standalone-app="true"] .layout.tool-layout,
body[data-pdfdost-single-app="true"] .layout.tool-layout {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  width: 100% !important;
  max-width: 1500px !important;
  margin: 0 auto !important;
  padding: var(--pdfdost-direct-main-pad-y) var(--pdfdost-direct-main-pad-x) 10px !important;
  overflow: hidden !important;
  align-items: stretch !important;
}

body[data-pdfdost-standalone-app="true"] #mainLayout.preview-hidden,
body[data-pdfdost-single-app="true"] #mainLayout.preview-hidden {
  grid-template-columns: minmax(320px, min(1320px, calc(100vw - 40px))) !important;
  justify-content: center !important;
}

body[data-pdfdost-standalone-app="true"] #mainLayout.preview-visible,
body[data-pdfdost-single-app="true"] #mainLayout.preview-visible,
body[data-pdfdost-standalone-app="true"] #mainLayout:not(.preview-hidden),
body[data-pdfdost-single-app="true"] #mainLayout:not(.preview-hidden) {
  grid-template-columns: minmax(520px, var(--action-pane-width, 58vw)) 12px minmax(300px, 1fr) !important;
}

body[data-pdfdost-standalone-app="true"] #actionPanel,
body[data-pdfdost-single-app="true"] #actionPanel,
body[data-pdfdost-standalone-app="true"] .controls.tool-controls,
body[data-pdfdost-single-app="true"] .controls.tool-controls,
body[data-pdfdost-standalone-app="true"] #previewPanel,
body[data-pdfdost-single-app="true"] #previewPanel,
body[data-pdfdost-standalone-app="true"] .preview,
body[data-pdfdost-single-app="true"] .preview {
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: auto !important;
  overscroll-behavior: contain !important;
  scroll-padding-top: 14px !important;
}

body[data-pdfdost-standalone-app="true"] .tab-panel:not(.active),
body[data-pdfdost-single-app="true"] .tab-panel:not(.active) {
  display: none !important;
}

body[data-pdfdost-standalone-app="true"] .tab-panel.active,
body[data-pdfdost-single-app="true"] .tab-panel.active {
  min-height: 0 !important;
}

body[data-pdfdost-standalone-app="true"] .active-tool-header,
body[data-pdfdost-single-app="true"] .active-tool-header {
  min-height: 0 !important;
  padding: 0 130px 4px !important;
  margin: 0 0 10px !important;
  gap: 3px !important;
}

body[data-pdfdost-standalone-app="true"] .active-tool-icon-stage,
body[data-pdfdost-single-app="true"] .active-tool-icon-stage {
  min-height: 74px !important;
  height: 74px !important;
  margin: 0 auto !important;
}

body[data-pdfdost-standalone-app="true"] .active-tool-icon,
body[data-pdfdost-single-app="true"] .active-tool-icon {
  width: 72px !important;
  height: 72px !important;
  border-radius: 18px !important;
}

body[data-pdfdost-standalone-app="true"] footer.app-footnote,
body[data-pdfdost-single-app="true"] footer.app-footnote {
  display: none !important;
}

@media (max-width: 1180px) {
  body[data-pdfdost-standalone-app="true"] .topbar.tool-topbar,
  body[data-pdfdost-single-app="true"] .topbar.tool-topbar {
    grid-template-columns: minmax(190px, 280px) minmax(0, 1fr) !important;
    padding-inline: 16px !important;
    gap: 10px !important;
  }
  body[data-pdfdost-standalone-app="true"] .brand-logo,
  body[data-pdfdost-single-app="true"] .brand-logo,
  body[data-pdfdost-standalone-app="true"] .pdfbuddy-brand-block .brand-logo,
  body[data-pdfdost-single-app="true"] .pdfbuddy-brand-block .brand-logo {
    max-width: 280px !important;
  }
  body[data-pdfdost-standalone-app="true"] .nav-offline-btn,
  body[data-pdfdost-single-app="true"] .nav-offline-btn {
    display: none !important;
  }
}

@media (max-width: 860px) {
  :root { --pdfdost-direct-header-height: auto; }
  body[data-pdfdost-standalone-app="true"],
  body[data-pdfdost-single-app="true"] {
    height: auto !important;
    max-height: none !important;
    overflow: auto !important;
    display: block !important;
  }
  body[data-pdfdost-standalone-app="true"] .topbar.tool-topbar,
  body[data-pdfdost-single-app="true"] .topbar.tool-topbar {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    grid-template-columns: 1fr !important;
    padding: 8px 12px !important;
  }
  body[data-pdfdost-standalone-app="true"] .topbar-main,
  body[data-pdfdost-single-app="true"] .topbar-main,
  body[data-pdfdost-standalone-app="true"] .pdfbuddy-brand-block,
  body[data-pdfdost-single-app="true"] .pdfbuddy-brand-block {
    justify-content: center !important;
    width: 100% !important;
  }
  body[data-pdfdost-standalone-app="true"] .tool-nav,
  body[data-pdfdost-single-app="true"] .tool-nav {
    grid-column: 1 !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    max-height: none !important;
  }
  body[data-pdfdost-standalone-app="true"] .layout.tool-layout,
  body[data-pdfdost-single-app="true"] .layout.tool-layout {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    grid-template-columns: 1fr !important;
  }
  body[data-pdfdost-standalone-app="true"] .controls.tool-controls,
  body[data-pdfdost-single-app="true"] .controls.tool-controls,
  body[data-pdfdost-standalone-app="true"] #previewPanel,
  body[data-pdfdost-single-app="true"] #previewPanel {
    height: auto !important;
    max-height: none !important;
  }
  body[data-pdfdost-standalone-app="true"] .active-tool-header,
  body[data-pdfdost-single-app="true"] .active-tool-header {
    padding: 0 0 4px !important;
  }
}
