/* ============================================================
   KODBIZDE RICH EDITOR — yeni, sağlam sürüm (.rte-*)
   Admin (admin-rich.js host: .rt-host / .rt-hidden-textarea) + Forum ortak.
   ============================================================ */

/* admin-rich.js mount kabı + gizli textarea (form taşıyıcısı) */
.rt-host { display: block; }
.rt-hidden-textarea { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; pointer-events: none; }

/* ---- kabuk ---- */
.rte {
  border: 1px solid #D6DEE9;
  border-radius: 12px;
  background: #fff;
  position: relative;
  overflow: visible;
  font-family: Inter, system-ui, Arial, sans-serif;
}
.rte:focus-within { border-color: #1E3A8A; box-shadow: 0 0 0 3px rgba(30,58,138,0.10); }

/* ---- araç çubuğu ---- */
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 7px 8px;
  border-bottom: 1px solid #E7EDF4;
  background: #F8FAFC;
  border-radius: 12px 12px 0 0;
  position: sticky; top: 0; z-index: 3;
}
.rte-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: #334155; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.rte-btn:hover { background: #EDF2F8; color: #0F172A; }
.rte-btn.is-active { background: rgba(30,58,138,0.10); color: #1E3A8A; border-color: rgba(30,58,138,0.20); }
.rte-btn svg { display: block; }
.rte-sep { width: 1px; height: 20px; background: #E2E8F0; margin: 0 5px; flex: 0 0 auto; }
.rte-color-dot {
  width: 15px; height: 15px; border-radius: 4px;
  background: linear-gradient(135deg, #DC2626, #1E3A8A 50%, #16A34A);
  display: inline-block;
}

/* ---- düzenleme alanı ---- */
.rte-area {
  padding: 14px 16px;
  outline: none;
  color: #0F172A;
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.rte-area[data-empty="1"]::before {
  content: attr(data-ph);
  color: #94A3B8;
  pointer-events: none;
  display: block;
}
.rte-compact .rte-area { font-size: 14.5px; }

/* içerik biçimleri (editör içi görünüm) */
.rte-area > *:first-child { margin-top: 0; }
.rte-area > *:last-child { margin-bottom: 0; }
.rte-area p { margin: 0 0 10px; }
.rte-area h2 { font-size: 21px; font-weight: 700; margin: 18px 0 10px; line-height: 1.3; color: #0B1220; }
.rte-area h3 { font-size: 17px; font-weight: 700; margin: 16px 0 8px; line-height: 1.35; color: #0B1220; }
.rte-area ul, .rte-area ol { margin: 0 0 10px; padding-left: 26px; }
.rte-area li { margin: 3px 0; }
.rte-area a { color: #1E3A8A; text-decoration: underline; }
.rte-area blockquote {
  margin: 0 0 12px; padding: 8px 16px;
  border-left: 4px solid #C7D2E4; background: #F1F5FB;
  color: #475569; border-radius: 0 8px 8px 0;
}
.rte-area pre {
  margin: 0 0 12px; padding: 14px 16px;
  background: #0F172A; color: #E2E8F0;
  border-radius: 10px; overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; line-height: 1.6;
}
.rte-area pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.rte-area code { background: #EEF2F7; color: #B4145A; padding: 2px 6px; border-radius: 5px; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; }
.rte-area img { max-width: 100%; height: auto; border-radius: 8px; margin: 4px 0; }
.rte-area table { border-collapse: collapse; width: 100%; margin: 0 0 12px; }
.rte-area td, .rte-area th { border: 1px solid #D6DEE9; padding: 7px 10px; min-width: 40px; }
.rte-area th { background: #F1F5FB; font-weight: 700; }
.rte-area hr { border: 0; border-top: 1px solid #E2E8F0; margin: 14px 0; }

/* ---- açılır kutular (link/renk/emoji/görsel/tablo) ---- */
.rte-pop-wrap { position: absolute; top: 46px; left: 8px; z-index: 20; }
.rte-pop {
  background: #fff; border: 1px solid #D6DEE9; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15,23,42,0.16);
  padding: 10px; min-width: 250px;
}
.rte-pop-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rte-pop-input {
  flex: 1; min-width: 150px; padding: 9px 11px;
  border: 1px solid #D6DEE9; border-radius: 9px; font-size: 14px; outline: none;
}
.rte-pop-input:focus { border-color: #1E3A8A; box-shadow: 0 0 0 3px rgba(30,58,138,0.10); }
.rte-pop-btn {
  padding: 9px 14px; border: 0; border-radius: 9px;
  background: #1E3A8A; color: #fff; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.rte-pop-btn:hover { background: #172554; }
.rte-pop-hint { font-size: 12px; color: #64748B; margin-bottom: 7px; font-weight: 600; }
.rte-pop-link-rm {
  margin-top: 8px; width: 100%; padding: 8px; border: 1px solid #FECACA;
  background: #FEF2F2; color: #B91C1C; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.rte-pop-link-rm:hover { background: #FEE2E2; }
.rte-pop-colors { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; min-width: 0; }
.rte-color-cell { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(0,0,0,0.08); cursor: pointer; }
.rte-color-cell:hover { transform: scale(1.08); }
.rte-pop-emoji { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-width: 300px; max-height: 200px; overflow-y: auto; }
.rte-emoji-cell { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 7px; font-size: 18px; cursor: pointer; line-height: 1; }
.rte-emoji-cell:hover { background: #EDF2F8; }

/* mobil */
@media (max-width: 600px) {
  .rte-btn { width: 30px; height: 30px; }
  .rte-area { padding: 12px 13px; font-size: 14.5px; }
  .rte-pop { min-width: 210px; }
}
