.edit-transaction-sidesheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  container-type: inline-size;
  position: relative;
}

.edit-transaction-sidesheet-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--spacing-05, 16px) var(--spacing-04, 12px) 0
    var(--spacing-04, 12px);
  background-color: var(--gray-01);
  position: sticky;
  top: var(--transaction-sidesheet-header-top, 40px);
  z-index: var(--z-index-sticky, 1020);
  transition: box-shadow var(--animation-duration, 0.3s)
      var(--animation-easing, ease-out),
    transform var(--animation-duration, 0.3s) var(--animation-easing, ease-out);
}

/* subtle visual elevation when the header is stuck */
.edit-transaction-sidesheet-header.is-sticky {
  box-shadow: var(--shadow-modal, 0px 8px 16px rgba(0, 0, 0, 0.1));
}

/* Ensure the body content grows and triggers the scroll behaviour
   inside .transaction-sidesheet, which allows the header to stick.
*/
.edit-transaction-sidesheet-body {
  padding: var(--spacing-04, 12px);
  height: calc(100vh - 250px);
  flex-grow: 1;
  overflow-y: auto;
}

.edit-transaction-sidesheet-header-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-05, 16px);
  /* margin-bottom: var(--spacing-05, 16px); */
}

.edit-transaction-sidesheet-header-items {
  /* Use flex-wrap so items take only the space they need and wrap
     to new lines when the container isn't wide enough. This avoids
     horizontal scrolling and keeps items compact.
  */
  display: flex;
  flex-direction: row;
  flex-wrap: wrap; /* allow items to wrap onto multiple lines */
  gap: var(--spacing-05, 12px);

  align-items: center;
}

/* Layout container holding header items + progress */
.edit-transaction-sidesheet-header-content {
  display: flex;
  flex-direction: row;
  /* allow the tabs to wrap onto their own row */
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.edit-transaction-sidesheet-header-items {
  /* take remaining space next to the progress */
  flex: 1 1 auto;
  padding-bottom: var(--spacing-03); /* handled by the grouping container */
}

.edit-transaction-sidesheet-header-progress {
  /* circular progress sits to the right and uses only necessary space */
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-transaction-sidesheet-tabs {
  /* ensure tabs always sit on a new line below the items + progress */
  order: 3; /* tabs after items and progress */
  flex: 0 0 100%; /* take full width */
  display: flex;
  align-items: center;
}

/* On small screens keep the original stacking behavior */
@media (max-width: 600px) {
  .edit-transaction-sidesheet-header-content {
    flex-direction: column;
    align-items: stretch;
  }
  .edit-transaction-sidesheet-header-progress {
    margin-left: 0;
  }
  .edit-transaction-sidesheet-header-items {
    margin-bottom: var(--spacing-05, 16px);
  }
}

.edit-transaction-sidesheet-header-item {
  min-width: 0; /* allow children to truncate inside grid cells */
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  scroll-snap-align: start; /*snap items when scrolling horizontally */
}

.edit-transaction-sidesheet-header-item .MuiTypography-caption {
  color: var(--muted-text, rgba(0, 0, 0, 0.6));
}

.edit-transaction-sidesheet-header-item .MuiTypography-body2,
.edit-transaction-sidesheet-header-item
  .transaction-sidesheet-header-item-status {
  /* allow item content to size intrinsically but cap extremely long
     values so they don't force a single row to overflow horizontally.
  */
  max-width: 40ch;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* keep compact on small screens */
}

.edit-transaction-sidesheet-header-buttons {
  display: flex;
  flex-direction: row;
  gap: 4px;
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--gray-03);
}

.edit-transaction-sidesheet-footer {
  padding-top: var(--spacing-04);
  padding-right: var(--spacing-05);
}

.edit-transaction-header-button-icon {
  margin-right: 8px;
}
