/*
 * CSS nội dung tin bài — nguồn duy nhất (SAS-1102026).
 * Được nạp bởi: swood-ecommerce (pages/_document.tsx), TinyMCE trong admin (content_css), WebView của App.
 * Mọi rule nằm trong .sw-post. Sửa file này thì tăng POST_CONTENT_CSS_VERSION (src/common/configs/postContent.ts)
 * và Cms:ContentCssVersion bên admin cho bằng nhau.
 */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,600;0,700;1,400&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Noto+Serif:ital,wght@0,400;0,700;1,400&display=swap');

/* ---------- 1. Nền + reset (thay Tailwind preflight để editor / web / App giống nhau) ---------- */
.sw-post {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55; /* = --mantine-line-height của web, để bài cũ không đổi chiều cao */
  overflow-wrap: break-word;
  counter-reset: sw-h1 sw-h2 sw-h3;
}
.sw-post::after { content: ''; display: table; clear: both; }
.sw-post *, .sw-post *::before, .sw-post *::after { box-sizing: border-box; }
/* Màu viền mặc định #e5e7eb như Tailwind preflight của web (viền đặt bằng style inline mà không nêu màu vẫn ra xám như cũ). */
.sw-post, .sw-post *, .sw-post *::before, .sw-post *::after { border-color: #e5e7eb; }
.sw-post h1, .sw-post h2, .sw-post h3, .sw-post h4, .sw-post h5, .sw-post h6,
.sw-post p, .sw-post blockquote, .sw-post figure, .sw-post ol, .sw-post ul, .sw-post hr, .sw-post pre { margin: 0; }
.sw-post h1, .sw-post h2, .sw-post h3, .sw-post h4, .sw-post h5, .sw-post h6 { font-size: inherit; font-weight: inherit; line-height: inherit; }
.sw-post a { color: blue; text-decoration: inherit; }
.sw-post table { border: 0 solid; border-collapse: collapse; text-indent: 0; border-color: inherit; }
.sw-post td, .sw-post th { border-width: 0; border-style: solid; }
.sw-post img, .sw-post svg, .sw-post video, .sw-post iframe { vertical-align: middle; }
.sw-post svg, .sw-post video, .sw-post iframe { display: block; }
.sw-post iframe { border: 0; }
.sw-post img, .sw-post video { max-width: 100%; height: auto; }

/* ---------- 2. Rule cũ của .detail-cms (giữ nguyên để bài đã đăng hiển thị như cũ) ---------- */
.sw-post table:not([cellpadding]) td, .sw-post table:not([cellpadding]) th { padding: 6.4px; }
.sw-post table[border]:not([border="0"]):not([style*=border-width]) td,
.sw-post table[border]:not([border="0"]):not([style*=border-width]) th { border-width: 1px; }
.sw-post table[border]:not([border="0"]):not([style*=border-style]) td,
.sw-post table[border]:not([border="0"]):not([style*=border-style]) th { border-style: solid; }
.sw-post table[border]:not([border="0"]):not([style*=border-color]) td,
.sw-post table[border]:not([border="0"]):not([style*=border-color]) th { border-color: #ccc; }
.sw-post figure { display: table; margin: 16px auto; }
.sw-post figure figcaption { color: #999; display: block; margin-top: 4px; text-align: center; }
.sw-post hr { height: 0; border-color: #ccc; border-style: solid; border-width: 1px 0 0 0; }
.sw-post code { background-color: #e8e8e8; border-radius: 3px; padding: 1.6px 3.2px; color: inherit; font-size: 1em; }
.sw-post blockquote { padding: 8px 20px; border-left: 4px solid #eee; margin: 5px 0; font-style: italic; font-size: 16px; color: #333; }

.sw-post #cms-button-link {
  display: block;
  box-sizing: border-box;
  width: fit-content;
  background: var(--sw-primary-background-gradient, linear-gradient(247.31deg, #0047AF 1%, #001670 99%)) !important;
  color: white !important;
  padding: 0 24px;
  height: 36px;
  border-radius: 36px;
  margin: 8px 0;
  font-weight: 600;
}

.sw-post ol, .sw-post ul, .sw-post menu { padding-left: 20px; }
.sw-post ol { list-style-type: decimal; }
.sw-post ul { list-style-type: disc; }
.sw-post li { list-style-position: outside; }

.sw-post h2, .sw-post h3, .sw-post h4, .sw-post h5, .sw-post h6, .sw-post p { word-break: break-word; }
.sw-post h2 { color: var(--sw-primary-color, #001670); font-weight: 700; text-transform: uppercase; font-size: 28px; padding-bottom: 16px; }
.sw-post h3 { color: var(--sw-primary-color, #001670); font-weight: 700; text-transform: uppercase; font-size: 20px; }
.sw-post h4 { color: var(--sw-primary-color, #001670); font-size: 14px; padding-bottom: 16px; }
.sw-post h5 { height: 2px; margin-bottom: 16px; background-color: #686868; max-width: 100px; }
.sw-post h6 { font-size: 18px; padding: 5px 0; font-style: italic; }
.sw-post p { font-size: 16px; padding: 5px 0; font-weight: 400; text-align: justify; }
.sw-post img { display: inline; }
.sw-post iframe, .sw-post video { width: 100%; }
.sw-post figcaption { padding: 10px 0 0; font-style: italic; color: #6b6b6b; text-align: center; font-size: 16px; }

/* ---------- 3. Đề mục phân cấp tự đánh số (I. → 1. → 1.1.) ---------- */
.sw-post .sw-h1, .sw-post .sw-h2, .sw-post .sw-h3, .sw-post .sw-title, .sw-post .sw-subtitle {
  color: var(--sw-primary-color, #001670);
  text-transform: none;
  padding: 0;
}
.sw-post .sw-h1 { font-size: 22px; font-weight: 700; text-transform: uppercase; margin: 24px 0 12px; counter-increment: sw-h1; counter-reset: sw-h2 sw-h3; }
.sw-post .sw-h2 { font-size: 18px; font-weight: 700; margin: 20px 0 8px; counter-increment: sw-h2; counter-reset: sw-h3; }
.sw-post .sw-h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; color: #101113; counter-increment: sw-h3; }
.sw-post .sw-h1::before { content: counter(sw-h1, upper-roman) ". "; }
.sw-post .sw-h2::before { content: counter(sw-h2) ". "; }
.sw-post .sw-h3::before { content: counter(sw-h2) "." counter(sw-h3) ". "; }
.sw-post .sw-title { font-size: 28px; font-weight: 700; margin: 24px 0 12px; }
.sw-post .sw-subtitle { font-size: 20px; font-weight: 600; margin: 16px 0 8px; }

/* ---------- 4. Bố cục cột ---------- */
.sw-post .sw-cols { display: grid; gap: 16px; margin: 16px 0; align-items: start; }
.sw-post .sw-cols--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sw-post .sw-cols--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sw-post .sw-cols--media-left { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.sw-post .sw-cols--media-right { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.sw-post .sw-col > :first-child { margin-top: 0; padding-top: 0; }
.sw-post .sw-col img { display: block; width: 100%; height: auto; }

/* ---------- 5. Canh ảnh ---------- */
.sw-post img.sw-img-left { float: left; max-width: 50%; margin: 4px 16px 8px 0; }
.sw-post img.sw-img-right { float: right; max-width: 50%; margin: 4px 0 8px 16px; }
.sw-post img.sw-img-center { display: block; margin: 8px auto; }
.sw-post img.sw-img-full { display: block; width: 100%; }

/* ---------- 6. Bảng theo class ---------- */
.sw-post table.sw-table-plain td, .sw-post table.sw-table-plain th { border: 0 !important; }
.sw-post table.sw-table-bordered td, .sw-post table.sw-table-bordered th { border: 1px solid #ccc; }

/* ---------- 7. Khối dựng sẵn ---------- */
.sw-post .sw-callout { margin: 16px 0; padding: 12px 16px; border-left: 4px solid; border-radius: 8px; }
.sw-post .sw-callout--info { background: #EEF4FF; border-left-color: var(--sw-secondary-color, #0047AF); }
.sw-post .sw-callout--warning { background: #FFF8E6; border-left-color: #CCAD66; }
.sw-post .sw-callout > :first-child { padding-top: 0; }
.sw-post blockquote.sw-quote { margin: 16px 0; padding: 4px 16px; border-left: 3px solid #ccc; color: #555; font-style: italic; }
.sw-post a.sw-btn {
  display: inline-block;
  background: var(--sw-primary-background-gradient, linear-gradient(247.31deg, #0047AF 1%, #001670 99%));
  color: #fff !important;
  padding: 0 24px;
  height: 36px;
  line-height: 36px;
  border-radius: 36px;
  margin: 8px 0;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- 8. Tệp đính kèm (icon vẽ bằng CSS, không chèn SVG vào nội dung) ---------- */
.sw-post .sw-file { margin: 8px 0; padding: 0; text-align: left; }
.sw-post .sw-file a { display: inline-flex; align-items: center; gap: 6px; color: blue; text-decoration: underline; }
.sw-post .sw-file a::after {
  content: '';
  flex: none;
  width: 20px;
  height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15'%3E%3Cpath fill='%23001670' fill-rule='evenodd' clip-rule='evenodd' d='M7 9.35801V1H8V9.29289L10.1464 7.14645L10.8536 7.85355L7.51386 11.1932L3.91086 7.8674L4.58914 7.1326L7 9.35801ZM2 13V7H1V14H14V7H13V13H2Z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- 9. Màn hình nhỏ ---------- */
@media screen and (max-width: 1024px) {
  .sw-post h2 { padding-top: 16px; }
}
@media screen and (max-width: 640px) {
  .sw-post .sw-cols { grid-template-columns: minmax(0, 1fr); }
  .sw-post img.sw-img-left, .sw-post img.sw-img-right { float: none; display: block; max-width: 100%; margin: 8px auto; }
}
@media screen and (max-width: 450px) {
  .sw-post p { font-size: 14px !important; }
  .sw-post li { font-size: 14px !important; }
}
