/* Volume 2 audit: scoped component corrections after the legacy theme layers.
   Keep state, permissions and record actions in their existing controllers. */

/* 1. Scrolling tabs and persistent tools have distinct, separated hit areas. */
#app .workspace-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#app .workspace-tab-list {
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  gap: 6px;
  padding-inline-end: 4px;
  scrollbar-width: none;
}
#app .workspace-tab-tools {
  position: static;
  flex: 0 0 auto;
  align-self: center;
  gap: 6px;
  padding: 0;
  margin: 0;
}
#app .workspace-tab-group {
  flex: 0 0 auto;
  grid-template-columns: minmax(68px, 1fr) 32px;
}
#app .workspace-tab-close {
  position: static;
  width: 32px;
  min-width: 32px;
}
#app .workspace-tab-tools .workspace-tab-add {
  width: 32px;
  min-width: 32px;
  border-radius: 7px;
}

/* 2. One native, labelled language control; no nested pill or white sliver. */
#app .language-switch {
  display: inline-flex;
  flex: 0 0 auto;
  width: max-content;
  min-width: 0;
  height: auto;
  min-height: 0;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}
#app .language-switch > span { display: none; }
#app .language-switch select[data-language] {
  box-sizing: border-box;
  display: block;
  width: auto;
  min-width: 65px;
  height: 34px;
  min-height: 34px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  appearance: auto;
}

/* 3. Counts are a joined trailing segment, not a floating inner badge. */
#app .workspace-filter-chip {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  min-height: 34px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}
#app .workspace-filter-chip > span {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
}
#app .workspace-filter-chip > .ui-count-badge {
  flex: 0 0 auto;
  align-self: stretch;
  width: auto;
  min-width: 30px;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0 7px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-2);
  color: var(--text);
}
#app .workspace-filter-chip.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary);
}
#app .workspace-filter-chip.active > .ui-count-badge {
  border-inline-start-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  color: var(--primary);
}

/* 4. A shared reading column, quiet messages and aligned context badges. */
#app .inbox-message-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  gap: 4px 10px;
  margin: 0;
  padding: 7px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#app .inbox-message-card.is-focused {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
#app .inbox-message-avatar { grid-column: 1; grid-row: 1; }
#app .inbox-message-avatar .avatar {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
}
#app .inbox-message-body {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 0;
}
#app .inbox-message-head { gap: 4px 8px; }
#app .inbox-message-head > strong { font-size: 13px; }
#app .inbox-message-head > span:not(.badge) { font-size: 11px; font-weight: 500; }
#app .inbox-message-body > p { margin: 4px 0 6px; font-size: 14px; line-height: 1.45; }
#app .inbox-message-foot {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
}
#app .inbox-message-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  margin: 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* 5. Match the current two-child form; expanded options get the full row. */
#app .task-lite-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 10px;
  border-radius: 10px;
  box-shadow: none;
}
#app .task-lite-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
#app .task-lite-title-row > :is(input, button) {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
  margin: 0;
}
#app .task-lite-options { min-width: 0; margin: 0; }
#app .task-lite-options > summary {
  box-sizing: border-box;
  min-height: 40px;
  padding: 11px 4px;
  color: var(--muted);
  line-height: 18px;
}
#app .task-lite-create:has(.task-lite-options[open]) { grid-template-columns: minmax(0, 1fr); }
#app .task-lite-option-grid { margin-top: 4px; }
#app .task-lite-filters {
  box-sizing: border-box;
  display: flex;
  width: 100%;
  max-width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin: 0;
  padding: 6px 12px;
  border-inline: 0;
  border-radius: 0;
  background: var(--surface-2);
  box-shadow: none;
  overflow-x: auto;
}

/* 6–8. One document gutter, unboxed headings, user-controlled categories. */
#app .docs-document { --docs-gutter: 14px; padding: 0; }
#app .docs-document-head {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--docs-gutter);
  background: transparent;
  box-shadow: none;
}
#app .docs-section-grid { margin: 0; padding: var(--docs-gutter); }
#app .docs-actions { margin: 0; padding: 0 var(--docs-gutter) var(--docs-gutter); }
#app .page-header {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  background: transparent;
  box-shadow: none;
}
#app .docs-nav-group { display: block; margin: 0; padding: 0; }
#app .docs-nav .docs-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: start;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
#app .docs-group-toggle[aria-expanded="true"] { background: var(--surface-2); }
#app .docs-group-toggle > .icon { width: 14px; height: 14px; transform: rotate(0deg); }
#app .docs-group-toggle[aria-expanded="true"] > .icon { transform: rotate(90deg); }
#app .docs-nav-links { display: grid; gap: 3px; padding: 4px 0 8px 8px; }
#app .docs-nav-links[hidden] { display: none; }
#app .docs-group-toggle:focus-visible,
#app .language-switch select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 9. Marketing detail starts with the data column, without a sticky offset. */
#app .split-page[data-module-workspace="Marketing"] { align-items: start; }
#app .split-page[data-module-workspace="Marketing"] > .context-panel {
  position: static;
  align-self: start;
  top: auto;
  margin-top: 0;
}
#app .email-template-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: none;
}

/* 10. Upload alone is a true viewport dialog, not an inherited side drawer. */
#app .drawer.open[data-drawer-kind="upload"] {
  box-sizing: border-box;
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(560px, calc(100vw - 32px));
  min-width: 0;
  height: auto;
  min-height: 0;
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
  transform: translate(-50%, -50%);
}
#app .drawer[data-drawer-kind="upload"] > :is(.drawer-header, .drawer-footer) {
  flex: 0 0 auto;
  padding: 12px 14px;
}
#app .drawer[data-drawer-kind="upload"] > .drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  overscroll-behavior: contain;
}

@media (max-width: 760px) {
  #app .workspace-tabs { gap: 8px; }
  #app .workspace-tab-group { min-width: 102px; max-width: 154px; }
  #app .language-switch select[data-language] { min-height: 40px; height: 40px; font-size: 16px; }
  #app .workspace-filter-chip { min-height: 36px; }
  #app .inbox-message-card { gap: 4px 8px; padding: 6px 2px; }
  #app .inbox-message-toolbar { grid-column: 2; grid-row: 2; }
  #app .task-lite-create { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 8px; }
  #app .task-lite-title-row > input { font-size: 16px; }
  #app .task-lite-options > summary { min-height: 36px; padding-block: 9px; }
  #app .task-lite-option-grid { grid-template-columns: minmax(0, 1fr); }
  #app .task-lite-filters { padding-inline: 10px; }
  #app .docs-document { --docs-gutter: 10px; }
  #app .docs-group-toggle { min-height: 44px; }
  #app .drawer.open[data-drawer-kind="upload"] { width: calc(100vw - 16px); }
}
