/* Reddit Formatting Tool Styles */
.statmat-tool.reddit-formatter {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  color: #1c1c1c; /* Reddit text color */
}

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

.statmat-tool.reddit-formatter .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background-color: #f6f7f8; /* Reddit light grey */
  border: 1px solid #edeff1;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 8px 12px;
}

.statmat-tool.reddit-formatter .format-btn {
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  color: #878a8c;
  transition: all 0.2s;
}

.statmat-tool.reddit-formatter .format-btn:hover {
  background-color: #e2e2e2;
  color: #1c1c1c;
}

.statmat-tool.reddit-formatter .toolbar-divider {
  width: 1px;
  background-color: #edeff1;
  margin: 4px 6px;
}

.statmat-tool.reddit-formatter .input-wrapper {
  margin-bottom: 12px;
}

.statmat-tool.reddit-formatter textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #edeff1;
  border-radius: 0 0 4px 4px;
  font-size: 14px;
  font-family: monospace; /* Monospace for Markdown editor */
  resize: vertical;
  min-height: 150px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #fff;
  line-height: 21px;
}

.statmat-tool.reddit-formatter textarea:focus {
  outline: none;
  border-color: #1c1c1c;
}

.statmat-tool.reddit-formatter .action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.statmat-tool.reddit-formatter .help-link {
  font-size: 12px;
  color: #0079d3; /* Reddit blue */
  text-decoration: none;
  font-weight: 600;
}

.statmat-tool.reddit-formatter .help-link:hover {
  text-decoration: underline;
}

.statmat-tool.reddit-formatter .actions {
  display: flex;
  gap: 12px;
}

.statmat-tool.reddit-formatter .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 9999px; /* Pill shape */
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.2s;
}

.statmat-tool.reddit-formatter .btn-primary {
  background-color: #0079d3;
  color: #fff;
}

.statmat-tool.reddit-formatter .btn-primary:hover {
  background-color: #1484d6;
}

.statmat-tool.reddit-formatter .btn-secondary {
  background-color: transparent;
  color: #0079d3;
  border: 1px solid #0079d3;
}

.statmat-tool.reddit-formatter .btn-secondary:hover {
  background-color: #f5fafd;
}

/* Reddit Preview Area */
.statmat-tool.reddit-formatter .preview-section h4 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: uppercase;
  color: #878a8c;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.statmat-tool.reddit-formatter .reddit-preview-box {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 16px;
}

.statmat-tool.reddit-formatter .reddit-comment {
  display: flex;
}

.statmat-tool.reddit-formatter .reddit-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: #d7dfe2;
  flex-shrink: 0;
  margin-right: 8px;
}

.statmat-tool.reddit-formatter .reddit-content {
  flex-grow: 1;
  min-width: 0;
}

.statmat-tool.reddit-formatter .reddit-header {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.statmat-tool.reddit-formatter .reddit-username {
  font-weight: 700;
  color: #1c1c1c;
}

.statmat-tool.reddit-formatter .reddit-time {
  color: #787c7e;
}

.statmat-tool.reddit-formatter .reddit-body {
  font-size: 14px;
  line-height: 21px;
  color: #1c1c1c;
  word-wrap: break-word;
  font-family: "Noto Sans", Arial, sans-serif;
}

.statmat-tool.reddit-formatter .reddit-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #878a8c;
  font-weight: 700;
}

.statmat-tool.reddit-formatter .action-icon {
  font-size: 16px;
  cursor: pointer;
}

.statmat-tool.reddit-formatter .action-text {
  cursor: pointer;
}

/* Reddit Markdown Render Styles */
.statmat-tool.reddit-formatter .md-content p {
  margin-top: 0;
  margin-bottom: 0.5em;
}

.statmat-tool.reddit-formatter .md-content p:last-child {
  margin-bottom: 0;
}

.statmat-tool.reddit-formatter .md-content strong {
  font-weight: 700;
}

.statmat-tool.reddit-formatter .md-content em {
  font-style: italic;
}

.statmat-tool.reddit-formatter .md-content del {
  text-decoration: line-through;
}

.statmat-tool.reddit-formatter .md-content .r-spoiler {
  background-color: #d6d6d6;
  color: transparent;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 2px;
  transition: background-color 0.2s, color 0.2s;
}

.statmat-tool.reddit-formatter .md-content .r-spoiler:hover,
.statmat-tool.reddit-formatter .md-content .r-spoiler.revealed {
  background-color: transparent;
  color: inherit;
}

.statmat-tool.reddit-formatter .md-content code {
  background-color: #f6f7f8;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 2px;
  color: #ff006d; /* Reddit inline code pink */
}

.statmat-tool.reddit-formatter .md-content pre {
  background-color: #f6f7f8;
  border-radius: 4px;
  padding: 8px;
  margin: 8px 0;
  overflow-x: auto;
}

.statmat-tool.reddit-formatter .md-content pre code {
  background-color: transparent;
  padding: 0;
  color: #1c1c1c;
}

.statmat-tool.reddit-formatter .md-content blockquote {
  border-left: 4px solid #c1c2c3;
  margin: 8px 0;
  padding-left: 12px;
  color: #555;
}

.statmat-tool.reddit-formatter .md-content h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 12px 0 8px 0;
}

.statmat-tool.reddit-formatter .md-content sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  top: -0.5em;
}

/* Toast */
.statmat-tool.reddit-formatter .toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #1c1c1c;
  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.reddit-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;
}
