/* R707: restore the manual workspace controls that older theme layers hid.
   The controls were always present in index.html and their click handlers remained
   active; r120-rice-dashboard.css and several responsive theme rules applied
   display:none!important. This final stylesheet is deliberately narrow: it repairs
   only the header/action bar and does not recolor or redesign the workspace. */

body.r120-rice-ui .app-header,
body[data-active-page="dashboard"].r120-rice-ui .app-header {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  min-height: 76px !important;
  height: auto !important;
  overflow: visible !important;
}

body.r120-rice-ui .app-header .header-leading {
  flex: 0 1 auto !important;
  min-width: min(360px, 32vw) !important;
}

body.r120-rice-ui .app-header .header-tools {
  display: flex !important;
  flex: 1 1 auto !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  min-width: 0 !important;
  max-width: none !important;
  flex-wrap: wrap !important;
}

body.r120-rice-ui .app-header .header-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  flex: 0 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  flex-wrap: wrap !important;
  pointer-events: auto !important;
}

body.r120-rice-ui .app-header .header-actions #autosaveStatus,
body.r120-rice-ui .app-header .header-actions #saveButton,
body.r120-rice-ui .app-header .header-actions #loadButton,
body.r120-rice-ui .app-header .header-actions #clearAutosaveButton,
body.r120-rice-ui .app-header #themeButton {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.r120-rice-ui .app-header #themeButton {
  display: grid !important;
}

body.r120-rice-ui .app-header .header-actions #autosaveStatus {
  min-width: 132px !important;
  min-height: 38px !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 7px 11px !important;
  border-radius: 999px !important;
  white-space: nowrap !important;
}

body.r120-rice-ui .app-header .header-actions button {
  min-height: 40px !important;
  width: auto !important;
  max-width: none !important;
  padding: 8px 13px !important;
  white-space: nowrap !important;
  font-size: 12px !important;
  line-height: 1.15 !important;
  transform: none !important;
}

body.r120-rice-ui .app-header .header-actions #clearAutosaveButton {
  min-width: 150px !important;
}

/* Do not reintroduce the GPU-heavy header effects removed by the stability build. */
body.r120-rice-ui .app-header,
body.r120-rice-ui .app-header * {
  animation: none !important;
  transition-duration: 0s !important;
}
body.r120-rice-ui .app-header {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

@media (max-width: 1180px) {
  body.r120-rice-ui .app-header {
    align-items: flex-start !important;
    flex-wrap: wrap !important;
  }
  body.r120-rice-ui .app-header .header-leading {
    min-width: 220px !important;
  }
  body.r120-rice-ui .app-header .header-tools {
    width: 100% !important;
  }
  body.r120-rice-ui .app-header .header-actions {
    flex: 1 1 100% !important;
  }
}

@media (max-width: 760px) {
  body.r120-rice-ui .app-header {
    padding: 10px 12px !important;
  }
  body.r120-rice-ui .app-header .header-tools,
  body.r120-rice-ui .app-header .header-actions {
    justify-content: flex-start !important;
  }
  body.r120-rice-ui .app-header .topbar-health {
    display: inline-flex !important;
  }
  body.r120-rice-ui .app-header .header-actions #autosaveStatus {
    flex: 1 1 100% !important;
    justify-content: flex-start !important;
  }
  body.r120-rice-ui .app-header .header-actions #saveButton,
  body.r120-rice-ui .app-header .header-actions #loadButton {
    flex: 1 1 calc(50% - 8px) !important;
  }
  body.r120-rice-ui .app-header .header-actions #clearAutosaveButton {
    flex: 1 1 100% !important;
  }
}

/* Explicit flex sizing defeats older generic `.actions button { width:100% }` rules. */
body.r120-rice-ui .app-header .header-actions button {
  flex: 0 0 auto !important;
}
body.r120-rice-ui .app-header .header-actions #themeButton {
  flex: 0 0 44px !important;
  width: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
}

@media (max-width: 760px) {
  body.r120-rice-ui .app-header .header-actions #saveButton,
  body.r120-rice-ui .app-header .header-actions #loadButton {
    flex: 1 1 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    max-width: none !important;
  }
  body.r120-rice-ui .app-header .header-actions #clearAutosaveButton {
    flex: 1 1 100% !important;
    width: 100% !important;
  }
}

@media (max-width: 760px) {
  body.r120-rice-ui .app-header .header-actions {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) !important;
    width: 100% !important;
    gap: 8px !important;
  }
  body.r120-rice-ui .app-header .header-actions #autosaveStatus {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
  body.r120-rice-ui .app-header .header-actions #themeButton {
    grid-column: 1 !important;
    width: 44px !important;
  }
  body.r120-rice-ui .app-header .header-actions #saveButton {
    grid-column: 2 !important;
    width: 100% !important;
  }
  body.r120-rice-ui .app-header .header-actions #loadButton {
    grid-column: 3 !important;
    width: 100% !important;
  }
  body.r120-rice-ui .app-header .header-actions #clearAutosaveButton {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
}
