/* Shared messaging styles — message threads, compose, scheduled messages */

:root {
  --msg-sms-out: #5BC236;
  --msg-sms-in: #a0a4aa;
  --msg-email-out: blue;
  --msg-email-in: rgb(154, 154, 222);
  --msg-bot: #6a5acd;
  --msg-notification: #ff9933;
  --msg-status-notes: purple;
  --msg-error: red;
  --msg-scheduled-sms-bg: rgba(91, 194, 54, 0.18);
  --msg-scheduled-sms-fg: #1e4d0c;
  --msg-scheduled-sms-border: rgba(91, 194, 54, 0.7);
  --msg-scheduled-email-bg: rgba(0, 0, 255, 0.12);
  --msg-scheduled-email-fg: #0a0a8a;
  --msg-scheduled-email-border: rgba(0, 0, 255, 0.5);
  --msg-text-dark: #1a1a1a;
  --msg-meta: gray;
}

/* ----- Thread / history container ----- */

.msg-thread,
.message-history-container {
  border: 1px solid #000;
  border-radius: 4px;
  padding: 6px 0;
  overflow-y: auto;
  background: #fff;
}

.msg-thread--fixed {
  height: 300px;
  display: flex;
  flex-direction: column-reverse;
}

.message-history-container {
  background: #fbfdff;
  border-color: var(--wh-border, #d8dcde);
  border-radius: var(--wh-radius, 4px);
  padding: 8px;
  max-height: 30vh;
  margin-bottom: 1rem;
}

.msg-empty,
.no-messages {
  color: var(--msg-meta);
  font-size: 13px;
  padding: 12px;
  text-align: center;
}

/* ----- Meta line (timestamp / from-to) ----- */

.msg-meta,
.message-header {
  font-size: 12px;
  color: var(--msg-meta);
  margin: 6px 0 0 12px;
}

.msg-meta--sm,
.message-history-container .msg-meta {
  font-size: 11px;
}

.msg-meta--inbound {
  margin: 6px 0 0 15%;
}

.msg-meta--dark {
  color: #000;
}

/* ----- Message bubbles ----- */

.msg-bubble,
.message-bubble {
  border-radius: 4px;
  padding: 6px;
  max-width: 80%;
  color: #fff;
  word-break: break-word;
}

.msg-bubble--out,
.message-bubble.sent {
  margin: 0 12px;
}

.msg-bubble--in,
.message-bubble.received {
  margin: 0 0 0 15%;
}

.msg-bubble--sms,
.message-bubble.sms.sent {
  background-color: var(--msg-sms-out);
}

.msg-bubble--sms-in,
.message-bubble.received:not(.email) {
  background-color: var(--msg-sms-in);
}

.msg-bubble--email,
.message-bubble.email.sent {
  background-color: var(--msg-email-out);
}

.msg-bubble--email-in {
  background-color: var(--msg-email-in);
}

.msg-bubble--bot {
  background-color: var(--msg-bot);
}

.msg-bubble--notification {
  background-color: var(--msg-notification);
}

.msg-bubble--status-notes {
  background-color: var(--msg-status-notes);
}

.msg-bubble--error,
.message-bubble.error {
  background-color: var(--msg-error);
}

.message-history-container .msg-bubble {
  font-size: 11px;
}

/* ----- Compose: SMS / Email mode toggle ----- */

.message-mode-toggle {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.message-mode-toggle button {
  border: 0;
  background: #f5f5f5;
  padding: 6px 12px;
  cursor: pointer;
}

.message-mode-toggle button.active {
  color: #fff;
  background: #2f855a;
}

.email-editor-container,
#email-editor-container,
#scheduled-email-editor-container {
  height: 180px;
  margin-bottom: 8px;
  background: #fff;
}

#scheduled-email-editor-container,
.scheduled-msg__quill {
  height: 140px;
}

.email-editor-container .ql-editor p,
#email-editor-container .ql-editor p,
#scheduled-email-editor-container .ql-editor p,
.scheduled-msg__quill .ql-editor p {
  margin: 0;
}

/* ----- Scheduled messages ----- */

.scheduled-msg {
  margin-top: 4px;
  transition: opacity 0.25s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.scheduled-msg.is-removing {
  opacity: 0;
  max-height: 0;
  margin: 0 !important;
  overflow: hidden;
}

.scheduled-msg__meta {
  font-size: 12px;
  color: var(--msg-meta);
  margin: 6px 0 0 12px;
}

.message-history-container .scheduled-msg__meta {
  font-size: 11px;
}

.scheduled-msg__badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(91, 194, 54, 0.2);
  color: #2f6b1a;
  font-size: 11px;
  font-weight: 600;
}

.scheduled-msg.is-email .scheduled-msg__badge {
  background: rgba(0, 0, 255, 0.14);
  color: var(--msg-scheduled-email-fg);
}

.scheduled-msg__bubble {
  background-color: var(--msg-scheduled-sms-bg);
  color: var(--msg-scheduled-sms-fg);
  border-radius: 4px;
  margin: 0 12px;
  padding: 6px;
  max-width: 80%;
  position: relative;
  border: 2px dashed var(--msg-scheduled-sms-border);
  box-sizing: border-box;
}

.message-history-container .scheduled-msg__bubble {
  font-size: 11px;
}

.scheduled-msg.is-email .scheduled-msg__bubble {
  background-color: var(--msg-scheduled-email-bg);
  color: var(--msg-scheduled-email-fg);
  border-color: var(--msg-scheduled-email-border);
}

.scheduled-msg__bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.scheduled-msg__subject {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--msg-text-dark);
}

.scheduled-msg.is-email .scheduled-msg__bubble-text {
  color: var(--msg-text-dark);
}

.scheduled-msg__html {
  background: #fff;
  color: var(--msg-text-dark);
  border-radius: 3px;
  padding: 8px;
  max-height: 160px;
  overflow: auto;
  white-space: normal;
  font-size: 13px;
  line-height: 1.4;
}

.scheduled-msg__html p {
  margin: 0 0 0.5em;
}

.scheduled-msg__html img {
  max-width: 100%;
  height: auto;
}

.scheduled-msg__subject-input,
#scheduled-text-subject {
  width: 100%;
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 3px;
  font-size: 13px;
  color: var(--msg-text-dark);
  box-sizing: border-box;
}

.scheduled-msg__toolbar {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scheduled-msg__toolbar button,
.scheduled-msg__toolbar input[type="submit"] {
  border: 0;
  background: rgba(91, 194, 54, 0.22);
  color: var(--msg-scheduled-sms-fg);
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.4;
}

.scheduled-msg__toolbar button:hover,
.scheduled-msg__toolbar input[type="submit"]:hover {
  background: rgba(91, 194, 54, 0.35);
}

.scheduled-msg.is-email .scheduled-msg__toolbar button,
.scheduled-msg.is-email .scheduled-msg__toolbar input[type="submit"] {
  background: rgba(0, 0, 255, 0.14);
  color: var(--msg-scheduled-email-fg);
}

.scheduled-msg.is-email .scheduled-msg__toolbar button:hover,
.scheduled-msg.is-email .scheduled-msg__toolbar input[type="submit"]:hover {
  background: rgba(0, 0, 255, 0.22);
}

.scheduled-msg__toolbar .scheduled-msg__delete,
.scheduled-msg.is-email .scheduled-msg__toolbar .scheduled-msg__delete {
  background: rgba(180, 40, 40, 0.15);
  color: #8b1a1a;
}

.scheduled-msg__edit {
  display: none;
  margin-top: 8px;
}

.scheduled-msg.is-editing .scheduled-msg__bubble-text,
.scheduled-msg.is-editing .scheduled-msg__subject,
.scheduled-msg.is-editing .scheduled-msg__toolbar {
  display: none;
}

.scheduled-msg.is-editing .scheduled-msg__edit {
  display: block;
}

.scheduled-msg__edit textarea {
  width: 100%;
  min-height: 72px;
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 3px;
  font-size: 13px;
  color: var(--msg-text-dark);
  box-sizing: border-box;
  resize: vertical;
}

.scheduled-msg__datetime {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}

.scheduled-msg__datetime input {
  padding: 2px 4px;
  border: 0;
  border-radius: 3px;
  font-size: 12px;
  color: var(--msg-text-dark);
}

.scheduled-msg__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scheduled-msg__footer button {
  border: 0;
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}

.scheduled-msg__save {
  background: #fff;
  color: #2f6b1a;
  font-weight: 600;
}

.scheduled-msg.is-email .scheduled-msg__save {
  color: #1e3a8a;
}

.scheduled-msg__cancel {
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}

.scheduled-msg__status {
  font-size: 11px;
  opacity: 0.95;
  min-height: 14px;
}
