.helpdesk-mail-channels {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.helpdesk-mail-channel {
  --text-primary: var(--card-text);
  --text-secondary: var(--card-text);
  --muted: color-mix(in srgb, var(--card-text) 80%, transparent);
  --border-default: color-mix(in srgb, var(--card-text) 18%, transparent);
  color: var(--card-text);
  background: var(--workspace-surface, var(--surface-secondary));
  border: 1px solid var(--border-default);
  border-radius: 12px;
  min-width: 0;
}

.helpdesk-mail-channel > summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  min-height: 76px;
  cursor: pointer;
  list-style: none;
  border-radius: inherit;
}

.helpdesk-mail-channel > summary::-webkit-details-marker { display: none; }
.helpdesk-mail-channel > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  flex: none;
  margin-left: auto;
}
.helpdesk-mail-channel[open] > summary::after { transform: rotate(45deg); }
.helpdesk-mail-channel > summary:hover { background: color-mix(in srgb, var(--card-text) 4%, transparent); }
.helpdesk-mail-channel > summary:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.helpdesk-mail-channel > summary > span { display: grid; gap: 4px; min-width: 0; }
.helpdesk-mail-channel > summary strong { font-size: 16px; font-weight: 500; }
.helpdesk-mail-channel > summary small { color: var(--muted); font-size: 13px; }
.helpdesk-mail-channel > summary svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.helpdesk-mail-channel-body {
  display: grid;
  gap: 20px;
  border-top: 1px solid var(--border-default);
  padding: 20px;
  min-width: 0;
}
.helpdesk-mail-channel-body > [data-helpdesk-inbound] { min-width: 0; }
.helpdesk-mail-channel-body > [data-helpdesk-inbound] > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.helpdesk-mail-channel-body > [data-helpdesk-inbound] > header:first-child { display: block; }
.helpdesk-mail-channel-body h3 { margin-top: 0; }
.helpdesk-mail-channel-body p { line-height: 1.5; }
.helpdesk-mail-channel-body .mail-content > summary { padding: 12px 0; font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 16px; list-style: none; cursor: pointer; }
.helpdesk-mail-channel-body .mail-content > summary::-webkit-details-marker { display: none; }
.helpdesk-mail-channel-body .mail-content > summary::after { content: "Ver plantillas"; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.helpdesk-mail-channel-body .mail-content[open] > summary::after { content: "Ocultar plantillas"; }
.helpdesk-mail-channel-body [data-inbound-config] > label:not(.field) { display: flex; align-items: flex-start; gap: 8px; grid-column: 1 / -1; }
.helpdesk-mail-channel-body [data-inbound-config] > label > input[type="checkbox"] { flex: none; margin-top: 3px; }
.helpdesk-mail-channel-body [data-inbound-error] { color: inherit; border-left: 3px solid var(--danger); padding-left: 12px; }

.hd-mail-dialog { width: min(1100px, calc(100vw - 40px)); max-width: none; max-height: calc(100dvh - 40px); margin: auto; padding: 0; border: 1px solid var(--border-default); border-radius: 16px; color: var(--card-text); background: var(--workspace-surface, var(--surface-secondary)); box-shadow: 0 24px 80px #0004; overflow: auto; }
.hd-mail-dialog::backdrop { background: #07132980; backdrop-filter: blur(3px); }
.hd-mail-dialog-head, .hd-mail-dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; }
.hd-mail-dialog-head { align-items: flex-start; border-bottom: 1px solid var(--border-default); }
.hd-mail-dialog-head h2 { margin: 0 0 8px; font-size: 21px; overflow-wrap: anywhere; }
.hd-mail-dialog-head p, .hd-mail-dialog-footer p { margin: 0; font-size: 13px; line-height: 1.5; }
.hd-mail-dialog-head > button { flex: none; }
.hd-mail-dialog-footer { border-top: 1px solid var(--border-default); flex-wrap: wrap; }
.hd-mail-dialog button { font: inherit; }
.hd-mail-table-scroll { overflow: auto; max-height: 60dvh; }
.hd-mail-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.hd-mail-table th, .hd-mail-table td { padding: 14px 18px; border-bottom: 1px solid var(--border-default); vertical-align: top; }
.hd-mail-table th { font-size: 12px; font-weight: 600; }
.hd-mail-table td { overflow-wrap: anywhere; min-width: 110px; }
.hd-mail-table td:first-child { min-width: 180px; }
.hd-mail-table th.hd-mail-select-cell, .hd-mail-table td.hd-mail-select-cell { min-width: 44px; width: 44px; padding-right: 8px; text-align: center; }
.hd-mail-table .hd-mail-select-cell + td { min-width: 180px; }
.hd-mail-select-cell input { width: 18px; height: 18px; margin: 0; accent-color: var(--interactive-primary, #328fea); cursor: pointer; }
.hd-mail-select-cell input:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.hd-mail-select-cell input:disabled, .hd-mail-dialog button:disabled { cursor: default; opacity: .6; }
.hd-mail-selection-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border-default); }
.hd-mail-selection-actions span { font-size: 13px; }
.hd-mail-subject { border: 0; padding: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; text-align: left; cursor: pointer; }
.hd-mail-dialog button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.hd-mail-reader { width: min(900px, calc(100vw - 40px)); }
.hd-mail-message-body { padding: 20px 24px; max-height: 55dvh; overflow: auto; }
.hd-mail-message-body pre { margin: 18px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.65; }
.hd-mail-reason { border-left: 3px solid var(--interactive-primary, #328fea); padding-left: 12px; }
.hd-mail-empty { padding: 32px 24px; text-align: center; }

@media (max-width: 600px) {
  .hd-mail-dialog, .hd-mail-reader { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .hd-mail-dialog-head, .hd-mail-dialog-footer, .hd-mail-message-body { padding: 16px; }
  .hd-mail-selection-actions { padding: 12px 16px; }
  .hd-mail-dialog .helpdesk-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .helpdesk-mail-channel > summary { padding: 14px; gap: 10px; }
  .helpdesk-mail-channel-body { padding: 14px; }
  .helpdesk-mail-channel-body [data-inbound-config] { grid-template-columns: minmax(0, 1fr); }
  .helpdesk-mail-channel-body [data-inbound-config] > * { grid-column: 1; }
  .helpdesk-mail-channel-body .email-template-card > footer { flex-wrap: wrap; }
  .helpdesk-mail-channel-body .email-template-token-bar { align-items: flex-start; flex-direction: column; }
}
