/* fastwheel/draft-actions.css
 *
 * Styles for the Approve / Reject / Edit buttons injected below each AI
 * draft private note + the Edit modal. Uses Chatwoot's CSS variables where
 * possible so we inherit dark mode + theme tweaks automatically.
 */

/* ── Button row ────────────────────────────────────────────────────── */

/* Injected as a sibling RIGHT AFTER the [data-message-id] message wrap.
 * The row spans the full width of the conversation column so its
 * ``justify-content: flex-end`` right-aligns the buttons under the
 * outgoing bubble — matching Chatwoot's outgoing-message orientation. */
.fw-draft-actions {
  display: flex;
  gap: 8px;
  margin: -2px 0 14px;
  padding: 0 16px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
  box-sizing: border-box;
}

.fw-btn {
  border: 1px solid var(--color-border, #d4d6d9);
  background: var(--white, #ffffff);
  color: var(--color-body, #1f293b);
  padding: 6px 14px;
  border-radius: 6px;
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.fw-btn:hover:not(:disabled) {
  filter: brightness(0.97);
}

.fw-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.fw-btn-approve {
  border-color: #16a34a;
  color: #16a34a;
  background: rgba(22, 163, 74, 0.06);
}

.fw-btn-approve:hover:not(:disabled) {
  background: rgba(22, 163, 74, 0.12);
}

.fw-btn-edit {
  border-color: #2563eb;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
}

.fw-btn-edit:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.12);
}

.fw-btn-reject {
  border-color: #dc2626;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}

.fw-btn-reject:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.12);
}

.fw-status {
  font-size: 12px;
  color: var(--color-light-gray, #8c8f95);
  margin-left: 4px;
}

.fw-status-ok {
  color: #16a34a;
  font-weight: 600;
}

.fw-status-error {
  color: #dc2626;
  font-weight: 600;
}

/* "Already actioned" badge — same insertion model as the button row
 * (sibling after [data-message-id]). Right-aligned with the bubble. */
.fw-draft-status-badge {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px;
  margin: -2px 0 14px;
  width: 100%;
  box-sizing: border-box;
}
.fw-draft-status-badge::before {
  content: attr(data-fw-label);
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--color-background, #f4f6fb);
  color: var(--color-light-gray, #8c8f95);
  font: 600 11px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
}

/* ── Edit modal ────────────────────────────────────────────────────── */

.fw-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.fw-modal {
  background: var(--white, #ffffff);
  color: var(--color-body, #1f293b);
  border-radius: 12px;
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.fw-modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #d4d6d9);
  font: 600 15px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.fw-modal-textarea {
  flex: 1;
  min-height: 180px;
  padding: 14px 18px;
  border: none;
  outline: none;
  background: var(--white, #ffffff);
  color: var(--color-body, #1f293b);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  resize: vertical;
}

.fw-modal-textarea:focus {
  background: var(--color-background, #fbfcfe);
}

.fw-modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--color-border, #d4d6d9);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.fw-btn-primary {
  background: var(--color-woot, #1f93ff);
  border-color: var(--color-woot, #1f93ff);
  color: #ffffff;
  padding: 7px 16px;
}

.fw-btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.fw-btn-secondary {
  background: transparent;
  border-color: var(--color-border, #d4d6d9);
  color: var(--color-body, #1f293b);
}

.fw-modal-error {
  padding: 0 18px 12px;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
}

/* Mobile */
@media (max-width: 600px) {
  .fw-modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .fw-modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .fw-draft-actions {
    margin: 6px 8px 12px;
  }
  .fw-btn {
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* Dark mode — inherit Chatwoot's theme. The CSS vars cover most of it;
 * this is just for the subtle tints that aren't variable-driven. */
@media (prefers-color-scheme: dark) {
  .fw-btn-approve { background: rgba(22, 163, 74, 0.18); }
  .fw-btn-edit    { background: rgba(37, 99, 235, 0.18); }
  .fw-btn-reject  { background: rgba(220, 38, 38, 0.18); }
  .fw-modal       { box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6); }
}
