/*** ck-editor ***/
.ck-editor__editable_inline {
  min-height: 80px;
}

.ck-powered-by {
  display: none;
}

.ck.ck-icon {
  font-size: 0.62em !important;
}

.ck.ck-color-grid__tile {
  height: calc(0.65 * var(--ck-color-grid-tile-size)) !important;
  min-height: calc(0.65 * var(--ck-color-grid-tile-size)) !important;
  min-width: calc(0.65 * var(--ck-color-grid-tile-size)) !important;
  width: calc(0.65 * var(--ck-color-grid-tile-size)) !important;
}

.ck-editor__editable[role="textbox"] {
  min-height: 100px;
}

.ck-content .image {
  max-width: 80%;
  margin: 20px auto;
}

/* Định dạng chung cho thẻ figure sử dụng ck-editor */
figure {
  margin: 1.5em 0;
  text-align: center;
}

/* Định dạng cho thẻ figure khi có media */
figure.media {
  display: block;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}
/* figure.media div[data-oembed-url] {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
} */
figure.media iframe,
figure.media video {
  /* position: absolute; */
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border: 0;
}

figure.image {
  display: inline-block;
  margin: 1em 0;
}
figure.image_resized {
  width: 100%;
}

.image-style-side {
  float: right;
  margin-left: 1em;
  max-width: 50%;
}

figure.image img {
  display: block;
  max-width: 100%;
  height: auto;
}
figure.image img[style*="aspect-ratio"] {
  /* Ensure aspect ratio is maintained */
  width: 100%;
  height: auto;
}
figure.image figcaption {
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  margin-top: 0.5em;
  background: #f7f7f7;
  padding: 10px 2px;
}

/* Định dạng cho bảng */
/* figure table {
    border: 1px double #b3b3b3;
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
	height: auto;
}
figure table td, figure table th {
    border: 1px solid #bfbfbf;
    min-width: 2em;
    padding: 0.4em;
    overflow-wrap: break-word;
    position: relative;
} */

figure.table {
  display: table;
  margin: 1em 0;
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
figure.table table {
  width: 100%;
  border-collapse: collapse;
}

figure.table table,
figure.table th,
figure.table td {
  border: 1px solid #ddd;
  padding: 5px;
}

figure.table th {
  background-color: #f2f2f2;
  font-weight: bold;
}
figure.table td {
  background-color: #fff;
}

figure.table figcaption {
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  margin-top: 0.5em;
  background: #f7f7f7;
  padding: 10px 2px;
}

/****** ck-editor */
/* Nếu popup Swal nằm trên editor, tăng z-index CK balloon đề phòng */
:root {
  --ck-z-default: 200000;
  --ck-z-panel: 200001;
  --ck-z-modal: 200002;
}
.ck-body-wrapper,
.ck.ck-balloon-panel,
.ck.ck-balloon-rotator,
.ck.ck-tooltip {
  z-index: 200000 !important;
}

/* Bọc editor để làm gốc cho absolute */
.rte-wrap {
  position: relative;
}

/* Nút nổi phủ trên thanh toolbar */
.rte-fab {
  /* position: absolute;
    top: 5px;
    right: 8px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1;
    color: #000;
    border: 0;
    cursor: pointer; */
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: #000;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.rte-fab-group {
  position: absolute;
  top: 5px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 5;
}

.rte-fab--icon {
  background: none;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background-color 0.12s ease, box-shadow 0.12s ease,
    border-color 0.12s ease;
  outline: none;
}
.rte-fab--icon:hover {
  background-color: #f0f0f0;
}
.rte-fab--icon:focus {
  border-color: #3779eb;
  box-shadow: 0 0 0 3px #cae1fc;
  outline: none;
}

/* Khi có nút nổi, đẩy nội dung toolbar sang trái một chút để không bị che */
.rte-wrap .ck.ck-toolbar {
  padding-right: 120px; /* đủ chỗ cho nút nổi */
}

/* Overlay + backdrop nằm TRONG Swal (không full màn hình) */
/* Khóa scroll khi mở overlay */
.body--overlay-open {
  overflow: hidden;
}

/* Overlay toàn màn hình, nổi trên mọi thứ */
.rte-global-overlay {
  position: fixed;
  inset: 0;
  z-index: 200000; /* cao hơn Swal/CK */
  display: flex;
  align-items: center;
  justify-content: center;
}

.rte-global-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.rte-global-overlay__panel {
  position: relative;
  z-index: 1;
  width: 380px;
  max-width: calc(100% - 32px);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 9px 28px 8px rgba(0, 0, 0, 0.05),
    0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0px rgba(0, 0, 0, 0.08);
}

.rte-global-overlay__header {
  height: 52px;
  padding: 20px 24px 8px 24px;
}

.rte-global-overlay__title {
  font-size: 16px;
  font-weight: 700;
  line-height: 150%;
  color: rgba(0, 0, 0, 0.88);
}

.rte-global-overlay__actions {
  display: grid;
  padding: 0;
  margin: 0;
  padding: 12px 24px 20px 24px;
}

.rte-global-overlay__btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}
.rte-global-overlay__btn:hover {
  background: #f9fafb;
  border-color: #e5e7eb;
}

.rte-global-overlay__btn:active {
  background: #cff8f0;
  border-color: #e5e7eb;
  color: #17726d;
}

.rte-global-overlay__close {
  cursor: pointer;
}

.rte-global-overlay__close:hover svg path {
  fill: rgba(0, 0, 0, 0.88);
  fill-opacity: 1;
}

/* Spinner overlay cho CKEditor */
.rte-busy-host {
  position: relative;
}

.rte-busy-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: all; /* chặn click trong lúc bận */
}
.rte-busy-overlay .spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: #1f6bff;
  animation: rteSpin 0.8s linear infinite;
}
.rte-busy-overlay .label {
  margin-left: 10px;
  font: 500 14px/1.2 system-ui, -apple-system, Segoe UI, Roboto;
  color: #1f2d3d;
}

@keyframes rteSpin {
  to {
    transform: rotate(360deg);
  }
}

/** */
.mc-wrap {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.mc-panel {
  position: relative;
  width: min(900px, 95vw);
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
}

.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 8px 24px;
}

.mc-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.88);
  line-height: 150%;
}

.mc-close {
  cursor: pointer;
}

.mc-close:hover svg path {
  fill: rgba(0, 0, 0, 0.88);
  fill-opacity: 1;
}

.mc-body {
  padding: 16px;
  overflow: auto;
}
.mc-search {
  position: relative;
  margin-bottom: 12px;
}
.mc-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid #ddd;
  border-radius: 8px;
}
.mc-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.mc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.mc-tab {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.mc-tab--active {
  background: #eef4ff;
  color: #17726d;
}
.mc-section-label {
  font-size: 12px;
  text-transform: uppercase;
  color: #777;
  margin-bottom: 8px;
}
.mc-folder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mc-folder-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  background: #fafafa;
}
.mc-folder-card:hover {
  background: #f2f6ff;
}
.mc-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
}
.mc-btn {
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #fff;
}
.mc-btn--primary {
  background: #17726d;
  color: #fff;
  border-color: #17726d;
}

/*** */
/* .resizable-embed { aspect-ratio: var(--ar, 16/9); }
.resizable-embed iframe { width:100%; height:100%; } */
.ck-content .resizable-embed {
  width: var(--w, 640px); /* cho phép set width bằng biến --w */
  max-width: 100%;
  aspect-ratio: var(--ar, 16/9); /* auto-height theo width */
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.ck-content .resizable-embed > iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.rte-dropdown-menu {
  display: block;
  position: absolute;
  top: 110%;
  right: 0px;
  background: rgb(255, 255, 255);
  border-radius: 8px;
  box-shadow: 0 9px 28px 8px rgba(0, 0, 0, 0.05),
    0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0px rgba(0, 0, 0, 0.08);
  min-width: 180px;
  padding: 4px;
  z-index: 9;
}

.rte-dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.88);
  font-weight: 500;
  min-height: 32px;
  border-radius: 4px;
}

.rte-dropdown-menu-item:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.rte-dropdown-menu-item:active {
  background-color: #cff8f0;
  color: #17726d;
}

.ic-16 {
  width: 16px !important;
  height: 16px !important;
}

.ic-22 {
  width: 22px !important;
  height: 22px !important;
}

.gap-16 {
  gap: 16px !important;
}
