/* Centiva 2.30.0 — viewport-safe modal layout + notification builder reflow */

/* Global modal contract: the modal content is the only vertical scroll owner. */
.ctv-modal-layer .ctv-modal-card{
  box-sizing:border-box;
  max-width:calc(100vw - 24px)!important;
  max-height:calc(100dvh - 24px)!important;
  min-width:0!important;
  min-height:0!important;
  overflow:hidden!important;
}
.ctv-modal-layer .ctv-modal-card #ctvModalContent{
  box-sizing:border-box;
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
  min-height:0!important;
  max-height:calc(100dvh - 44px)!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
.ctv-modal-layer .ctv-modal-card #ctvModalContent > *{
  box-sizing:border-box;
  max-width:100%!important;
  min-width:0!important;
}
.ctv-modal-layer .ctv-modal-card #ctvModalContent :where(
  .ctv-grid,.ctv-grid-2,.ctv-grid-3,.ctv-form-grid,.ctv-detail-grid,.ctv-ui-grid,
  .ctv-work-grid,.ctv-notify-layout,.ctv-notifications-layout,.ctv-event-layout,.ctv-rule-layout,.ctv-log-layout
){min-width:0!important;max-width:100%!important;}
.ctv-modal-layer .ctv-modal-card #ctvModalContent :where(input,select,textarea,.select2-container,.select2-selection){
  box-sizing:border-box;max-width:100%!important;min-width:0!important;
}
.ctv-modal-layer .ctv-modal-card #ctvModalContent :where(.ctv-real-table-wrap,.ctv-data-table-wrap,.ctv-table-wrap){
  max-width:100%!important;min-width:0!important;overflow-x:auto!important;overflow-y:visible!important;
  -webkit-overflow-scrolling:touch;
}

/* Notification rule builder: no horizontal palette/canvas scrollbars. */
.ctv-modal-card.ctv-notify-wide-modal{
  width:min(1480px,calc(100vw - 24px))!important;
  height:min(900px,calc(100dvh - 24px))!important;
  max-height:calc(100dvh - 24px)!important;
}
.ctv-modal-card.ctv-notify-wide-modal #ctvModalContent{
  height:100%!important;
  max-height:100%!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  padding:0!important;
}
.ctv-notify-builder{
  position:relative!important;
  height:auto!important;
  min-height:100%!important;
  overflow:visible!important;
  display:flex!important;
  flex-direction:column!important;
  gap:10px!important;
  padding:14px 14px 78px!important;
}
.ctv-notify-builder :where(.ctv-notify-saved,.ctv-notify-event-strip,.ctv-notify-bottom-card,.ctv-notify-form,.ctv-notify-canvas){
  min-width:0!important;max-width:100%!important;
}
.ctv-notify-rule-list{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr))!important;
  gap:8px!important;
  min-height:0!important;
  max-height:none!important;
  overflow:visible!important;
  padding:2px!important;
}
.ctv-notify-rule-card{min-width:0!important;max-width:none!important;width:100%!important;}
.ctv-notify-h-palette{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(170px,1fr))!important;
  gap:7px!important;
  width:100%!important;
  max-width:100%!important;
  overflow:visible!important;
  padding:2px!important;
}
.ctv-notify-palette-item{
  width:100%!important;
  min-width:0!important;
  max-width:none!important;
  white-space:normal!important;
}
.ctv-notify-palette-item strong,.ctv-notify-palette-item small{
  white-space:normal!important;overflow:visible!important;text-overflow:clip!important;overflow-wrap:anywhere;
}
.ctv-notify-canvas{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:8px!important;
  overflow:visible!important;
  padding:10px!important;
  min-height:0!important;
}
.ctv-notify-connector{display:none!important;}
.ctv-notify-node{min-width:0!important;min-height:150px!important;}
.ctv-node-drop{overflow:visible!important;max-width:100%!important;}
.ctv-notify-token{max-width:100%!important;white-space:normal!important;overflow-wrap:anywhere;}
.ctv-notify-bottom-palettes{grid-template-columns:1fr 1fr!important;min-width:0!important;}
.ctv-notify-actions.ctv-modal-actions{
  position:sticky!important;
  right:auto!important;left:auto!important;bottom:0!important;
  margin-top:auto!important;
  padding:10px 4px 2px!important;
  border-top:1px solid #e5ecf6!important;
  background:linear-gradient(180deg,rgba(249,251,255,.92),#f9fbff 35%)!important;
  backdrop-filter:blur(8px);
  z-index:5;
}

/* Events modal: one scroll surface; cards reflow instead of becoming unreachable. */
.ctv-modal-card.ctv-notify-events-modal,.ctv-modal-card.ctv-notify-logs-modal{
  width:min(1380px,calc(100vw - 24px))!important;
  height:min(880px,calc(100dvh - 24px))!important;
  max-height:calc(100dvh - 24px)!important;
}
.ctv-modal-card.ctv-notify-events-modal #ctvModalContent,
.ctv-modal-card.ctv-notify-logs-modal #ctvModalContent{
  height:100%!important;max-height:100%!important;overflow-y:auto!important;overflow-x:hidden!important;
}
.ctv-notify-events-view,.ctv-notify-queue-view,.ctv-notify-rule-view{
  min-width:0!important;max-width:100%!important;min-height:100%;padding:14px 14px 72px!important;box-sizing:border-box;
}
.ctv-notify-events-body{
  height:auto!important;max-height:none!important;overflow:visible!important;padding:0!important;
}
.ctv-event-module-block{min-width:0!important;max-width:100%!important;}
.ctv-notify-events-grid{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr))!important;
  gap:10px!important;
  min-width:0!important;max-width:100%!important;
}
.ctv-notify-event-card{min-width:0!important;max-width:100%!important;overflow:hidden!important;}
.ctv-event-vars{max-width:100%!important;overflow:visible!important;}
.ctv-event-vars code{white-space:normal!important;overflow-wrap:anywhere;}
.ctv-event-settings{
  display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto!important;gap:7px!important;min-width:0!important;
}
.ctv-event-settings label{min-width:0!important;}
.ctv-event-settings input{min-width:0!important;max-width:100%!important;}

/* Custom recipient overlay keeps its own bounded body because it is an overlay within the modal. */
.ctv-custom-recipient-popover{
  position:fixed!important;
  inset:auto 50% max(18px,env(safe-area-inset-bottom)) auto!important;
  transform:translateX(50%)!important;
  width:min(860px,calc(100vw - 32px))!important;
  max-height:min(620px,calc(100dvh - 48px))!important;
}
.ctv-custom-popover-body{max-height:calc(100dvh - 150px)!important;overflow-y:auto!important;overflow-x:hidden!important;}
.ctv-custom-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;min-width:0!important;}

@media (max-width:1180px){
  .ctv-notify-form{grid-template-columns:1fr 1fr!important;}
  .ctv-notify-form .ctv-field-wide{grid-column:1/-1!important;}
  .ctv-notify-canvas{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .ctv-notify-bottom-palettes{grid-template-columns:1fr!important;}
  .ctv-notify-h-palette{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))!important;}
  .ctv-event-settings{grid-template-columns:1fr 1fr!important;}
  .ctv-event-settings button{grid-column:1/-1!important;width:100%!important;}
}

@media (max-width:760px){
  .ctv-modal-layer .ctv-modal-card{
    width:100vw!important;max-width:100vw!important;height:100dvh!important;max-height:100dvh!important;
    border-radius:0!important;margin:0!important;
  }
  .ctv-modal-layer .ctv-modal-card #ctvModalContent{height:100dvh!important;max-height:100dvh!important;padding-bottom:env(safe-area-inset-bottom)!important;}
  .ctv-notify-builder,.ctv-notify-events-view,.ctv-notify-queue-view,.ctv-notify-rule-view{padding:12px 10px calc(78px + env(safe-area-inset-bottom))!important;}
  .ctv-notify-builder .ctv-modal-head,.ctv-notify-events-view .ctv-modal-head,.ctv-notify-logs-view .ctv-modal-head{padding-right:38px!important;}
  .ctv-notify-form{grid-template-columns:1fr!important;}
  .ctv-notify-form .ctv-field-wide{grid-column:auto!important;}
  .ctv-notify-rule-list,.ctv-notify-h-palette,.ctv-notify-canvas,.ctv-notify-events-grid,.ctv-custom-grid{grid-template-columns:1fr!important;}
  .ctv-notify-node{min-height:126px!important;}
  .ctv-notify-actions.ctv-modal-actions{padding-bottom:max(8px,env(safe-area-inset-bottom))!important;flex-wrap:wrap!important;}
  .ctv-notify-actions.ctv-modal-actions button{flex:1 1 160px!important;min-height:44px!important;}
  .ctv-custom-recipient-popover{width:calc(100vw - 16px)!important;max-height:calc(100dvh - 16px)!important;bottom:8px!important;border-radius:18px!important;}
  .ctv-custom-popover-body{max-height:calc(100dvh - 128px)!important;}
  .ctv-event-settings{grid-template-columns:1fr!important;}
  .ctv-event-settings button{grid-column:auto!important;}
}

@media (max-height:720px) and (min-width:761px){
  .ctv-modal-layer .ctv-modal-card{max-height:calc(100dvh - 12px)!important;}
  .ctv-modal-card.ctv-notify-wide-modal,.ctv-modal-card.ctv-notify-events-modal,.ctv-modal-card.ctv-notify-logs-modal{height:calc(100dvh - 12px)!important;}
  .ctv-notify-builder{padding-top:10px!important;gap:7px!important;}
  .ctv-notify-node{min-height:126px!important;}
  .ctv-notify-rule-list{grid-template-columns:repeat(auto-fit,minmax(205px,1fr))!important;}
}
.ctv-vmware-schema-warning{display:flex;align-items:flex-start;gap:9px;width:100%;padding:10px 12px;border:1px solid #f4d58d;background:#fffaf0;border-radius:14px;color:#7c5700}.ctv-vmware-schema-warning .ctv-line-icon{flex:0 0 28px;width:28px;height:28px;border-radius:9px;background:#fff3cd}.ctv-vmware-schema-warning span{display:grid;gap:3px;min-width:0}.ctv-vmware-schema-warning strong{font-size:12px}.ctv-vmware-schema-warning small{font-size:10.5px;color:#8b6a1a;line-height:1.8}

/* Neutralize legacy negative mobile footer offsets. */
.ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-modal-actions,
.ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-modal-footer,
.ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-wizard-footer{
  position:sticky!important;
  bottom:0!important;
  right:auto!important;left:auto!important;
  margin:14px 0 0!important;
  padding:10px 0 max(10px,env(safe-area-inset-bottom))!important;
  background:linear-gradient(180deg,rgba(255,255,255,.90),#fff 38%)!important;
  border-top:1px solid #e8eef7!important;
  box-shadow:0 -8px 24px rgba(15,28,50,.06)!important;
  z-index:12!important;
}
.ctv-modal-layer .ctv-modal-card #ctvModalContent :where(.ctv-notify-roles-grid,.ctv-notify-log-table){
  height:auto!important;max-height:none!important;overflow-y:visible!important;overflow-x:hidden!important;
}
@media(max-width:760px){
  .ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-modal-actions,
  .ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-modal-footer,
  .ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-wizard-footer{
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:7px!important;
  }
  .ctv-modal-layer .ctv-modal-card #ctvModalContent .ctv-modal-actions>*{min-width:0!important;width:100%!important;}
}
