/*!
 * WYSIWYG Editor - CSS
 * A lightweight, dependency-free rich text editor.
 * https://github.com/ (bundle for standalone use)
 * License: MIT
 */

.wye-wrapper {
  --wye-border: #d0d5dd;
  --wye-toolbar-bg: #f7f8fa;
  --wye-btn-hover: #e7e9ee;
  --wye-btn-active: #d8dcff;
  --wye-text: #1f2430;
  --wye-panel-bg: #ffffff;
  --wye-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  --wye-radius: 6px;
  --wye-accent: #4a5df9;

  box-sizing: border-box;
  border: 1px solid var(--wye-border);
  border-radius: var(--wye-radius);
  overflow: visible;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wye-text);
  background: var(--wye-panel-bg);
}

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

/* ---------- Toolbar ---------- */

.wye-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--wye-toolbar-bg);
  border-bottom: 1px solid var(--wye-border);
  border-radius: var(--wye-radius) var(--wye-radius) 0 0;
  position: relative;
  user-select: none;
}

.wye-group {
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
}

.wye-sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 4px;
  background: var(--wye-border);
}

.wye-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--wye-text);
}

.wye-btn:hover {
  background: var(--wye-btn-hover);
}

.wye-btn.is-active {
  background: var(--wye-btn-active);
  border-color: var(--wye-accent);
}

.wye-btn svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.wye-select {
  height: 30px;
  border: 1px solid var(--wye-border);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  padding: 0 4px;
  color: var(--wye-text);
  cursor: pointer;
  max-width: 130px;
}

.wye-color-btn {
  position: relative;
  overflow: hidden;
}

.wye-color-btn input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.wye-color-swatch {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 4px;
  height: 3px;
  border-radius: 1px;
  background: #ff0000;
  pointer-events: none;
}

/* ---------- Dropdown panels (emoji, link, image) ---------- */

.wye-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1000;
  background: var(--wye-panel-bg);
  border: 1px solid var(--wye-border);
  border-radius: var(--wye-radius);
  box-shadow: var(--wye-shadow);
  padding: 10px;
  display: none;
}

.wye-panel.is-open {
  display: block;
}

.wye-emoji-panel {
  width: 260px;
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
}

.wye-emoji {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  width: 28px;
  height: 28px;
}

.wye-emoji:hover {
  background: var(--wye-btn-hover);
}

.wye-form-panel {
  width: 300px;
}

.wye-form-panel h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.wye-form-row {
  margin-bottom: 8px;
}

.wye-form-row label {
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  color: #555;
}

.wye-form-row input[type="text"],
.wye-form-row input[type="url"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--wye-border);
  border-radius: 4px;
  font-size: 13px;
}

.wye-form-row.wye-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wye-form-row.wye-checkbox label {
  margin: 0;
}

.wye-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--wye-border);
}

.wye-tab {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: #555;
}

.wye-tab.is-active {
  border-bottom-color: var(--wye-accent);
  color: var(--wye-text);
  font-weight: 600;
}

.wye-tab-content {
  display: none;
}

.wye-tab-content.is-active {
  display: block;
}

.wye-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.wye-btn-primary,
.wye-btn-secondary {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--wye-border);
}

.wye-btn-primary {
  background: var(--wye-accent);
  border-color: var(--wye-accent);
  color: #fff;
}

.wye-btn-secondary {
  background: #fff;
  color: var(--wye-text);
}

/* ---------- Editable area ---------- */

.wye-editable {
  min-height: 220px;
  max-height: 600px;
  overflow-y: auto;
  padding: 12px 14px;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  border-radius: 0 0 var(--wye-radius) var(--wye-radius);
}

.wye-editable img {
  max-width: 100%;
  height: auto;
}

.wye-editable a {
  color: var(--wye-accent);
}

.wye-editable blockquote {
  margin: 0 0 0 0;
  padding-left: 12px;
  border-left: 3px solid var(--wye-border);
  color: #555;
}

.wye-editable:empty:before {
  content: attr(data-placeholder);
  color: #9aa0ac;
  pointer-events: none;
}

/* Source view */
.wye-source {
  display: none;
  width: 100%;
  min-height: 220px;
  max-height: 600px;
  border: none;
  padding: 12px 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  resize: vertical;
  outline: none;
}

.wye-wrapper.wye-source-mode .wye-editable {
  display: none;
}

.wye-wrapper.wye-source-mode .wye-source {
  display: block;
}
