/* Messenger variant of the existing team cards and shared controls. */
.ai-team-workspace {
  --team-ink: var(--text, #172033);
  --team-muted: var(--muted, #64748b);
  --team-line: var(--border, #dce3ed);
  --team-surface: var(--card, #fff);
  --team-soft: var(--bg, #f5f7fb);
  --team-accent: var(--accent, #4f46e5);
  color: var(--team-ink);
  max-width: 1440px;
  margin: auto;
}
.ai-team-workspace [hidden] {
  display: none !important;
}
.ai-team-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}
.ai-team-heading h1 {
  font-size: 28px;
  line-height: 36px;
  margin: 4px 0 8px;
  letter-spacing: -0.6px;
}
.ai-team-heading p {
  margin: 0;
  color: var(--team-muted);
  font-size: 14px;
  line-height: 20px;
}
.ai-team-eyebrow {
  color: var(--team-muted);
  font-size: 12px;
  line-height: 16px;
}
.ai-team-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--team-line);
  margin-bottom: 24px;
  overflow-x: auto;
}
.ai-team-tabs button {
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--team-muted);
  padding: 12px 20px;
  white-space: nowrap;
  min-height: 44px;
  box-shadow: none;
}
.ai-team-tabs button[aria-selected="true"] {
  color: var(--team-accent);
  background: var(--team-surface);
  border-bottom: 3px solid currentColor;
  font-weight: 700;
}
.ai-team-messenger {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  border: 1px solid var(--team-line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--team-surface);
  height: calc(100dvh - 200px);
  min-height: 480px;
}
.ai-team-contacts {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 12px 12px;
  border-right: 1px solid var(--team-line);
  background: var(--team-soft);
}
.ai-team-contacts-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 16px;
}
.ai-team-contacts-heading h2 {
  font-size: 16px;
  margin: 0;
}
.ai-team-contacts-heading > span {
  font-size: 12px;
  color: var(--team-muted);
}
.ai-team-search {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--team-line);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--team-surface);
  margin-bottom: 16px;
  color: var(--team-muted);
}
.ai-team-search input {
  border: 0;
  background: transparent;
  min-width: 0;
  width: 100%;
  padding: 12px 0;
  outline-offset: 2px;
  box-shadow: none;
}
.ai-team-contact-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-team-contact {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  width: 100%;
  background: transparent;
  color: var(--team-ink);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 8px;
  flex-shrink: 0;
  box-shadow: none;
}
.ai-team-contact:hover {
  background: var(--team-surface);
}
.ai-team-contact[aria-current="true"] {
  background: var(--team-surface);
  border-color: var(--team-line);
  box-shadow: 0 2px 6px #17203308;
}
.ai-team-contact > span:last-child {
  min-width: 0;
}
.ai-team-contact strong {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}
.ai-team-contact small {
  display: block;
  color: var(--team-muted);
  font-size: 12px;
  line-height: 16px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-team-avatar {
  display: grid;
  place-items: center;
  height: 40px;
  width: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--team-soft);
  border: 1px solid var(--team-line);
  font-size: 13px;
  font-weight: 700;
  color: var(--team-accent);
}
.ai-team-contacts-note {
  font-size: 12px;
  line-height: 18px;
  color: var(--team-muted);
  margin: 16px 8px 0;
}
.ai-team-workspace [data-widget-id="workforce-chat"] {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}
.ai-team-workspace .ai-chat-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0;
  border: 0;
  background: var(--team-surface);
  border-radius: 0;
}
.ai-team-workspace .ai-chat-header {
  padding: 20px 24px;
  margin: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--team-line);
  gap: 12px;
}
.ai-team-workspace .ai-chat-person {
  min-width: 0;
  gap: 12px;
}
.ai-team-workspace .ai-chat-person h2 {
  font-size: 16px;
  line-height: 24px;
  margin: 0;
}
.ai-team-workspace .ai-chat-person p {
  font-size: 12px;
  line-height: 18px;
  margin: 4px 0 0;
  color: var(--team-muted);
}
.ai-team-workspace .ai-chat-person > span {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}
.ai-team-workspace #ai-chat-employee {
  max-width: 180px;
  font-size: 12px;
  width: auto;
}
.ai-chat-back {
  display: none;
}
.ai-chat-conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  overscroll-behavior: auto;
  scroll-behavior: auto;
}
.ai-team-workspace .ai-chat-log {
  max-height: none;
  overflow: visible;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 0;
  background: transparent;
}
.ai-team-workspace .ai-chat-message {
  max-width: 88%;
  width: fit-content;
  min-width: min(180px, 100%);
  border: 1px solid var(--team-line);
  border-radius: 4px 16px 16px;
  padding: 16px 20px;
  margin: 12px 0;
  background: var(--team-soft);
  color: var(--team-ink);
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.ai-team-workspace .ai-chat-message.task {
  margin-left: auto;
  background: var(--team-surface);
  border-radius: 16px 4px 16px 16px;
}
.ai-team-workspace .ai-chat-message.error {
  border-color: var(--danger, #b91c1c);
}
.ai-team-workspace .ai-chat-message em {
  display: block;
  font-size: 11px;
  color: var(--team-muted);
  margin-top: 8px;
  font-style: normal;
}
.ai-chat-author {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--team-muted);
}
.ai-chat-message [data-ai-answer-text] {
  white-space: normal;
}
.ai-chat-message.task > div {
  white-space: pre-wrap;
}
.ai-team-workspace .ai-chat-compose {
  flex-shrink: 0;
  display: block;
  padding: 16px 24px 12px;
  border-top: 1px solid var(--team-line);
  background: var(--team-surface);
  position: relative;
}
.ai-chat-input-surface {
  border: 1px solid var(--team-line);
  border-radius: 16px;
  padding: 12px;
  background: var(--team-surface);
}
.ai-chat-input-surface:focus-within {
  border-color: var(--team-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--team-accent) 12%, transparent);
}
.ai-team-workspace #ai-chat-message-input {
  width: 100%;
  min-height: 56px;
  max-height: 160px;
  resize: vertical;
  border: 0;
  padding: 4px;
  margin: 0;
  box-shadow: none;
  background: transparent;
  font-size: 16px;
  line-height: 24px;
  border-radius: 4px;
}
.ai-chat-compose-toolbar,
.ai-chat-compose-tools,
.ai-chat-compose-caption {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.ai-chat-compose-tools {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.ai-chat-compose-toolbar button,
.ai-chat-compose-toolbar summary {
  font-size: 12px;
  min-height: 40px;
}
.ai-chat-compose-toolbar svg,
.ai-chat-read-toggle svg {
  flex-shrink: 0;
}
.ai-team-workspace .ai-chat-compose details {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.ai-team-workspace .ai-chat-compose summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  color: var(--team-muted);
  font-weight: 500;
}
.ai-team-workspace .ai-chat-compose summary:after {
  width: 20px;
  height: 20px;
  margin: 0;
}
.ai-chat-compose-tools > button,
.ai-chat-read-toggle,
.ai-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ai-chat-send {
  border-radius: 12px;
  padding: 10px 16px;
}
.ai-chat-compose-tools > .ghost {
  color: var(--team-muted);
  padding: 8px;
}
.ai-chat-compose-caption {
  margin-top: 8px;
  font-size: 11px;
  color: var(--team-muted);
}
.ai-chat-read-toggle {
  font-size: 11px;
  padding: 6px 8px;
  color: var(--team-muted);
  background: transparent;
}
.ai-chat-read-toggle[aria-pressed="true"],
.ai-chat-voice-button[aria-pressed="true"] {
  color: var(--team-accent);
  background: var(--team-soft);
}
.ai-chat-popup {
  position: absolute;
  bottom: 100%;
  left: 24px;
  right: 24px;
  max-height: min(55dvh, 460px);
  overflow: auto;
  z-index: 5;
  background: var(--team-surface);
  border: 1px solid var(--team-line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 40px #17203320;
  font-size: 14px;
}
.ai-chat-popup h3 {
  margin: 0;
  font-size: 16px;
}
.ai-chat-popup label {
  display: block;
  margin-top: 12px;
}
.ai-chat-popup select,
.ai-chat-popup input {
  width: 100%;
}
.ai-chat-popup .check-row {
  display: flex;
  gap: 8px;
}
.ai-chat-popup .check-row input {
  width: auto;
}
.ai-chat-attached {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--team-accent);
}
.ai-chat-voice-status,
.ai-chat-status {
  font-size: 12px;
  line-height: 18px;
  margin: 8px 0 0;
}
.ai-chat-voice-status:empty,
.ai-chat-status:empty {
  display: none;
}
.ai-chat-recovery {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.ai-chat-recovery button {
  font-size: 12px;
}
.ai-chat-speak {
  font-size: 12px;
  padding: 6px 8px;
  min-height: 32px;
  margin-top: 8px;
}
.ai-chat-members {
  max-height: 160px;
  overflow: auto;
}
.ai-chat-history-nav {
  margin-bottom: 16px;
}
.ai-chat-history-nav summary {
  font-size: 12px;
  color: var(--team-muted);
}
.ai-chat-history-status {
  color: var(--team-muted);
  font-size: 12px;
}
.ai-chat-proof {
  font-size: 12px;
  color: var(--team-muted);
  margin-top: 12px;
}
.ai-team-workspace .ai-employee-card {
  padding: 20px;
}
.ai-team-workspace .ai-employee-card > p {
  font-size: 14px;
  line-height: 22px;
}
.ai-employee-details {
  margin: 16px 0;
}
.ai-employee-details summary {
  font-size: 12px;
}
.ai-team-workspace [role="tabpanel"]:not(.ai-team-messenger) > .card {
  margin-bottom: 16px;
}
@media (max-width: 767px) {
  .ai-team-heading {
    margin-bottom: 16px;
  }
  .ai-team-heading h1 {
    font-size: 24px;
    line-height: 32px;
  }
  .ai-team-tabs {
    margin-bottom: 16px;
    gap: 0;
  }
  .ai-team-tabs button {
    padding: 12px;
  }
  .ai-team-messenger {
    display: block;
    height: calc(100dvh - 180px);
    min-height: 440px;
    border-radius: 12px;
  }
  .ai-team-contacts {
    display: none;
    height: 100%;
    border: 0;
  }
  .show-contacts .ai-team-contacts {
    display: flex;
  }
  .show-contacts [data-widget-id="workforce-chat"] {
    display: none;
  }
  .ai-chat-back {
    display: inline-flex;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
  }
  .ai-team-workspace .ai-chat-header {
    padding: 12px;
  }
  .ai-team-workspace #ai-chat-employee {
    display: none;
  }
  .ai-chat-conversation {
    padding: 16px 12px;
  }
  .ai-team-workspace .ai-chat-message {
    max-width: 96%;
    padding: 12px;
  }
  .ai-team-workspace .ai-chat-compose {
    padding: 12px 8px;
  }
  .ai-chat-popup {
    left: 8px;
    right: 8px;
    padding: 16px;
  }
  .ai-chat-compose-caption > span {
    display: none;
  }
  .ai-chat-compose-caption {
    justify-content: flex-end;
  }
  .ai-chat-compose-toolbar button,
  .ai-chat-compose-toolbar summary,
  .ai-chat-speak {
    min-height: 44px;
  }
  .ai-chat-send > span,
  .ai-chat-voice-button > span {
    display: none;
  }
  .ai-chat-send {
    min-width: 44px;
    padding: 10px;
  }
  .ai-chat-compose-tools {
    gap: 0;
  }
  .ai-team-workspace .ai-chat-compose summary {
    padding: 8px 4px;
    font-size: 11px;
  }
  .ai-chat-compose-toolbar {
    gap: 4px;
  }
  .ai-chat-compose-tools svg {
    width: 18px;
  }
  .ai-team-workspace .ai-chat-person > span {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-chat-conversation {
    scroll-behavior: auto;
  }
}

/* Override broad legacy form/button layout only inside this workspace. */
.ai-team-workspace .ai-chat-header {
  flex-wrap: nowrap;
}
.ai-team-workspace .ai-chat-header #ai-chat-employee {
  display: none;
}
.ai-team-workspace .ai-chat-back,
.ai-team-workspace .ai-chat-compose button,
.ai-team-workspace .ai-chat-speak {
  width: auto;
}
.ai-team-workspace .ai-chat-back {
  flex: 0 0 44px;
}
.ai-team-workspace .ai-chat-person {
  flex: 1;
}
.ai-team-workspace .ai-team-contact {
  min-height: 72px;
  height: auto;
}
.ai-team-workspace .ai-chat-speak {
  display: inline-flex;
}
.ai-team-workspace .ai-chat-options summary > span {
  display: inline;
}
@media (max-width: 767px) {
  .ai-team-workspace .ai-chat-header {
    flex-direction: row;
    align-items: center;
  }
  .ai-team-workspace .ai-chat-compose-toolbar {
    flex-wrap: nowrap;
  }
  .ai-team-workspace .ai-chat-compose-tools {
    flex-wrap: nowrap;
  }
  .ai-team-workspace .ai-chat-attachments > summary > span,
  .ai-team-workspace .ai-chat-options > summary > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .ai-team-workspace .ai-chat-compose details > summary {
    min-width: 44px;
  }
  .ai-team-workspace .ai-chat-compose-caption button {
    min-height: 44px;
  }
}

/* The selected contact already identifies the conversation in the sidebar. */
.ai-team-workspace .ai-chat-header {
  display: none;
}
.ai-team-workspace .ai-chat-person,
.ai-team-workspace #ai-chat-employee {
  display: none;
}
.ai-chat-compose-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ai-team-workspace .ai-chat-compose {
  padding: 12px 16px;
}
.ai-team-workspace .ai-chat-status:empty,
.ai-team-workspace .ai-chat-voice-status:empty {
  display: none;
}
.ai-team-workspace .ai-chat-message {
  max-width: 100%;
}
@media (max-width: 767px) {
  .ai-team-workspace .ai-chat-header {
    display: flex;
    padding: 4px 8px;
  }
  .ai-chat-compose-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .ai-team-workspace .ai-chat-compose-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .ai-team-workspace .ai-chat-compose-actions {
    margin-left: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .ai-team-workspace .ai-chat-read-toggle {
    min-width: 44px;
    width: 44px;
    padding: 10px;
    position: relative;
  }
  .ai-team-workspace .ai-chat-read-toggle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .ai-team-workspace #ai-chat-message-input {
    font-size: 16px;
    line-height: 24px;
  }
}

.ai-chat-shell button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ai-team-workspace .ai-workforce-task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.ai-team-workspace .ai-workforce-task-actions > button {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 44px;
  max-width: 100%;
  height: auto;
  line-height: 1.4;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
}
@media (max-width: 767px) {
  .ai-team-workspace .ai-workforce-task-table td:last-child {
    grid-template-columns: minmax(0, 1fr);
  }
  .ai-team-workspace .ai-workforce-task-actions > button {
    flex-basis: 100%;
  }
}

.ai-chat-prose p {
  margin: 0 0 0.75em;
}
.ai-chat-prose p:last-child {
  margin-bottom: 0;
}
.ai-chat-prose ul,
.ai-chat-prose ol {
  padding-inline-start: 1.5em;
  margin-block: 0.75em;
}
.ai-chat-prose li + li {
  margin-block-start: 0.5em;
}
.ai-chat-prose pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-chat-prose .ai-chat-table {
  margin-block: 0.75em;
}
.ai-chat-prose .ai-chat-table table {
  width: 100%;
  font: inherit;
  border-collapse: collapse;
}
.ai-chat-prose .ai-chat-table :is(th, td) {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}
.ai-chat-prose .ai-chat-table .ai-chat-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
