/* ═══ NEXORA RICH TEXT EDITOR (RTE) ═══ */

/* ── Wrapper ── */
.rte-wrap {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: var(--white, #fff);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: "Inter", sans-serif;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.rte-wrap:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ── Toolbar ── */
.rte-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  user-select: none;
}

/* Divider between toolbar groups */
.rte-sep {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
  margin: 0 8px;
  flex-shrink: 0;
}

/* Individual toolbar buttons */
.rte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  color: #4b5563;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  position: relative;
}
.rte-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}
.rte-btn.active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}
.rte-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* Select dropdowns inside toolbar */
.rte-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #4b5563;
  background: #fff;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.rte-select:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}
.rte-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.rte-select-font { width: 160px; }
.rte-select-size { width: 100px; }

/* Color pickers inside toolbar */
.rte-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.rte-color-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  cursor: pointer;
  padding: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: relative;
}
.rte-color-btn:hover { 
  border-color: #d1d5db;
  background: #f3f4f6;
}
.rte-color-btn svg { 
  width: 18px; 
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rte-icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}
.rte-color-btn-img {
  padding: 3px 4px 4px;
}
.rte-color-swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  margin-top: 2px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* Color dropdown */
.rte-color-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  min-width: 160px;
}
.rte-color-wrap.open .rte-color-dropdown {
  display: block;
}
.rte-color-palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.rte-color-option {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
}
.rte-color-option:hover {
  border-color: #3b82f6;
  transform: scale(1.1);
}
.rte-color-option.active {
  border-color: #1e40af;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.rte-custom-color {
  display: block;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  padding: 4px 0 2px;
  cursor: pointer;
  border-top: 1px solid #e5e7eb;
  margin-top: 4px;
  padding-top: 8px;
  transition: color 0.15s;
}
.rte-custom-color:hover {
  color: #3b82f6;
}
.rte-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  cursor: pointer;
}

/* Link button tooltip wrapper */
.rte-btn[data-cmd="createLink"] {
  position: relative;
}

/* ── Editor area ── */
.rte-editor {
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px 18px;
  outline: none;
  color: #111827;
  font-family: "Inter", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  caret-color: #3b82f6;
  background: #fff;
}
.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

/* Render rich content nicely inside the editor */
.rte-editor b, .rte-editor strong { font-weight: 700; }
.rte-editor i, .rte-editor em     { font-style: italic; }
.rte-editor u                     { text-decoration: underline; }
.rte-editor s, .rte-editor strike { text-decoration: line-through; }
.rte-editor h1 { font-size: 2rem; font-weight: 700; color: #111827; margin: 16px 0 8px; line-height: 1.3; }
.rte-editor h2 { font-size: 1.5rem; font-weight: 600; color: #111827; margin: 14px 0 6px; line-height: 1.3; }
.rte-editor h3 { font-size: 1.25rem; font-weight: 600; color: #111827; margin: 12px 0 5px; line-height: 1.3; }
.rte-editor ul, .rte-editor ol  { padding-left: 24px; margin: 8px 0; }
.rte-editor li  { margin: 4px 0; }
.rte-editor a   { color: #3b82f6; text-decoration: underline; }
.rte-editor a:hover { color: #2563eb; }
.rte-editor blockquote {
  border-left: 4px solid #3b82f6;
  margin: 12px 0;
  padding: 10px 16px;
  background: #eff6ff;
  border-radius: 0 6px 6px 0;
  color: #374151;
  font-style: italic;
}
.rte-editor hr { border: none; border-top: 2px solid #e5e7eb; margin: 16px 0; }
.rte-editor p  { margin: 6px 0; }
.rte-editor table { border-collapse: collapse; width: 100%; margin: 10px 0; border: 1px solid #e5e7eb; }
.rte-editor td, .rte-editor th { border: 1px solid #e5e7eb; padding: 8px 12px; }
.rte-editor th { background: #f9fafb; font-weight: 600; }

/* ── Link dialog popup ── */
.rte-link-dialog {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 9999;
  width: 400px;
  font-family: "Inter", sans-serif;
}
.rte-link-dialog.open { display: block; }
.rte-link-dialog h4 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}
.rte-link-dialog input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: #111827;
  outline: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
}
.rte-link-dialog input:focus { 
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.rte-link-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.rte-link-dialog-actions button {
  padding: 9px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: "Inter", sans-serif;
  transition: all 0.15s ease;
}
.rte-link-ok  { background: #3b82f6; color: #fff; }
.rte-link-ok:hover { background: #2563eb; }
.rte-link-cancel { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.rte-link-cancel:hover { background: #e5e7eb; }
.rte-link-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 9998;
  backdrop-filter: blur(2px);
}
.rte-link-overlay.open { display: block; }

/* ── Word-count bar ── */
.rte-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 14px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  letter-spacing: .2px;
  font-weight: 500;
}

/* ═══ PUBLIC DISPLAY STYLES (property listing & detail) ═══ */
/* Used on property-detail.php and anywhere $p['description'] is rendered as HTML */
.rte-output {
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-dark, #1a202c);
}
.rte-output b, .rte-output strong { font-weight: 700; }
.rte-output i, .rte-output em     { font-style: italic; }
.rte-output u                     { text-decoration: underline; }
.rte-output s                     { text-decoration: line-through; }
.rte-output h1 { font-size: 1.6rem; font-family: "Playfair Display", serif; color: var(--navy, #1a2e4a); margin: 16px 0 6px; }
.rte-output h2 { font-size: 1.25rem; font-family: "Playfair Display", serif; color: var(--navy, #1a2e4a); margin: 14px 0 5px; }
.rte-output h3 { font-size: 1.05rem; font-weight: 700; color: var(--navy, #1a2e4a); margin: 12px 0 4px; }
.rte-output ul, .rte-output ol  { padding-left: 22px; margin: 8px 0; }
.rte-output li  { margin: 4px 0; }
.rte-output a   { color: var(--gold, #c9a84c); text-decoration: underline; }
.rte-output blockquote {
  border-left: 4px solid var(--gold, #c9a84c);
  margin: 12px 0;
  padding: 10px 16px;
  background: rgba(201, 168, 76, 0.07);
  border-radius: 0 8px 8px 0;
  color: #555;
  font-style: italic;
}
.rte-output hr  { border: none; border-top: 2px solid var(--border, #e2e8f0); margin: 16px 0; }
.rte-output p   { margin: 6px 0; }
.rte-output table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.rte-output td, .rte-output th { border: 1px solid var(--border, #e2e8f0); padding: 7px 12px; }
.rte-output th  { background: #f7f8fa; font-weight: 600; }

/* Scrollbar styling for editor */
.rte-editor::-webkit-scrollbar {
  width: 8px;
}
.rte-editor::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}
.rte-editor::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
.rte-editor::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Tooltip for buttons */
.rte-btn::after {
  content: attr(title);
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}
.rte-btn:hover::after {
  opacity: 1;
  transition-delay: 0.5s;
}

@media (max-width: 600px) {
  .rte-select-font { width: 120px; }
  .rte-select-size { width: 85px; }
  .rte-link-dialog { width: 90vw; }
  .rte-toolbar { padding: 10px 8px; gap: 4px; }
  .rte-btn { width: 32px; height: 32px; }
  .rte-btn svg { width: 14px; height: 14px; }
  .rte-select { height: 32px; font-size: 12px; padding: 0 8px; }
  .rte-color-btn { width: 32px; height: 32px; }
  .rte-color-btn svg { width: 16px; height: 16px; }
  .rte-sep { margin: 0 4px; }
  .rte-btn::after { display: none; }
}