/* WhatsApp Text Formatter Styles */
.statmat-tool.whatsapp-formatter {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  color: #111b21;
}

.statmat-tool.whatsapp-formatter * {
  box-sizing: border-box;
}

.statmat-tool.whatsapp-formatter .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background-color: #f0f2f5; /* WhatsApp Web Grey */
  border: 1px solid #d1d7db;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 10px;
}

.statmat-tool.whatsapp-formatter .format-btn {
  background-color: #fff;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #54656f;
  transition: all 0.2s;
}

.statmat-tool.whatsapp-formatter .format-btn:hover {
  background-color: #d9dbdd;
  color: #111b21;
}

.statmat-tool.whatsapp-formatter .toolbar-divider {
  width: 1px;
  background-color: #d1d7db;
  margin: 0 4px;
}

.statmat-tool.whatsapp-formatter .input-wrapper {
  margin-bottom: 16px;
}

.statmat-tool.whatsapp-formatter textarea {
  width: 100%;
  padding: 16px;
  border: 1px solid #d1d7db;
  border-radius: 0 0 8px 8px;
  font-size: 15px;
  font-family: monospace;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s;
  background-color: #fff;
  line-height: 1.5;
}

.statmat-tool.whatsapp-formatter textarea:focus {
  outline: none;
  border-color: #00a884; /* WhatsApp Green */
}

.statmat-tool.whatsapp-formatter .action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 32px;
}

.statmat-tool.whatsapp-formatter .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s;
}

.statmat-tool.whatsapp-formatter .btn-primary {
  background-color: #00a884;
  color: #fff;
}

.statmat-tool.whatsapp-formatter .btn-primary:hover {
  background-color: #008f6f;
}

.statmat-tool.whatsapp-formatter .btn-secondary {
  background-color: #f0f2f5;
  color: #54656f;
}

.statmat-tool.whatsapp-formatter .btn-secondary:hover {
  background-color: #d9dbdd;
}

/* WhatsApp Preview Area */
.statmat-tool.whatsapp-formatter .preview-section h4 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: uppercase;
  color: #54656f;
  font-weight: 600;
}

.statmat-tool.whatsapp-formatter .whatsapp-preview-box {
  background-color: #efeae2; /* WhatsApp chat background */
  background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><g fill="%23dcd2c6" fill-opacity="0.4" fill-rule="evenodd"><path d="M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z"/></g></svg>');
  border: 1px solid #d1d7db;
  border-radius: 8px;
  padding: 24px 16px;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.statmat-tool.whatsapp-formatter .wa-message-row {
  display: flex;
  justify-content: flex-end; /* Sent message aligns right */
}

.statmat-tool.whatsapp-formatter .wa-bubble {
  background-color: #d9fdd3; /* WhatsApp sent bubble */
  border-radius: 8px 0 8px 8px;
  padding: 6px 7px 8px 9px;
  max-width: 85%;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  display: inline-flex;
  flex-direction: column;
}

.statmat-tool.whatsapp-formatter .wa-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background: radial-gradient(circle at top right, transparent 0, transparent 72%, #d9fdd3 72%, #d9fdd3 100%);
}

.statmat-tool.whatsapp-formatter .wa-body {
  font-size: 14.2px;
  line-height: 19px;
  color: #111b21;
  word-wrap: break-word;
  white-space: pre-wrap;
  margin-bottom: 2px;
}

.statmat-tool.whatsapp-formatter .wa-time {
  font-size: 11px;
  color: #667781;
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: -4px;
}

.statmat-tool.whatsapp-formatter .wa-ticks {
  color: #53bdeb; /* Blue read ticks */
  letter-spacing: -2px;
  margin-left: 2px;
  margin-right: 2px;
}

/* WhatsApp Rendered Formatting */
.statmat-tool.whatsapp-formatter .wa-body strong {
  font-weight: bold;
}
.statmat-tool.whatsapp-formatter .wa-body em {
  font-style: italic;
}
.statmat-tool.whatsapp-formatter .wa-body del {
  text-decoration: line-through;
}
.statmat-tool.whatsapp-formatter .wa-body code {
  font-family: monospace;
  background: transparent;
  color: inherit;
}

/* Empty */
.statmat-tool.whatsapp-formatter .empty-preview {
  color: #667781;
  font-style: italic;
}

/* Toast */
.statmat-tool.whatsapp-formatter .toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #111b21;
  color: white;
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 9999;
}

.statmat-tool.whatsapp-formatter .toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Global override for mobile scrolling on long results */
.statmat-tool [class*="result"], 
.statmat-tool [class*="output"],
.statmat-tool [class*="preview"],
.statmat-tool [class*="display"] {
  overflow-x: auto;
  max-width: 100%;
}

/* Global safeguard: ensure main wrapper never exceeds mobile viewport */
.statmat-tool {
  width: 100% !important;
  box-sizing: border-box;
}
