/* ============================================================================
   RICH EDITOR & WHATSAPP PREVIEW STYLES - GAEO
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Montserrat:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Poppins:ital,wght@0,400;0,600;0,700;1,400;1,700&family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,700&display=swap');

.rich-editor-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.rich-editor-wrapper:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.rich-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  flex-wrap: wrap;
  user-select: none;
}

/* Container do botão de Emoji no Rich Editor */
.rich-editor-emoji-wrapper {
  position: relative;
  display: inline-flex;
}

/* Popup do Seletor de Emojis */
.rich-editor-emoji-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1100;
  width: 310px;
  max-width: 90vw;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 10px;
  box-sizing: border-box;
}

.dark-theme .rich-editor-emoji-picker {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.rich-editor-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  margin-right: 6px;
  border-right: 1px solid #e2e8f0;
}

.rich-editor-group:last-child {
  border-right: none;
}

.rich-editor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}

.rich-editor-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.rich-editor-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #1d4ed8 !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.rich-editor-select {
  height: 32px;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.rich-editor-select:hover {
  border-color: #94a3b8;
}

.rich-editor-select:focus {
  border-color: #3b82f6;
}

.rich-editor-color-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.rich-editor-color-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Área Editável ContentEditable */
.rich-editor-content {
  min-height: 250px;
  max-height: 450px;
  overflow-y: auto;
  padding: 12px 14px;
  color: #1e293b;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  background: #ffffff;
}

.rich-editor-content b,
.rich-editor-content strong,
.rich-editor-content i,
.rich-editor-content em,
.rich-editor-content u,
.rich-editor-content s,
.rich-editor-content span,
.rich-editor-content p,
.wa-preview-content b,
.wa-preview-content strong,
.wa-preview-content i,
.wa-preview-content em,
.wa-preview-content u,
.wa-preview-content s,
.wa-preview-content span,
.wa-preview-content p,
.items-list b,
.items-list strong,
.items-list i,
.items-list em,
.items-list u,
.items-list s,
.items-list span,
.markdown-content b,
.markdown-content strong,
.markdown-content i,
.markdown-content em,
.markdown-content u,
.markdown-content s,
.markdown-content span {
  font-family: inherit;
}

.rich-editor-content[placeholder]:empty:before {
  content: attr(placeholder);
  color: #94a3b8;
  pointer-events: none;
  display: block;
}

.rich-editor-content h1 {
  font-size: 1.6em;
  font-weight: 700;
  margin: 8px 0 4px 0;
  color: #0f172a;
}

.rich-editor-content h2 {
  font-size: 1.35em;
  font-weight: 600;
  margin: 6px 0 4px 0;
  color: #1e293b;
}

.rich-editor-content h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin: 4px 0 2px 0;
  color: #334155;
}

.rich-editor-content p {
  margin: 0 0 6px 0;
}

.rich-editor-content ul, .rich-editor-content ol {
  padding-left: 24px;
  margin: 4px 0 8px 0;
}

.rich-editor-content blockquote {
  border-left: 4px solid #cbd5e1;
  padding-left: 12px;
  margin: 8px 0;
  color: #64748b;
  font-style: italic;
}

/* Variáveis para WhatsApp (pills clicáveis na toolbar) */
.rich-editor-var-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.rich-editor-var-btn:hover {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}

/* ============================================================================
   PREVIEW DO WHATSAPP (REALTIME BUBBLE)
   ============================================================================ */

.wa-preview-container {
  margin-top: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #efeae2; /* Fundo oficial WhatsApp chat */
  background-image: radial-gradient(#d1d5db 0.75px, transparent 0.75px);
  background-size: 12px 12px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.03);
}

.wa-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #075e54;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
}

.wa-preview-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-preview-header-title i {
  font-size: 16px;
  color: #25d366;
}

.wa-preview-body {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wa-preview-bubble {
  position: relative;
  align-self: flex-start;
  max-width: 85%;
  background: #ffffff;
  border-radius: 0 8px 8px 8px;
  padding: 8px 12px 20px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  color: #111b21;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.2px;
  line-height: 1.45;
  word-break: break-word;
}

.wa-preview-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent #ffffff transparent transparent;
}

.wa-preview-bubble strong, .wa-preview-bubble b {
  font-weight: 700;
}

.wa-preview-bubble em, .wa-preview-bubble i {
  font-style: italic;
}

.wa-preview-bubble s, .wa-preview-bubble strike {
  text-decoration: line-through;
}

.wa-preview-time {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  color: #667781;
}

.wa-preview-image {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 6px;
}

/* Estilos de Links Clicáveis dentro do Rich Editor */
.rich-editor-content a {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  word-break: break-all;
}

.rich-editor-content a:hover {
  color: #1d4ed8;
}
