/* ==========================================================================
   TRÌNH SOẠN THẢO BÀI VIẾT KIỂU WORDPRESS (CHỈ ADMIN)
   + Kiểu hiển thị ảnh trong bài cho khách xem
   ========================================================================== */

/* ---------- 1. Ảnh trong nội dung bài (trang công khai) ---------- */
.reader-rich-body img,
#aboutPageContent img {
  max-width: 100%;
  height: auto;
}

.reader-rich-body figure.image,
#aboutPageContent figure.image {
  display: table;
  margin: 2rem auto;
  text-align: center;
}

.reader-rich-body figure.image figcaption,
#aboutPageContent figure.image figcaption {
  display: table-caption;
  caption-side: bottom;
  font-size: 0.85rem;
  font-style: italic;
  color: #666666;
  margin-top: 8px;
}

.reader-rich-body img.wp-img-center,
#aboutPageContent img.wp-img-center {
  display: block;
  margin: 1.5rem auto;
  border-radius: 8px;
}

.reader-rich-body img.wp-img-full,
#aboutPageContent img.wp-img-full {
  display: block;
  width: 100%;
  margin: 1.5rem 0;
  border-radius: 8px;
}

.reader-rich-body img.wp-img-left,
#aboutPageContent img.wp-img-left,
.reader-rich-body figure.image.wp-img-left,
#aboutPageContent figure.image.wp-img-left {
  float: left;
  max-width: 45%;
  margin: 0.4rem 1.5rem 1rem 0;
  border-radius: 8px;
}

.reader-rich-body img.wp-img-right,
#aboutPageContent img.wp-img-right,
.reader-rich-body figure.image.wp-img-right,
#aboutPageContent figure.image.wp-img-right {
  float: right;
  max-width: 45%;
  margin: 0.4rem 0 1rem 1.5rem;
  border-radius: 8px;
}

.reader-rich-body::after,
#aboutPageContent::after {
  content: '';
  display: table;
  clear: both;
}

.reader-rich-body table,
#aboutPageContent table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.reader-rich-body table td,
.reader-rich-body table th,
#aboutPageContent table td,
#aboutPageContent table th {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
}

@media (max-width: 650px) {
  .reader-rich-body img.wp-img-left,
  .reader-rich-body img.wp-img-right,
  #aboutPageContent img.wp-img-left,
  #aboutPageContent img.wp-img-right,
  .reader-rich-body figure.image.wp-img-left,
  .reader-rich-body figure.image.wp-img-right,
  #aboutPageContent figure.image.wp-img-left,
  #aboutPageContent figure.image.wp-img-right {
    float: none;
    max-width: 100%;
    margin: 1.5rem auto;
    display: block;
  }
}

/* ---------- 2. Nút sửa chỉ hiện khi admin đăng nhập ---------- */
.wp-admin-only {
  display: none !important;
}

body.wp-is-admin .wp-admin-only {
  display: inline-flex !important;
}

.wp-edit-btn {
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #2271b1;
  background: #2271b1;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: background 0.15s;
}

.wp-edit-btn:hover {
  background: #135e96;
}

.wp-edit-btn.wp-edit-btn-ghost {
  background: #ffffff;
  color: #2271b1;
}

.wp-edit-btn.wp-edit-btn-ghost:hover {
  background: #f0f6fc;
}

.wp-admin-bar {
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 1rem;
}

body.wp-is-admin .wp-admin-bar.wp-admin-only {
  display: flex !important;
}

.wp-card-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.wp-card-draft {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 3;
  background: #dba617;
  color: #1d2327;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ---------- 3. Màn hình soạn thảo ---------- */
.wpe-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #f0f0f1;
  display: none;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Plus Jakarta Sans', sans-serif;
  color: #1d2327;
}

.wpe-overlay.open {
  display: flex;
}

body.wpe-lock {
  overflow: hidden;
}

body.wpe-lock .floating-contact-widget {
  display: none !important;
}

.wpe-topbar {
  height: 56px;
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid #dcdcde;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.wpe-topbar-title {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wpe-save-state {
  font-size: 13px;
  color: #646970;
  white-space: nowrap;
}

.wpe-save-state.dirty {
  color: #b32d2e;
}

.wpe-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 3px;
  border: 1px solid #2271b1;
  background: #ffffff;
  color: #2271b1;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.wpe-btn:hover {
  background: #f0f6fc;
}

.wpe-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.wpe-btn-primary {
  background: #2271b1;
  color: #ffffff;
}

.wpe-btn-primary:hover {
  background: #135e96;
}

.wpe-btn-plain {
  border-color: transparent;
  color: #1d2327;
}

.wpe-btn-plain:hover {
  background: #f0f0f1;
}

.wpe-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.wpe-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 32px 60px;
}

.wpe-main-inner {
  max-width: 900px;
  margin: 0 auto;
}

.wpe-title {
  width: 100%;
  border: 1px solid #dcdcde;
  background: #ffffff;
  padding: 12px 14px;
  font-size: 1.7rem;
  font-weight: 700;
  font-family: 'Playfair Display', Georgia, serif;
  color: #1d2327;
  border-radius: 4px;
  box-sizing: border-box;
}

.wpe-title:focus {
  outline: 2px solid #2271b1;
  border-color: #2271b1;
}

.wpe-permalink {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 10px 0 16px;
  font-size: 13px;
  color: #50575e;
}

.wpe-permalink input {
  border: 1px solid #dcdcde;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 13px;
  min-width: 260px;
  flex: 1;
}

.wpe-editor-wrap {
  background: #ffffff;
  border-radius: 4px;
}

.wpe-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #ffffff;
  border-left: 1px solid #dcdcde;
  overflow-y: auto;
}

.wpe-panel {
  border-bottom: 1px solid #f0f0f1;
  padding: 16px;
}

.wpe-panel h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #1d2327;
}

.wpe-field {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}

.wpe-field span {
  display: block;
  margin-bottom: 4px;
  color: #50575e;
}

.wpe-field select,
.wpe-field input,
.wpe-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #8c8f94;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}

.wpe-field textarea {
  min-height: 90px;
  resize: vertical;
}

.wpe-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  cursor: pointer;
}

.wpe-cover-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: #f0f0f1 center / cover no-repeat;
  border: 1px dashed #c3c4c7;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8c8f94;
  font-size: 12px;
}

.wpe-cover-preview.has-image {
  border-style: solid;
  color: transparent;
}

.wpe-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wpe-link-danger {
  background: none;
  border: none;
  color: #b32d2e;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  margin-top: 8px;
}

.wpe-hint {
  font-size: 12px;
  color: #646970;
  line-height: 1.5;
  margin: 0 0 10px;
}

.wpe-revisions {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.wpe-revisions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f0f0f1;
  font-size: 12px;
}

.wpe-revisions li button {
  border: 1px solid #c3c4c7;
  background: #f6f7f7;
  border-radius: 3px;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.wpe-loading {
  padding: 60px 0;
  text-align: center;
  color: #646970;
  font-size: 14px;
}

/* Xem trước */
.wpe-preview {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 30px 16px;
}

.wpe-preview.open {
  display: flex;
}

.wpe-preview-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 900px;
  border-radius: 10px;
  padding: 2.5rem;
  position: relative;
  box-sizing: border-box;
}

.wpe-preview-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -1rem -1rem 0 0;
}

.wpe-preview-sheet h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.2rem;
  color: #0f172a;
  margin: 0 0 1.25rem;
}

.wpe-preview-cover {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .wpe-body {
    flex-direction: column;
    overflow-y: auto;
  }

  .wpe-main {
    overflow: visible;
    padding: 18px 14px 30px;
  }

  .wpe-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid #dcdcde;
    overflow: visible;
  }

  .wpe-topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
  }

  .wpe-save-state {
    display: none;
  }
}

/* Menu thả xuống, hộp thoại (Chèn ảnh, link, bảng…) và menu chuột phải của TinyMCE
   mặc định ở lớp 1300, thấp hơn màn hình soạn thảo (10000) nên bị che mất */
.tox.tox-tinymce-aux,
.tox-tinymce-aux,
.tox-silver-sink {
  z-index: 10030 !important;
}

/* Danh sách font chữ riêng trong cột phải */
.wpe-fonts {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.wpe-fonts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f0f0f1;
  font-size: 14px;
}

.wpe-fonts li button {
  border: none;
  background: none;
  color: #b32d2e;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
  white-space: nowrap;
}
