/* =========================================================================
   Builder — Section Editor (Cover + WYSIWYG content)

   Site khong dung Bootstrap. File nay cung cap style cho MOI thanh phan
   ma TinyMCE (Classic Editor) + Gutenberg block co the sinh ra: heading,
   list, table, cot, anh, video, iframe, align, font-size, color, button...
   ========================================================================= */

/* ---------- Inner wrapper ------------------------------------------------ */
.bs-section-editor__inner {
  max-width: 1070px;
  margin: 0 auto;
  padding: 75px 15px;
  box-sizing: border-box;
}

@media screen and (max-width: 767px) {
  .bs-section-editor__inner {
    padding: 48px 15px;
  }
}

/* ---------- WYSIWYG content root ---------------------------------------- */
.bs-section-editor__content {
  color: #293948;
  font-family: var(--font-hn);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.bs-section-editor__content > *:first-child { margin-top: 0; }
.bs-section-editor__content > *:last-child  { margin-bottom: 0; }

/* ---------- Headings ---------------------------------------------------- */
.bs-section-editor__content h1,
.bs-section-editor__content h2,
.bs-section-editor__content h3,
.bs-section-editor__content h4,
.bs-section-editor__content h5,
.bs-section-editor__content h6 {
  color: #293948;
  font-family: var(--font-hn);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.bs-section-editor__content h1 { margin: 32px 0 16px; font-size: 32px; }
.bs-section-editor__content h2 { margin: 28px 0 14px; font-size: 26px; }
.bs-section-editor__content h3 { margin: 24px 0 12px; font-size: 22px; }
.bs-section-editor__content h4 { margin: 20px 0 10px; font-size: 18px; }
.bs-section-editor__content h5 { margin: 18px 0 8px;  font-size: 16px; font-weight: 600; }
.bs-section-editor__content h6 { margin: 16px 0 8px;  font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Paragraph, hr, blockquote, code ----------------------------- */
.bs-section-editor__content p {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.65;
}

.bs-section-editor__content a {
  color: #D85401;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.bs-section-editor__content a:hover,
.bs-section-editor__content a:focus {
  color: #b64301;
}

.bs-section-editor__content strong,
.bs-section-editor__content b { font-weight: 700; }

.bs-section-editor__content em,
.bs-section-editor__content i { font-style: italic; }

.bs-section-editor__content u { text-decoration: underline; }

.bs-section-editor__content small { font-size: 0.85em; }

.bs-section-editor__content hr {
  border: 0;
  border-top: 1px solid #E0E0E0;
  margin: 32px 0;
}

.bs-section-editor__content blockquote {
  margin: 20px 0;
  padding: 12px 20px;
  border-left: 4px solid #D85401;
  color: #465E75;
  font-style: italic;
  background: #F7F9FB;
  border-radius: 0 8px 8px 0;
}

.bs-section-editor__content blockquote p:last-child { margin-bottom: 0; }

.bs-section-editor__content pre {
  margin: 16px 0;
  padding: 16px;
  background: #1E2A38;
  color: #E7EBEF;
  border-radius: 8px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.5;
}

.bs-section-editor__content code {
  padding: 2px 6px;
  background: #F0F2F5;
  color: #C7361F;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.bs-section-editor__content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  border-radius: 0;
  font-size: inherit;
}

/* ---------- Lists ------------------------------------------------------- */
.bs-section-editor__content ul,
.bs-section-editor__content ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.bs-section-editor__content ul { list-style: disc outside; }
.bs-section-editor__content ol { list-style: decimal outside; }

.bs-section-editor__content li {
  margin: 0 0 6px;
  line-height: 1.6;
}

.bs-section-editor__content li > ul,
.bs-section-editor__content li > ol {
  margin: 6px 0 0;
}

/* ---------- Tables (khong co framework - style default) ----------------- */
.bs-section-editor__content table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
  font-size: 15px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
}

.bs-section-editor__content table caption {
  padding: 8px 12px;
  font-weight: 600;
  text-align: left;
  color: #465E75;
}

.bs-section-editor__content thead th {
  padding: 12px 14px;
  background: #F0F4F7;
  color: #293948;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid #E0E0E0;
}

.bs-section-editor__content tbody th {
  padding: 10px 14px;
  background: #F7F9FB;
  color: #293948;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid #E0E0E0;
  border-right: 1px solid #E0E0E0;
}

.bs-section-editor__content td {
  padding: 10px 14px;
  border-bottom: 1px solid #EEEEEE;
  border-right: 1px solid #EEEEEE;
  vertical-align: top;
}

.bs-section-editor__content tbody tr:last-child td,
.bs-section-editor__content tbody tr:last-child th { border-bottom: 0; }

.bs-section-editor__content td:last-child,
.bs-section-editor__content th:last-child { border-right: 0; }

/* Table responsive wrapper: neu bang qua rong, cho scroll ngang */
.bs-section-editor__content .table-responsive,
.bs-section-editor__content .wp-block-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Wide table on mobile: scroll */
@media screen and (max-width: 640px) {
  .bs-section-editor__content table {
    min-width: 480px;
  }
  .bs-section-editor__content {
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- Images (Classic + Gutenberg) -------------------------------- */
.bs-section-editor__content img {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: contain;
  background: #F4F6F8;
  border-radius: 8px;
  display: block;
}

.bs-section-editor__content p img,
.bs-section-editor__content figure img { display: block; }

.bs-section-editor__content .aligncenter,
.bs-section-editor__content img.aligncenter,
.bs-section-editor__content figure.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.bs-section-editor__content .alignleft,
.bs-section-editor__content img.alignleft,
.bs-section-editor__content figure.alignleft {
  float: left;
  margin: 4px 20px 12px 0;
  max-width: 50%;
}

.bs-section-editor__content .alignright,
.bs-section-editor__content img.alignright,
.bs-section-editor__content figure.alignright {
  float: right;
  margin: 4px 0 12px 20px;
  max-width: 50%;
}

.bs-section-editor__content .alignnone,
.bs-section-editor__content img.alignnone {
  display: block;
  margin: 12px 0;
  max-width: 100%;
}

.bs-section-editor__content .alignwide {
  margin-left: -60px;
  margin-right: -60px;
  max-width: none;
  width: calc(100% + 120px);
}

.bs-section-editor__content .alignfull {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  max-width: 100vw;
  width: 100vw;
}

@media screen and (max-width: 900px) {
  .bs-section-editor__content .alignwide { margin-left: 0; margin-right: 0; width: 100%; }
}

/* Clear floats after floated images */
.bs-section-editor__content::after {
  content: "";
  display: table;
  clear: both;
}

/* Figure & caption */
.bs-section-editor__content figure {
  margin: 16px 0;
}

.bs-section-editor__content figcaption,
.bs-section-editor__content .wp-caption-text {
  margin-top: 8px;
  font-size: 13.5px;
  color: #616161;
  text-align: center;
  font-style: italic;
}

.bs-section-editor__content .wp-caption {
  max-width: 100%;
}

/* Image size classes */
.bs-section-editor__content .size-thumbnail img { max-width: 150px; }
.bs-section-editor__content .size-medium img    { max-width: 300px; }
.bs-section-editor__content .size-large img     { max-width: 640px; }
.bs-section-editor__content .size-full img      { max-width: 100%; }

/* ---------- Video ------------------------------------------------------- */
.bs-section-editor__content video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  max-width: 100%;
  margin: 16px 0;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

/* ---------- Iframe (YouTube, Vimeo, Google Maps, etc.) ------------------ */
/* Wrap iframe fallback: responsive aspect-ratio */
.bs-section-editor__content iframe {
  display: block;
  max-width: 100%;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  margin: 16px 0;
  border: 0;
  border-radius: 8px;
  background: #000;
}

/* WordPress embed wrappers (oEmbed / [embed] / Gutenberg) */
.bs-section-editor__content .wp-block-embed,
.bs-section-editor__content .wp-block-embed__wrapper,
.bs-section-editor__content .wp-embed-responsive {
  margin: 16px 0;
  position: relative;
  width: 100%;
}

.bs-section-editor__content .wp-block-embed iframe,
.bs-section-editor__content .wp-embed-responsive iframe {
  margin: 0;
}

.bs-section-editor__content .wp-block-embed figcaption {
  margin-top: 8px;
}

/* ---------- Columns (Gutenberg) ---------------------------------------- */
.bs-section-editor__content .wp-block-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 20px 0;
}

.bs-section-editor__content .wp-block-column {
  flex: 1 1 0;
  min-width: 0;
  word-break: break-word;
}

/* Column layout hints from Gutenberg */
.bs-section-editor__content .wp-block-columns.are-vertically-aligned-top    { align-items: flex-start; }
.bs-section-editor__content .wp-block-columns.are-vertically-aligned-center { align-items: center; }
.bs-section-editor__content .wp-block-columns.are-vertically-aligned-bottom { align-items: flex-end; }

.bs-section-editor__content .wp-block-column > *:first-child { margin-top: 0; }
.bs-section-editor__content .wp-block-column > *:last-child  { margin-bottom: 0; }

@media screen and (max-width: 781px) {
  .bs-section-editor__content .wp-block-columns:not(.is-not-stacked-on-mobile) {
    flex-direction: column;
    gap: 20px;
  }
  .bs-section-editor__content .wp-block-columns:not(.is-not-stacked-on-mobile) > .wp-block-column {
    flex-basis: 100% !important;
  }
}

/* ---------- Buttons (Gutenberg) ----------------------------------------- */
.bs-section-editor__content .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}

.bs-section-editor__content .wp-block-buttons.aligncenter { justify-content: center; }
.bs-section-editor__content .wp-block-buttons.alignright  { justify-content: flex-end; }

.bs-section-editor__content .wp-block-button__link,
.bs-section-editor__content .wp-element-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 40px;
  background: #293948;
  color: #FFFFFF;
  font-family: var(--font-hn);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.bs-section-editor__content .wp-block-button__link:hover,
.bs-section-editor__content .wp-element-button:hover {
  background: #D85401;
  color: #FFFFFF;
}

.bs-section-editor__content .is-style-outline .wp-block-button__link {
  background: transparent;
  color: #293948;
  border: 1px solid #293948;
}

.bs-section-editor__content .is-style-outline .wp-block-button__link:hover {
  background: #293948;
  color: #FFFFFF;
}

/* ---------- Text alignment (Gutenberg + inline styles) ------------------ */
.bs-section-editor__content .has-text-align-left    { text-align: left; }
.bs-section-editor__content .has-text-align-center  { text-align: center; }
.bs-section-editor__content .has-text-align-right   { text-align: right; }
.bs-section-editor__content .has-text-align-justify { text-align: justify; }

/* Classic editor text-align via style attribute already works natively */

/* ---------- Font sizes (Gutenberg) -------------------------------------- */
.bs-section-editor__content .has-small-font-size    { font-size: 13px; }
.bs-section-editor__content .has-medium-font-size   { font-size: 18px; }
.bs-section-editor__content .has-large-font-size    { font-size: 24px; line-height: 1.4; }
.bs-section-editor__content .has-x-large-font-size  { font-size: 32px; line-height: 1.3; }
.bs-section-editor__content .has-xx-large-font-size { font-size: 42px; line-height: 1.2; }

/* ---------- Color classes (Gutenberg palette placeholders) -------------- */
/* Chi cung cap khi user chon color trong Gutenberg: WP tu them class kiem
   theo palette. Neu palette custom, class se co ten khac -> style tu WP core.
   O day chi bao dam ho tro `--wp--preset--color--*` variables + inline. */

.bs-section-editor__content [style*="color"]           { /* respect inline */ }
.bs-section-editor__content [style*="background"]      { /* respect inline */ }

/* Preset colors thuong dung */
.bs-section-editor__content .has-black-color   { color: #000; }
.bs-section-editor__content .has-white-color   { color: #FFF; }
.bs-section-editor__content .has-primary-color { color: #293948; }
.bs-section-editor__content .has-accent-color  { color: #D85401; }

.bs-section-editor__content .has-black-background-color   { background-color: #000; }
.bs-section-editor__content .has-white-background-color   { background-color: #FFF; }
.bs-section-editor__content .has-primary-background-color { background-color: #293948; color: #FFF; }
.bs-section-editor__content .has-accent-background-color  { background-color: #D85401; color: #FFF; }

/* ---------- Group / Cover / Spacer / Separator blocks ------------------- */
.bs-section-editor__content .wp-block-group,
.bs-section-editor__content .wp-block-group__inner-container {
  margin: 16px 0;
}

.bs-section-editor__content .wp-block-spacer {
  height: 24px;
}

.bs-section-editor__content .wp-block-separator {
  margin: 24px auto;
  border: 0;
  border-top: 1px solid #E0E0E0;
  max-width: 100px;
}

.bs-section-editor__content .wp-block-separator.is-style-wide {
  max-width: 100%;
}

.bs-section-editor__content .wp-block-separator.is-style-dots {
  border: 0;
  text-align: center;
}

.bs-section-editor__content .wp-block-separator.is-style-dots::before {
  content: "···";
  color: #9E9E9E;
  font-size: 20px;
  letter-spacing: 12px;
}

/* ---------- Media & Text block (Gutenberg) ------------------------------ */
.bs-section-editor__content .wp-block-media-text {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
  margin: 20px 0;
}

.bs-section-editor__content .wp-block-media-text.has-media-on-the-right {
  grid-template-columns: 1fr 1fr;
}

.bs-section-editor__content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media {
  order: 2;
}

.bs-section-editor__content .wp-block-media-text__media img,
.bs-section-editor__content .wp-block-media-text__media video {
  margin: 0;
}

.bs-section-editor__content .wp-block-media-text__content > *:first-child { margin-top: 0; }
.bs-section-editor__content .wp-block-media-text__content > *:last-child  { margin-bottom: 0; }

@media screen and (max-width: 767px) {
  .bs-section-editor__content .wp-block-media-text {
    grid-template-columns: 1fr;
  }
  .bs-section-editor__content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media {
    order: 0;
  }
}

/* ---------- Cover block (background image + inner content) -------------- */
.bs-section-editor__content .wp-block-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  margin: 20px 0;
  padding: 32px;
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  overflow: hidden;
  color: #FFF;
}

.bs-section-editor__content .wp-block-cover__inner-container {
  position: relative;
  z-index: 2;
  max-width: 720px;
}

.bs-section-editor__content .wp-block-cover__inner-container > *:first-child { margin-top: 0; }
.bs-section-editor__content .wp-block-cover__inner-container > *:last-child  { margin-bottom: 0; }

.bs-section-editor__content .wp-block-cover__image-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  margin: 0;
  border-radius: 0;
}

/* Page Builder inside a product: body copy is justified by default. */
.single-product .bs-section-editor__content p,
.single-product .bs-section-editor__content li,
.single-product .bs-section-editor__content td,
.single-product .bs-section-editor__content blockquote {
  text-align: justify;
  text-align-last: left;
}

.single-product .bs-section-editor__content .has-text-align-left { text-align: left; }
.single-product .bs-section-editor__content .has-text-align-center { text-align: center; }
.single-product .bs-section-editor__content .has-text-align-right { text-align: right; }
.single-product .bs-section-editor__content .has-text-align-justify { text-align: justify; }

/* ---------- Preformatted text (line-breaks preserved) ------------------- */
.bs-section-editor__content .wp-block-preformatted {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

/* ---------- Pullquote --------------------------------------------------- */
.bs-section-editor__content .wp-block-pullquote {
  margin: 24px 0;
  padding: 24px;
  border-top: 3px solid #D85401;
  border-bottom: 3px solid #D85401;
  text-align: center;
  font-size: 20px;
  font-style: italic;
  color: #465E75;
}

.bs-section-editor__content .wp-block-pullquote cite {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-style: normal;
  color: #9E9E9E;
}

/* ---------- Kbd, mark, del ---------------------------------------------- */
.bs-section-editor__content kbd {
  padding: 2px 6px;
  background: #F0F2F5;
  border: 1px solid #D0D6DE;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: #293948;
}

.bs-section-editor__content mark { background: #FFF3CD; padding: 0 2px; }
.bs-section-editor__content del  { color: #9E9E9E; text-decoration: line-through; }
.bs-section-editor__content ins  { text-decoration: underline; }

/* ---------- Responsive typography --------------------------------------- */
@media screen and (max-width: 767px) {
  .bs-section-editor__content { font-size: 15px; }
  .bs-section-editor__content h1 { font-size: 26px; }
  .bs-section-editor__content h2 { font-size: 22px; }
  .bs-section-editor__content h3 { font-size: 19px; }
  .bs-section-editor__content h4 { font-size: 17px; }
  .bs-section-editor__content .has-large-font-size    { font-size: 20px; }
  .bs-section-editor__content .has-x-large-font-size  { font-size: 26px; }
  .bs-section-editor__content .has-xx-large-font-size { font-size: 32px; }

  .bs-section-editor__content .alignleft,
  .bs-section-editor__content .alignright,
  .bs-section-editor__content img.alignleft,
  .bs-section-editor__content img.alignright,
  .bs-section-editor__content figure.alignleft,
  .bs-section-editor__content figure.alignright {
    float: none;
    display: block;
    max-width: 100%;
    margin: 12px auto;
  }
}
