/* ===========================================
   Agents: the roster (agents/index) and the agent form (agents/new, edit and
   their sections). Owned by the agent forms slice.

   The form is one column at --form-max-width with form__section disclosures
   (base/forms.css). Channel blocks keep their .form__channel* hooks, which
   form_sections_controller.js and the specs query, but every rule here is
   scoped under the form's own .agent-form class, so no shared block is
   styled from this file. Channels are neutral: a --color-surface-raised tile
   with a sprite icon and the channel name, no brand colours.
   =========================================== */

/* ===========================================
   Page column
   =========================================== */

.agent-form-page {
  width: 100%;
  max-width: var(--form-max-width);
}

/* Tools save on their own (a separate form), so a hairline ends the main
   form at its Save row before they start. */
.agent-form-page__tools {
  margin-top: var(--spacing-2xl);
  padding-top: var(--spacing-2xl);
  border-top: 1px solid var(--color-border-subtle);
}

/* Groups of basic fields: a quiet heading and a hairline between groups */
.agent-form__group {
  min-width: 0;
  margin: 0 0 var(--spacing-2xl);
  padding: 0;
  border: 0;
}

.agent-form__legend {
  width: 100%;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-emphasis);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.agent-form__group > .agent-form__fields {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

/* The column gap spaces the groups; their own margin would double it. */
.agent-form__fields > .form__group {
  margin-bottom: 0;
}

.agent-form__errors-title {
  margin: 0;
  color: inherit;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

/* ===========================================
   Channels
   =========================================== */

.agent-form .form__channels {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
}

.agent-form .form__channel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.agent-form .form__channel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm) var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
}

.agent-form .form__channel-header > .form__checkbox {
  flex: 1;
  min-width: 0;
  align-items: center;
}

/* Teams has no checkbox: its name sits beside the tile. */
.agent-form .form__channel-header > .form__checkbox-label {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.agent-channel-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
}

.agent-channel-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}

.agent-form .form__channel-name {
  color: var(--color-text-emphasis);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.agent-form .form__channel-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.agent-form .form__channel-info-item {
  display: block;
}

/* Why a channel is off, such as an email channel paused after a complaint. */
.agent-form .form__channel-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0;
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
}

.agent-form .form__channel-fields {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
  padding: var(--spacing-lg);
  border-top: 1px solid var(--color-border-subtle);
}

/* Labels sit close to their field; each field starts a new beat. */
.agent-form .form__channel-fields .form__field-group {
  gap: 0.375rem;
}

.agent-form .form__channel-fields .form__field-group > .form__label:not(:first-child) {
  margin-top: var(--spacing-lg);
}

.agent-form .form__channel-fields .form__field-group > .form__help-text {
  margin-top: 0;
}

/* Fields the agent form shows only for a switched-on channel */
.agent-form .form__channel-fields--hidden {
  display: none;
}

/* ===========================================
   Roster (agents/index): one hairline list of agents
   =========================================== */

.agent-roster__item {
  align-items: flex-start;
}

/* Two classes so the title beats markdown.css's running-text li a rule. */
.agent-roster .agent-roster__name a {
  color: var(--color-text-emphasis);
  text-decoration: none;
}

.agent-roster .agent-roster__name a:hover {
  color: var(--color-text-emphasis);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.agent-roster__meta {
  color: var(--color-text-subtle);
}

.agent-roster__channels {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: var(--spacing-sm) 0 0;
  padding: 0;
  list-style: none;
}

.channel-badge.agent-roster__channel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--spacing-sm);
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
}

.agent-roster__channel .channel-badge__action {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
}

.agent-roster__channel .channel-badge__action--secondary {
  color: var(--color-text-muted);
}

@media (min-width: 640px) {
  .agent-roster__item {
    align-items: center;
  }
}

@media (min-width: 768px) {
  .agent-form .form__channel-header {
    padding: var(--spacing-sm) var(--spacing-lg);
  }

  .agent-form .form__channel-notice {
    padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-md);
  }

  .agent-form .form__channel-fields {
    padding: var(--spacing-xl);
  }
}
