/* Messaging compose + chips */
.help-text,
.muted {
  color: var(--muted, #6b7280);
  font-size: 0.875rem;
}
#subject-group[hidden] {
  display: none !important;
}
.container-messaging {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--page-padding-y, 1.25rem) var(--page-padding-x, 1rem);
}
.template-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.template-editor-preview {
  position: sticky;
  top: 1rem;
}
.template-editor-preview h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}
.preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
  margin-bottom: 0.5rem;
}
.preview-placeholder {
  color: #9ca3af !important;
  font-style: italic;
}
.email-preview-chrome {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.email-preview-meta {
  display: flex;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-size: 0.875rem;
}
.email-preview-meta .meta-key {
  flex: 0 0 4.5rem;
  color: var(--muted, #6b7280);
  font-weight: 600;
}
.email-preview-frame {
  display: block;
  width: 100%;
  min-height: 240px;
  height: 280px;
  border: 0;
  background: #fff;
}
.sms-preview-device {
  max-width: 280px;
  margin: 0 auto;
  border: 2px solid #1f2937;
  border-radius: 28px;
  padding: 0.75rem 0.65rem 1rem;
  background: #111827;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.sms-preview-notch {
  width: 72px;
  height: 8px;
  border-radius: 999px;
  background: #374151;
  margin: 0 auto 0.75rem;
}
.sms-preview-screen {
  background: #f3f4f6;
  border-radius: 16px;
  min-height: 220px;
  padding: 0.85rem;
}
.sms-preview-screen .sms-body-preview {
  background: #fff;
  border-radius: 14px 14px 14px 4px;
  padding: 0.65rem 0.75rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  font-size: 0.9rem;
  line-height: 1.45;
  color: #111827;
}
.delivery-preview[hidden] {
  display: none !important;
}
.placeholder-chips .chip {
  cursor: pointer;
}
.compose-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
}
.compose-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(580px, calc(100vw - 1.5rem));
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
.compose-panel[hidden],
.compose-backdrop[hidden] {
  display: none !important;
}
.compose-panel.is-minimized {
  max-height: 48px;
  overflow: hidden;
}
.compose-panel.is-minimized .compose-panel-body {
  display: none;
}
.compose-panel-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.compose-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.15rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  min-height: 2.5rem;
}
.compose-field-label {
  flex: 0 0 auto;
  min-width: 3.25rem;
  color: #5f6368;
  font-size: 0.875rem;
}
.compose-input,
.compose-field .compose-input,
.compose-chip-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  border-radius: 0 !important;
  padding: 0.45rem 0 !important;
  font-size: 0.9375rem;
  outline: none;
}
.compose-chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0 !important;
}
.compose-chip-input .compose-input {
  flex: 1;
  min-width: 8rem;
}
.compose-body-field {
  flex: 1;
  padding: 0.35rem 0.5rem 0;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.compose-body-field textarea.compose-input,
.compose-body-field #id_sms_body {
  flex: 1;
  min-height: 180px;
  width: 100%;
  resize: vertical;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0.5rem 0.5rem !important;
  font-size: 0.9375rem;
  outline: none;
  background: transparent;
}
.compose-body-field .ck.ck-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  border: 0 !important;
}
.compose-body-field .ck-editor__editable {
  min-height: 220px;
  border: 0 !important;
  box-shadow: none !important;
}
.compose-body-field .ck.ck-toolbar {
  border: 0 !important;
  border-bottom: 1px solid #e0e0e0 !important;
  background: #fff !important;
}
.compose-body-field .ck.ck-editor__main {
  flex: 1;
}
.compose-body-field .ck.ck-editor__main > .ck-editor__editable {
  background: #fff;
  border: 0 !important;
}
.compose-body-field .ck.ck-editor__top .ck-sticky-panel .ck-toolbar {
  border-radius: 0 !important;
}
.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem 0.85rem;
  border-top: 1px solid #e0e0e0;
  margin-top: auto;
  background: #fff;
}
.compose-attach {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-left: auto;
}
.compose-attach-label {
  font-size: 0.875rem;
  color: #5f6368;
  cursor: pointer;
  flex-shrink: 0;
}
.compose-attach-label:hover {
  color: #202124;
}
.compose-attach input[type="file"] {
  font-size: 0.8rem;
  max-width: 12rem;
  color: #5f6368;
}
.compose-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.compose-send-btn {
  border-radius: 999px !important;
  min-width: 5.5rem;
  padding-left: 1.25rem !important;
  padding-right: 1.25rem !important;
}
.compose-discard-btn {
  border: 0;
  background: transparent;
  color: #5f6368;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}
.compose-discard-btn:hover {
  background: #f1f3f4;
  color: #202124;
}
.compose-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem 0.55rem 1rem;
  border-bottom: 0;
  background: #404040;
  color: #fff;
  position: sticky;
  top: 0;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
  z-index: 1;
}
.compose-panel-header strong {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.compose-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.compose-panel-header .compose-icon-btn.icon-btn,
.compose-panel-header .icon-btn.compose-icon-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1;
  box-shadow: none;
}
.compose-panel-header .compose-icon-btn.icon-btn:hover,
.compose-panel-header .icon-btn.compose-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.compose-panel-header .compose-icon-btn.icon-btn:focus-visible,
.compose-panel-header .icon-btn.compose-icon-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.chip-input {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  background: #fff;
}
.chip-input .chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.chip-input .chip-list:empty {
  display: none;
}
.compose-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--primary-light, #3b82f6);
  color: #fff;
  font-size: 0.8rem;
}
.compose-chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.chip-input input.form-control {
  border: 0;
  padding: 0.25rem 0;
  box-shadow: none;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}
.status-pill.status-queued,
.status-pill.status-sending { background: #dbeafe; color: #1d4ed8; }
.status-pill.status-completed { background: #dcfce7; color: #166534; }
.status-pill.status-failed { background: #fee2e2; color: #b91c1c; }
.status-pill.status-cancelled,
.status-pill.status-draft { background: #f3f4f6; color: #4b5563; }
.email-body-preview {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: #fff;
  overflow: auto;
}
.sms-body-preview {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}
.member-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.member-row:last-child {
  border-bottom: 0;
}
.ck-editor__editable {
  min-height: 180px;
}
@media (max-width: 900px) {
  .template-editor {
    grid-template-columns: 1fr;
  }
  .template-editor-preview {
    position: static;
  }
}
@media (max-width: 640px) {
  .compose-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: 0.5rem;
  }
}

/* Send-to-group modal */
.messaging-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.65);
}
.messaging-modal[hidden] {
  display: none !important;
}
.messaging-modal-card {
  width: min(100%, 640px);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-card, 12px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}
.messaging-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.messaging-modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
}
.messaging-modal-body {
  padding: 1rem;
}
.messaging-modal-body .email-preview-frame {
  min-height: 180px;
  height: 220px;
}
@media (max-width: 640px) {
  .messaging-modal {
    align-items: flex-end;
    padding: 0.5rem;
  }
  .messaging-modal-card {
    max-height: calc(100vh - 1rem);
    border-radius: 12px 12px 0 0;
  }
}
