/* ════════════════════════════════════════════════════════════════════
 *  blog-editor.css — v47 "Blog Editor Pro"
 *  Loaded after the inline admin.php styles, overrides where needed.
 *
 *  Sections:
 *    1.  Grouped ribbon toolbar
 *    2.  Active-state highlighting
 *    3.  Sticky toolbar positioning
 *    4.  Slash command menu popup
 *    5.  Block menu (+ in margin)
 *    6.  Floating selection toolbar
 *    7.  Drag-and-drop overlay
 *    8.  Upload progress placeholder
 *    9.  Word count + reading time
 *    10. Editor canvas polish
 * ════════════════════════════════════════════════════════════════════ */


/* ── 1. Grouped ribbon toolbar ───────────────────────────────── */
.rte-toolbar-v47 {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  align-items: flex-end;
  padding: .55rem .75rem .65rem;
  background: linear-gradient(180deg, #fafbfc 0%, #f1f3f5 100%);
  border: 1px solid #d4d8dc;
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.rte-group {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  position: relative;
}
.rte-group + .rte-group::before {
  content: '';
  position: absolute;
  left: -.5rem;
  top: .8rem;
  bottom: .1rem;
  width: 1px;
  background: #d4d8dc;
}

.rte-group-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  padding-left: .15rem;
}

.rte-group .rte-controls {
  display: flex;
  gap: .15rem;
  align-items: center;
}

/* Buttons within the new ribbon */
.rte-toolbar-v47 .rte-btn {
  background: #ffffff;
  border: 1px solid #d4d8dc;
  border-radius: 5px;
  padding: .32rem .55rem;
  font-size: .82rem;
  cursor: pointer;
  color: #1e293b;
  transition: background .12s, border-color .12s, box-shadow .12s;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
}
.rte-toolbar-v47 .rte-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}
.rte-toolbar-v47 .rte-btn:active {
  background: #dbeafe;
  transform: translateY(.5px);
}

/* Selects within the new ribbon */
.rte-toolbar-v47 select {
  background: #ffffff;
  border: 1px solid #d4d8dc;
  border-radius: 5px;
  padding: .3rem .45rem;
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  min-height: 30px;
}
.rte-toolbar-v47 select:hover { border-color: #93c5fd; }

/* Color pickers — keep the existing visual but match the ribbon */
.rte-toolbar-v47 .rte-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #d4d8dc;
  border-radius: 5px;
  width: 38px;
  height: 30px;
  cursor: pointer;
  overflow: hidden;
}
.rte-toolbar-v47 .rte-color-wrap:hover { border-color: #93c5fd; }
.rte-toolbar-v47 .rte-color-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.rte-toolbar-v47 .rte-color-icon {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  pointer-events: none;
}


/* ── 2. Active-state highlighting (on Bold, Italic, etc.) ────── */
.rte-toolbar-v47 .rte-btn.is-active {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
  color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(29,78,216,.4);
}
.rte-toolbar-v47 .rte-btn.is-active b,
.rte-toolbar-v47 .rte-btn.is-active i,
.rte-toolbar-v47 .rte-btn.is-active u,
.rte-toolbar-v47 .rte-btn.is-active s {
  color: #ffffff;
}


/* ── 3. Word count + reading time ────────────────────────────── */
.rte-status {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  padding-bottom: .15rem;
}
.rte-wordcount {
  font-size: .76rem;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  background: #ffffff;
  border: 1px solid #d4d8dc;
  border-radius: 99px;
  padding: .3rem .75rem;
}


/* ── 4. Slash command menu popup ─────────────────────────────── */
.rte-slash-menu {
  position: absolute;
  background: #ffffff;
  border: 1px solid #d4d8dc;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.08);
  z-index: 1000;
  min-width: 280px;
  max-width: 360px;
  max-height: 360px;
  overflow-y: auto;
  padding: .35rem 0;
  font-family: inherit;
  font-size: .9rem;
}
.rte-slash-menu-search {
  padding: .55rem .85rem .4rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #94a3b8;
  font-weight: 600;
  border-bottom: 1px solid #f1f5f9;
}
.rte-slash-menu-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .85rem;
  cursor: pointer;
  transition: background .08s;
}
.rte-slash-menu-item:hover,
.rte-slash-menu-item.is-active {
  background: #eff6ff;
}
.rte-slash-menu-item-icon {
  font-size: 1.05rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.rte-slash-menu-item-text {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  flex: 1;
  min-width: 0;
}
.rte-slash-menu-item-title {
  font-weight: 600;
  color: #1e293b;
  font-size: .88rem;
}
.rte-slash-menu-item-desc {
  font-size: .74rem;
  color: #64748b;
}
.rte-slash-menu-empty {
  padding: 1.1rem .85rem;
  text-align: center;
  color: #94a3b8;
  font-size: .85rem;
}


/* ── 5. Block menu (+ in margin) ──────────────────────────────── */
.rte-editor-wrap {
  position: relative;
}
.rte-block-add {
  position: absolute;
  left: -34px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #d4d8dc;
  color: #64748b;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .12s, color .12s, border-color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  font-family: inherit;
  padding: 0;
  line-height: 1;
}
.rte-block-add.is-visible {
  opacity: 1;
}
.rte-block-add:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}
@media (max-width: 1100px) {
  /* Hide on narrow screens — no margin to put it in */
  .rte-block-add { display: none; }
}


/* ── 6. Floating selection toolbar ───────────────────────────── */
.rte-selection-bar {
  position: absolute;
  background: #1e293b;
  border-radius: 7px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  padding: .25rem;
  display: none;
  gap: .15rem;
  z-index: 999;
  font-family: inherit;
}
.rte-selection-bar.is-visible {
  display: flex;
}
.rte-selection-bar .rte-sel-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  padding: .35rem .55rem;
  border-radius: 5px;
  font-size: .82rem;
  cursor: pointer;
  min-width: 28px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rte-selection-bar .rte-sel-btn:hover {
  background: rgba(255,255,255,.15);
}
.rte-selection-bar .rte-sel-btn.is-active {
  background: #1d4ed8;
}
.rte-selection-bar::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #1e293b;
}
.rte-selection-bar.is-flipped::after {
  top: -6px;
  bottom: auto;
  border-top: none;
  border-bottom: 6px solid #1e293b;
}


/* ── 7. Drag-and-drop overlay ────────────────────────────────── */
.rte-dragdrop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(29,78,216,.08);
  border: 3px dashed #1d4ed8;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1d4ed8;
  pointer-events: none;
  z-index: 100;
  letter-spacing: .01em;
}
.rte-dragdrop-overlay.is-visible {
  display: flex;
}


/* ── 8. Upload progress placeholder ──────────────────────────── */
.rte-upload-placeholder {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 220px;
  height: 140px;
  background: #f1f5f9;
  border: 2px dashed #cbd5e1;
  border-radius: 7px;
  color: #64748b;
  font-size: .82rem;
  font-weight: 500;
  margin: .35rem 0;
  font-family: inherit;
}
.rte-upload-placeholder .rte-upload-bar {
  width: 80%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin-top: .35rem;
}
.rte-upload-placeholder .rte-upload-bar-fill {
  height: 100%;
  background: #1d4ed8;
  width: 0%;
  transition: width .3s;
}


/* ── 9. Editor canvas polish ─────────────────────────────────── */
.rte-editor-wrap #postContent {
  border: 1px solid #d4d8dc;
  border-top: none;
  border-radius: 0 0 7px 7px;
  min-height: 360px;
  padding: 1.25rem 1.5rem;
  background: #ffffff;
  outline: none;
  font-size: 1rem;
  line-height: 1.6;
}
.rte-editor-wrap #postContent:focus-within {
  border-color: #93c5fd;
}
.rte-editor-wrap #postContent:empty::before {
  content: attr(placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.rte-editor-wrap #postContent p {
  margin: 0 0 1rem;
}
.rte-editor-wrap #postContent p:last-child {
  margin-bottom: 0;
}
