
.wysiwyg-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid #c8ccd0;
  border-radius: 4px;
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #333;
  box-sizing: border-box;
  position: relative;
}

.wysiwyg-wrapper * {
  box-sizing: border-box;
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  background: #f6f8fa;
  border-bottom: 1px solid #c8ccd0;
  min-height: 38px;
  user-select: none;
}

.wysiwyg-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  color: #444;
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  position: relative;
}

.wysiwyg-toolbar-btn svg {
  pointer-events: none;
}

.wysiwyg-toolbar-btn:hover {
  background: #e8eaed;
  border-color: #c0c4c8;
  color: #111;
}

.wysiwyg-toolbar-btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.wysiwyg-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.wysiwyg-toolbar-sep {
  width: 1px;
  height: 20px;
  background: #d0d4d8;
  margin: 0 4px;
  flex-shrink: 0;
}

.wysiwyg-toolbar-select {
  height: 28px;
  padding: 0 4px;
  border: 1px solid #c8ccd0;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
  color: #444;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
}

.wysiwyg-toolbar-select:hover {
  border-color: #888;
}

.wysiwyg-toolbar-select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

.wysiwyg-toolbar-btn.color-btn {
  width: 28px;
  height: 28px;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.color-swatch {
  display: block;
  width: 14px;
  height: 3px;
  border-radius: 1px;
  margin-top: 1px;
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}

.wysiwyg-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.wysiwyg-editor-area {
  flex: 1;
  padding: 14px 16px;
  outline: none;
  overflow-y: auto;
  line-height: 1.6;
  color: #222;
  background: #fff;
  cursor: text;
  min-height: 150px;
  word-break: break-word;
}

.wysiwyg-editor-area:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
  pointer-events: none;
}

.wysiwyg-editor-area p { margin: 0 0 0.75em; }
.wysiwyg-editor-area p:last-child { margin-bottom: 0; }
.wysiwyg-editor-area h1,
.wysiwyg-editor-area h2,
.wysiwyg-editor-area h3,
.wysiwyg-editor-area h4,
.wysiwyg-editor-area h5,
.wysiwyg-editor-area h6 { margin: 0.75em 0 0.4em; line-height: 1.3; }
.wysiwyg-editor-area h1 { font-size: 2em; }
.wysiwyg-editor-area h2 { font-size: 1.5em; }
.wysiwyg-editor-area h3 { font-size: 1.25em; }
.wysiwyg-editor-area h4 { font-size: 1.1em; }
.wysiwyg-editor-area h5 { font-size: 1em; }
.wysiwyg-editor-area h6 { font-size: 0.9em; color: #555; }
.wysiwyg-editor-area blockquote {
  margin: 0.75em 0;
  padding: 0.5em 1em;
  border-left: 4px solid #d0d4d8;
  color: #555;
  background: #f9fafb;
}
.wysiwyg-editor-area pre {
  background: #f3f4f6;
  border: 1px solid #e0e2e6;
  border-radius: 4px;
  padding: 1em;
  margin: 0.75em 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  overflow-x: auto;
  white-space: pre-wrap;
}
.wysiwyg-editor-area code {
  font-family: 'Courier New', Courier, monospace;
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}
.wysiwyg-editor-area pre code {
  background: none;
  padding: 0;
}
.wysiwyg-editor-area ul,
.wysiwyg-editor-area ol { margin: 0.5em 0; padding-left: 2em; }
.wysiwyg-editor-area li { margin: 0.25em 0; }
.wysiwyg-editor-area a { color: #1d6eb5; text-decoration: underline; }
.wysiwyg-editor-area a:hover { color: #1558a0; }
.wysiwyg-editor-area hr {
  border: none;
  border-top: 2px solid #d0d4d8;
  margin: 1em 0;
}
.wysiwyg-editor-area table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75em 0;
}
.wysiwyg-editor-area th,
.wysiwyg-editor-area td {
  border: 1px solid #c8ccd0;
  padding: 6px 10px;
  min-width: 40px;
}
.wysiwyg-editor-area th {
  background: #f6f8fa;
  font-weight: 600;
}

.wysiwyg-editor-area img {
  max-width: 100%;
  cursor: default;
}

.wysiwyg-editor-area img.selected-img {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.wysiwyg-img-wrapper {
  position: relative;
  display: inline-block;
}

.wysiwyg-img-wrapper.float-left { float: left; margin: 0 12px 8px 0; }
.wysiwyg-img-wrapper.float-right { float: right; margin: 0 0 8px 12px; }
.wysiwyg-img-wrapper.align-center { display: block; text-align: center; }

.img-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #1d6eb5;
  border: 1px solid #fff;
  border-radius: 50%;
}
.img-resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

.wysiwyg-media-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 0.75em 0;
}

.wysiwyg-media-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.wysiwyg-source-area {
  flex: 1;
  padding: 14px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  color: #222;
  background: #f8f9fa;
  white-space: pre;
  word-break: break-all;
  line-height: 1.5;
}

.wysiwyg-source-area:focus {
  background: #fff;
}

.wysiwyg-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 10px;
  background: #f6f8fa;
  border-top: 1px solid #c8ccd0;
  font-size: 11px;
  color: #777;
  min-height: 24px;
  flex-shrink: 0;
}

.wys-elementpath {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.wys-path-seg {
  padding: 1px 5px;
  border-radius: 3px;
  color: #555;
  cursor: pointer;
}

.wys-path-seg:hover {
  background: #e8eaed;
  color: #1d4ed8;
}

.wys-path-sep {
  color: #bbb;
  user-select: none;
}

.wys-counts {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.wysiwyg-toolbar-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}

.wysiwyg-toolbar-btn[data-tooltip]:hover::after {
  opacity: 1;
}

.wysiwyg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wys-fade-in 0.1s ease;
}

@keyframes wys-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.wysiwyg-dialog {
  background: #fff;
  border-radius: 6px;
  padding: 24px 28px;
  min-width: 320px;
  max-width: 520px;
  width: calc(100vw - 40px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: wys-slide-in 0.15s ease;
}

@keyframes wys-slide-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.wysiwyg-dialog h3 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 600;
  color: #111;
}

.wysiwyg-dialog-field {
  margin-bottom: 14px;
}

.wysiwyg-dialog-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
}

.wysiwyg-dialog-field input[type="text"],
.wysiwyg-dialog-field input[type="url"],
.wysiwyg-dialog-field input[type="number"],
.wysiwyg-dialog-field textarea,
.wysiwyg-dialog-field select {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #c8ccd0;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
  background: #fff;
}

.wysiwyg-dialog-field input:focus,
.wysiwyg-dialog-field textarea:focus,
.wysiwyg-dialog-field select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25);
}

.wysiwyg-dialog-field input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}

.wysiwyg-dialog-field .checkbox-label {
  font-size: 13px;
  color: #444;
  cursor: pointer;
  user-select: none;
}

.wysiwyg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.wysiwyg-btn {
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  outline: none;
}

.wysiwyg-btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.wysiwyg-btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.wysiwyg-btn-secondary {
  background: #f6f8fa;
  color: #444;
  border-color: #c8ccd0;
}

.wysiwyg-btn-secondary:hover {
  background: #e8eaed;
}

.wysiwyg-btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

.wysiwyg-btn-danger:hover {
  background: #b91c1c;
}

.table-picker {
  display: grid;
  grid-template-columns: repeat(10, 22px);
  gap: 2px;
  margin-top: 8px;
}

.table-picker-cell {
  width: 22px;
  height: 22px;
  border: 1px solid #d0d4d8;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.table-picker-cell.highlighted {
  background: #dbeafe;
  border-color: #60a5fa;
}

.table-picker-label {
  margin-top: 6px;
  font-size: 12px;
  color: #555;
  text-align: center;
}

.find-results-count {
  font-size: 11px;
  color: #777;
  padding: 2px 0;
}

.wysiwyg-wrapper.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  border: none;
}

.wysiwyg-wrapper.fullscreen .wysiwyg-editor-area,
.wysiwyg-wrapper.fullscreen .wysiwyg-source-area {
  height: calc(100vh - 80px) !important;
  max-height: none !important;
}

.wysiwyg-table-toolbar {
  position: absolute;
  background: #fff;
  border: 1px solid #c8ccd0;
  border-radius: 4px;
  display: flex;
  gap: 1px;
  padding: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 500;
}

.wysiwyg-table-toolbar .wysiwyg-toolbar-btn {
  width: 24px;
  height: 24px;
}
