﻿.clean-rte {
  border: 1px solid #d4d4d8;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.clean-rte-toolbar {
  border-bottom: 1px solid #e4e4e7;
  background: #f3f4f6;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.clean-rte-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.clean-rte .clean-rte-name,
.clean-rte .clean-rte-row select,
.clean-rte .clean-rte-color {
  height: 36px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
}

.clean-rte .clean-rte-name {
  width: 130px;
  padding: 0 10px;
  flex: 0 0 auto;
}

.clean-rte .clean-rte-row select {
  width: auto;
  min-width: 122px;
  padding: 0 10px;
  flex: 0 0 auto;
}

.clean-rte .clean-rte-color {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  width: auto;
  flex: 0 0 auto;
}

.clean-rte-color span {
  font-size: 14px;
  font-weight: 600;
}

.clean-rte .clean-rte-color input[type="color"] {
  width: 26px;
  min-width: 26px;
  height: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.clean-rte-buttons button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.clean-rte-buttons button i {
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.clean-rte-buttons button:hover {
  background: #f9fafb;
}

.clean-rte-buttons button.is-active,
.clean-rte-buttons button.is-mode-active {
  border-color: #9ca3af;
  background: #e5e7eb;
}

.clean-rte-canvas {
  min-height: 320px;
  max-height: 62vh;
  overflow: auto;
  padding: 16px;
  outline: none;
  color: #111827;
  line-height: 1.6;
}

.clean-rte-canvas p,
.clean-rte-canvas h1,
.clean-rte-canvas h2,
.clean-rte-canvas h3,
.clean-rte-canvas blockquote,
.clean-rte-canvas ul,
.clean-rte-canvas ol {
  margin: 0 0 12px;
}

.clean-rte-canvas h1 { font-size: 2rem; }
.clean-rte-canvas h2 { font-size: 1.6rem; }
.clean-rte-canvas h3 { font-size: 1.3rem; }

.clean-rte-canvas blockquote {
  border-left: 3px solid #9ca3af;
  padding-left: 10px;
  color: #374151;
}

.clean-rte-canvas a {
  color: #0f4abf;
}

.clean-rte-canvas figure {
  margin: 10px 0 14px;
}

.clean-rte-canvas figure img {
  max-width: 100%;
  width: min(100%, 760px);
  max-height: min(70vh, 1200px);
  height: auto;
  border-radius: 8px;
  display: block;
}

.clean-rte-canvas img {
  max-width: 100%;
  width: min(100%, 760px);
  max-height: min(70vh, 1200px);
  height: auto;
  display: block;
  object-fit: contain;
}

.clean-rte-canvas p,
.clean-rte-canvas figure {
  overflow: hidden;
}

.clean-rte-canvas img.rte-image-selected {
  outline: 3px solid #4f46e5;
  outline-offset: 2px;
}

.clean-rte-canvas figcaption {
  margin-top: 6px;
  color: #4b5563;
  font-size: 13px;
}

.clean-rte-source {
  width: 100%;
  min-height: 320px;
  max-height: 62vh;
  resize: vertical;
  border: 0;
  border-top: 1px solid #e4e4e7;
  outline: none;
  padding: 16px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #111827;
  background: #ffffff;
}

.clean-rte.is-source-mode .clean-rte-canvas {
  display: none;
}

.clean-rte.is-source-mode .clean-rte-source {
  display: block;
}

.rte-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.46);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 10050;
}

.rte-modal-overlay[hidden] {
  display: none !important;
}

.rte-modal-card {
  width: min(100%, 460px);
  background: #ffffff;
  border: 1px solid #d4d4d8;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(2, 6, 23, 0.2);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.rte-modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.rte-modal-card p {
  margin: 0;
  color: #4b5563;
  font-size: 0.92rem;
}

.rte-modal-card label {
  display: grid;
  gap: 6px;
}

.rte-modal-card label span {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1f2937;
}

.rte-modal-card input,
.rte-modal-card textarea {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  color: #111827;
  background: #ffffff;
}

.rte-modal-card textarea {
  resize: vertical;
  min-height: 86px;
}

.rte-media-modal {
  width: min(100%, 760px);
  max-height: min(86vh, 860px);
}

.rte-media-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.rte-media-tools input[type="search"] {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  color: #111827;
  background: #ffffff;
}

.rte-media-grid {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
  max-height: 52vh;
  overflow: auto;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.rte-media-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid #dbe0e8;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  text-align: left;
  padding: 8px;
  cursor: pointer;
}

.rte-media-item:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.rte-media-thumb {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: #eef2f7;
}

.rte-media-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rte-media-copy strong,
.rte-media-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rte-media-copy strong {
  font-size: 0.9rem;
}

.rte-media-copy small {
  color: #4b5563;
  font-size: 0.75rem;
}

.rte-media-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 14px;
  color: #475569;
  text-align: center;
}

.rte-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.rte-btn-muted,
.rte-btn-primary {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.rte-btn-muted {
  background: #ffffff;
  color: #111827;
}

.rte-btn-primary {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}

@media (max-width: 760px) {
  .clean-rte {
    border-radius: 8px;
  }

  .clean-rte-toolbar {
    padding: 10px;
    gap: 8px;
  }

  .clean-rte-row {
    gap: 8px;
  }

  .clean-rte-buttons button {
    min-width: 42px;
    padding: 0 8px;
  }

  .clean-rte-canvas,
  .clean-rte-source {
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  .clean-rte .clean-rte-name,
  .clean-rte .clean-rte-row select,
  .clean-rte .clean-rte-color {
    width: 100%;
    min-width: 100%;
  }

  .clean-rte-buttons button {
    flex: 1 1 44px;
  }

  .rte-media-tools {
    grid-template-columns: 1fr;
  }

  .rte-media-grid {
    grid-template-columns: 1fr;
  }
}
