/* GMDR UI Stability Patch */

/* Keep old experiments from leaking into current production UI */
.gmdr-fx-journey,
.gmdr-fx-summary-strip,
.gmdr-fx-toolbar {
  display: none !important;
}

/* Workbench page hygiene */
body.gmdr-workbench-page .gmdr-workbench {
  margin-top: 18px !important;
}

body.gmdr-workbench-page .gmdr-workbench-list {
  gap: 12px !important;
}

body.gmdr-workbench-page .gmdr-workitem {
  overflow: visible !important;
}

body.gmdr-workbench-page .gmdr-workitem-top {
  padding: 16px 20px !important;
}

body.gmdr-workbench-page .gmdr-workitem-body {
  padding: 14px 20px 16px !important;
}

body.gmdr-workbench-page .gmdr-workitem-action {
  min-height: auto !important;
  align-items: center !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-text {
  line-height: 1.4 !important;
}

/* The main fix: actions must not become giant blocks */
body.gmdr-workbench-page .gmdr-workitem-action-buttons {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  justify-content: flex-end !important;
  align-items: center !important;
  min-width: 220px !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-buttons form {
  display: inline-flex !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-buttons a,
body.gmdr-workbench-page .gmdr-workitem-action-buttons button,
body.gmdr-workbench-page .gmdr-workitem-action-buttons input[type="submit"] {
  width: auto !important;
  max-width: 180px !important;
  min-width: 0 !important;
  min-height: 38px !important;
  height: 38px !important;
  padding: 8px 13px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  line-height: 1.1 !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-buttons .gmdr-action-primary {
  background: #29b6f6 !important;
  border-color: #29b6f6 !important;
  color: #fff !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-buttons .gmdr-action-secondary {
  background: #fff !important;
  border: 1px solid #ebe5de !important;
  color: #102f4e !important;
}

body.gmdr-workbench-page .gmdr-workitem-action-buttons .gmdr-action-disabled,
body.gmdr-workbench-page .gmdr-workitem-action-buttons [disabled] {
  opacity: .45 !important;
  cursor: not-allowed !important;
}

/* Better card density */
body.gmdr-workbench-page .gmdr-workitem-value,
body.gmdr-workbench-page .gmdr-workitem-action-text {
  overflow-wrap: anywhere !important;
}

body.gmdr-workbench-page .gmdr-workitem-title {
  overflow-wrap: anywhere !important;
}

/* Prepared page: long draft text should not dominate the whole card */
body.gmdr-workbench-page .gmdr-workitem-field {
  min-width: 0 !important;
}

body.gmdr-workbench-page .gmdr-workitem-field .gmdr-workitem-value {
  max-width: 100% !important;
}

/* Floating buttons should not cover final card actions */
body.gmdr-workbench-page .gmdr-pro-floating {
  right: 20px !important;
  bottom: 20px !important;
  opacity: .92 !important;
}

body.gmdr-workbench-page .gmdr-pro-floating:hover {
  opacity: 1 !important;
}

/* Generic page protection */
body:not(.gmdr-workbench-page) .gmdr-workbench {
  display: none !important;
}

/* Tables on non-workbench pages should remain tables, not hacked cards */
body:not(.gmdr-workbench-page) .gmdr-mobile-card-list {
  display: none !important;
}

/* Responsive */
@media (max-width: 980px) {
  body.gmdr-workbench-page .gmdr-workitem-action-buttons {
    justify-content: flex-start !important;
    min-width: 0 !important;
  }

  body.gmdr-workbench-page .gmdr-workitem-action-buttons a,
  body.gmdr-workbench-page .gmdr-workitem-action-buttons button,
  body.gmdr-workbench-page .gmdr-workitem-action-buttons input[type="submit"] {
    max-width: 100% !important;
  }
}

@media (max-width: 620px) {
  body.gmdr-workbench-page .gmdr-workitem-action-buttons {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  body.gmdr-workbench-page .gmdr-workitem-action-buttons a,
  body.gmdr-workbench-page .gmdr-workitem-action-buttons button,
  body.gmdr-workbench-page .gmdr-workitem-action-buttons input[type="submit"] {
    width: 100% !important;
  }
}
