/* Stage 4 Organisation B5 — Unterhaltungen.
   Scope: communication workspace, thread list, conversation, details rail and composer.
   Behavior and DOM remain unchanged. */

.tool-organisation .communication-workspace {
  min-width: 0;
  gap: var(--zg-space-4);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.tool-organisation :is(.communication-toolbar, .thread-list, .thread-view, .thread-details, .communication-empty) {
  overflow: hidden;
  border: 1px solid var(--zg-border-soft);
  border-radius: var(--zg-radius-lg);
  background: var(--zg-surface-card);
  box-shadow: var(--zg-shadow-soft);
}

.tool-organisation .communication-toolbar {
  gap: var(--zg-space-3);
  padding: var(--zg-card-padding);
  border-bottom: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .communication-toolbar > div {
  gap: var(--zg-space-3);
}

.tool-organisation .communication-toolbar h2 {
  color: var(--zg-text-primary);
  font-size: var(--zg-font-h3);
  line-height: var(--zg-line-height-heading);
}

.tool-organisation .communication-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--zg-radius-md);
  background: var(--zg-accent-secondary);
  color: var(--zg-accent-primary);
}

.tool-organisation .communication-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-organisation .communication-toolbar label {
  min-width: 0;
}

.tool-organisation .communication-toolbar label input {
  width: 100%;
  min-height: var(--zg-input-height);
  padding: 0 var(--zg-space-4);
  border: 1px solid var(--zg-border-default);
  border-radius: var(--zg-radius-md);
  background: var(--zg-surface-card);
  color: var(--zg-text-primary);
}

.tool-organisation .communication-toolbar label input::placeholder,
.tool-organisation .message-composer input::placeholder {
  color: var(--zg-text-muted);
}

.tool-organisation .communication-toolbar label input:focus,
.tool-organisation .message-composer input:focus,
.tool-organisation .thread-details select:focus {
  border-color: var(--zg-accent-primary);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--zg-accent-primary) 18%, transparent);
}

.tool-organisation .thread-list {
  min-width: 0;
  border-right: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .thread-list > nav {
  gap: var(--zg-space-1);
  padding: var(--zg-space-2) var(--zg-space-3) 0;
  border-bottom: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .thread-list > nav button {
  min-height: 38px;
  padding: 0 var(--zg-space-3);
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--zg-text-muted);
  font-size: var(--zg-font-caption);
  font-weight: 600;
}

.tool-organisation .thread-list > nav button:hover {
  background: var(--zg-surface-hover);
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-list > nav button.is-active {
  border-bottom-color: var(--zg-accent-primary);
  color: var(--zg-accent-primary);
}

.tool-organisation .thread-list-item {
  gap: var(--zg-space-2);
  padding: var(--zg-space-4);
  border-bottom: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-list-item:hover {
  background: var(--zg-surface-hover);
}

.tool-organisation .thread-list-item.is-active {
  background: color-mix(in srgb, var(--zg-accent-secondary) 55%, white);
  box-shadow: inset 3px 0 var(--zg-accent-primary);
}

.tool-organisation .thread-list-top {
  gap: var(--zg-space-2);
}

.tool-organisation .thread-list-top strong {
  color: var(--zg-text-primary);
  font-size: var(--zg-font-body-sm);
}

.tool-organisation .thread-list-top time,
.tool-organisation .thread-preview,
.tool-organisation .thread-list > footer {
  color: var(--zg-text-muted);
}

.tool-organisation .thread-preview {
  font-size: var(--zg-font-caption);
}

.tool-organisation .thread-list-bottom {
  gap: var(--zg-space-2);
}

.tool-organisation .conversation-avatars i {
  border-color: var(--zg-surface-card);
  background: var(--zg-neutral-200);
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-list-bottom > span:not(.conversation-avatars),
.tool-organisation .thread-context {
  gap: var(--zg-space-1);
}

.tool-organisation .thread-list-bottom b,
.tool-organisation .thread-context > span,
.tool-organisation .thread-status {
  border-radius: var(--zg-radius-sm);
  font-weight: 600;
}

.tool-organisation .context-project {
  background: var(--zg-accent-secondary);
  color: color-mix(in srgb, var(--zg-accent-primary) 58%, black);
}

.tool-organisation .context-area {
  background: var(--zg-state-warning-soft);
  color: var(--zg-state-warning);
}

.tool-organisation .context-task {
  background: color-mix(in srgb, var(--zg-state-warning-soft) 72%, white);
  color: var(--zg-state-warning);
}

.tool-organisation .context-note {
  background: var(--zg-state-success-soft);
  color: var(--zg-state-success);
}

.tool-organisation .context-board {
  background: var(--zg-neutral-100);
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-status {
  background: color-mix(in srgb, var(--zg-accent-secondary) 62%, white);
  color: var(--zg-accent-primary);
}

.tool-organisation .thread-view {
  min-width: 0;
  background: var(--zg-surface-card);
}

.tool-organisation .thread-view > header {
  gap: var(--zg-space-3);
  padding: var(--zg-card-padding);
  border-bottom: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .thread-view h2 {
  margin-bottom: var(--zg-space-2);
  color: var(--zg-text-primary);
  font-size: var(--zg-font-body);
  line-height: var(--zg-line-height-heading);
}

.tool-organisation .thread-view > header > button,
.tool-organisation .thread-actions-trigger {
  color: var(--zg-text-muted);
}

.tool-organisation .thread-members {
  color: var(--zg-text-muted);
}

.tool-organisation .thread-messages {
  padding: var(--zg-card-padding);
  background: var(--zg-surface-subtle);
}

.tool-organisation .message-day {
  gap: var(--zg-space-3);
  color: var(--zg-text-muted);
}

.tool-organisation .message-day::before,
.tool-organisation .message-day::after {
  background: var(--zg-border-soft);
}

.tool-organisation .message {
  gap: var(--zg-space-2);
  margin-bottom: var(--zg-space-4);
}

.tool-organisation .message > i {
  background: var(--zg-neutral-200);
  color: var(--zg-text-secondary);
}

.tool-organisation .message > div {
  padding: var(--zg-space-3) var(--zg-space-4);
  border: 1px solid var(--zg-border-soft);
  border-radius: var(--zg-radius-lg);
  background: var(--zg-surface-card);
  box-shadow: var(--zg-shadow-soft);
}

.tool-organisation .message.is-own > div {
  border-color: var(--zg-accent-border);
  background: color-mix(in srgb, var(--zg-accent-secondary) 62%, white);
}

.tool-organisation .message strong {
  color: var(--zg-text-secondary);
}

.tool-organisation .message p {
  color: var(--zg-text-primary);
  font-size: var(--zg-font-body-sm);
  line-height: 1.55;
}

.tool-organisation .message time {
  color: var(--zg-text-muted);
}

.tool-organisation .message-attachment {
  gap: var(--zg-space-2);
  padding: var(--zg-space-2) var(--zg-space-3);
  border: 1px solid var(--zg-border-soft);
  border-radius: var(--zg-radius-md);
  background: var(--zg-surface-card);
  color: var(--zg-text-secondary);
}

.tool-organisation .message-attachment:hover {
  border-color: var(--zg-accent-border);
  background: var(--zg-surface-hover);
}

.tool-organisation .message-composer {
  gap: var(--zg-space-2);
  padding: var(--zg-space-3) var(--zg-card-padding);
  border-top: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .message-composer input {
  min-width: 0;
  min-height: var(--zg-input-height);
  padding: 0 var(--zg-space-4);
  border: 1px solid var(--zg-border-default);
  border-radius: var(--zg-radius-md);
  background: var(--zg-surface-card);
  color: var(--zg-text-primary);
}

.tool-organisation .message-composer button {
  width: var(--zg-button-icon-size);
  height: var(--zg-button-icon-size);
  border: 1px solid var(--zg-border-default);
  border-radius: var(--zg-radius-md);
  background: var(--zg-surface-card);
  color: var(--zg-text-secondary);
}

.tool-organisation .message-composer button:hover {
  border-color: var(--zg-accent-border);
  background: var(--zg-surface-hover);
}

.tool-organisation .message-composer .message-send {
  border-color: var(--zg-accent-primary);
  background: var(--zg-accent-primary);
  color: var(--zg-text-on-accent);
}

.tool-organisation .message-composer .message-send:hover {
  background: var(--zg-accent-hover);
}

.tool-organisation .message-file-selection {
  grid-column: 2 / -1;
  color: var(--zg-text-muted);
  font-size: var(--zg-font-caption);
}

.tool-organisation .thread-details {
  min-width: 0;
  border-left: 1px solid var(--zg-border-soft);
  background: var(--zg-surface-card);
}

.tool-organisation .thread-details > header {
  padding: var(--zg-space-4);
  border-bottom: 1px solid var(--zg-border-soft);
}

.tool-organisation .thread-details h2 {
  color: var(--zg-text-primary);
  font-size: var(--zg-font-body-sm);
}

.tool-organisation .thread-details > header button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--zg-border-soft);
  border-radius: var(--zg-radius-sm);
  background: var(--zg-surface-card);
  color: var(--zg-text-muted);
}

.tool-organisation .thread-details > header button:hover {
  border-color: var(--zg-accent-border);
  background: var(--zg-surface-hover);
  color: var(--zg-accent-primary);
}

.tool-organisation .thread-details > header button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-organisation .thread-detail-context > div,
.tool-organisation .thread-details > section,
.tool-organisation .thread-details > label,
.tool-organisation .thread-details > dl > div {
  gap: var(--zg-space-1);
  padding: var(--zg-space-3) var(--zg-space-4);
  border-bottom: 1px solid var(--zg-border-soft);
}

.tool-organisation .thread-details span,
.tool-organisation .thread-details dt {
  color: var(--zg-text-muted);
}

.tool-organisation .thread-details strong,
.tool-organisation .thread-details dd {
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-details select {
  min-height: var(--zg-input-height-compact);
  padding: 0 var(--zg-space-3);
  border: 1px solid var(--zg-border-default);
  border-radius: var(--zg-radius-md);
  background: var(--zg-surface-card);
  color: var(--zg-text-primary);
}

.tool-organisation .thread-actions-menu {
  border: 1px solid var(--zg-border-soft);
  border-radius: var(--zg-radius-lg);
  background: var(--zg-surface-floating);
  box-shadow: var(--zg-shadow-floating);
}

.tool-organisation .thread-actions-menu button {
  color: var(--zg-text-secondary);
}

.tool-organisation .thread-actions-menu button:hover {
  background: var(--zg-surface-hover);
}

.tool-organisation .thread-actions-menu button.is-danger {
  color: var(--zg-state-danger);
}

.tool-organisation .details-rail-collapsed .thread-details {
  width: 52px;
  min-width: 52px;
  overflow: hidden;
}

.tool-organisation .details-rail-collapsed .thread-details > :not(header) {
  display: none;
}

.tool-organisation .details-rail-collapsed .thread-details > header {
  justify-content: center;
  padding-inline: var(--zg-space-2);
}

.tool-organisation .details-rail-collapsed .thread-details > header h2,
.tool-organisation .details-rail-collapsed .thread-edit-button {
  display: none;
}

@media (max-width: 1100px) {
  .tool-organisation .communication-workspace,
  .tool-organisation .communication-workspace.details-hidden {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: var(--zg-space-3);
  }

  .tool-organisation .communication-toolbar {
    grid-template-columns: 280px minmax(220px, 1fr) auto;
  }

  .tool-organisation .communication-detail-toggle {
    display: none;
  }

  .tool-organisation .thread-details {
    display: none;
  }
}

@media (max-width: 760px) {
  .tool-organisation .communication-workspace,
  .tool-organisation .communication-workspace.details-hidden {
    display: grid;
    gap: var(--zg-space-3);
  }

  .tool-organisation .communication-toolbar {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .tool-organisation .communication-toolbar > div {
    min-width: 0;
    flex: 1 1 auto;
  }

  .tool-organisation .communication-toolbar label {
    order: 3;
    width: 100%;
  }

  .tool-organisation .communication-toolbar [data-communication-create] {
    flex: 0 0 auto;
  }

  .tool-organisation .thread-list {
    max-height: 600px;
    border-right: 0;
  }

  .tool-organisation .thread-view {
    min-height: 650px;
    border-top: 1px solid var(--zg-border-soft);
  }

  .tool-organisation .communication-workspace:has(.thread-list-item.is-active) .thread-list {
    display: none;
  }

  .tool-organisation .message > div {
    max-width: 85%;
  }
}

@media (max-width: 430px) {
  .tool-organisation .communication-toolbar {
    padding: var(--zg-space-3);
  }

  .tool-organisation .communication-toolbar h2 {
    font-size: var(--zg-font-body);
  }

  .tool-organisation .communication-icon {
    width: 36px;
    height: 36px;
  }

  .tool-organisation .communication-toolbar [data-communication-create] {
    width: 100%;
    order: 4;
  }

  .tool-organisation .thread-view > header,
  .tool-organisation .thread-messages,
  .tool-organisation .message-composer {
    padding-inline: var(--zg-space-3);
  }

  .tool-organisation .message > div {
    max-width: calc(100% - 44px);
  }
}
