/* ============================================================
 * Shared Post Content Typography
 * ============================================================
 * Dipakai di:
 *  - Frontend Blade: .news-description__body.post-content
 *  - Admin CKEditor:  .ck-editor__editable.post-content
 *
 * Ubah file ini untuk mengubah tampilan konten di SEMUA tempat.
 * ============================================================ */

/* ----------------------------------
   Base Typography
   ---------------------------------- */
.post-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: hidden;
}

.post-content div,
.post-content p,
.post-content span {
    font-size: 16px;
    font-weight: 400;
    line-height: 28px;
    color: var(--color-black-3);
}

.post-content a,
.post-content a > * {
    text-decoration: underline;
    color: var(--color-primary) !important;
    transition: opacity 0.2s ease;
}

.post-content a:hover {
    opacity: 0.8;
}

.post-content p:not(:last-child),
.post-content div:not(:last-child) {
    margin-bottom: 20px;
}

.post-content strong,
.post-content b {
    font-weight: 700 !important;
}

.post-content em,
.post-content i {
    font-style: italic;
}

.post-content u {
    text-decoration: underline;
}

.post-content s,
.post-content del {
    text-decoration: line-through;
}

.post-content sub {
    vertical-align: sub;
    font-size: smaller;
}

.post-content sup {
    vertical-align: super;
    font-size: smaller;
}

/* ----------------------------------
   Text Alignment (CKEditor output)
   Supports both inline styles and
   class-based alignment.
   ---------------------------------- */
.post-content [style*="text-align:center"],
.post-content [style*="text-align: center"],
.post-content .text-align-center {
    text-align: center !important;
}

.post-content [style*="text-align:right"],
.post-content [style*="text-align: right"],
.post-content .text-align-right {
    text-align: right !important;
}

.post-content [style*="text-align:left"],
.post-content [style*="text-align: left"],
.post-content .text-align-left {
    text-align: left !important;
}

.post-content [style*="text-align:justify"],
.post-content [style*="text-align: justify"],
.post-content .text-align-justify {
    text-align: justify !important;
}

/* ----------------------------------
   Headings (h1 – h6)
   ---------------------------------- */
.post-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-black-3);
    margin: 32px 0 16px;
}

.post-content h2 {
    font-size: 1.3125rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-black-3);
    margin: 1.75rem 0 0.875rem;
}

.post-content h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-black-3);
    margin: 1.5rem 0 0.75rem;
}

.post-content h4 {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-black-3);
    margin: 1.25rem 0 0.625rem;
}

.post-content h5 {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--color-black-3);
    margin: 1rem 0 0.5rem;
}

.post-content h6 {
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--color-black-3);
    margin: 0.875rem 0 0.5rem;
}

/* Remove top margin when heading is first child */
.post-content > h1:first-child,
.post-content > h2:first-child,
.post-content > h3:first-child,
.post-content > h4:first-child,
.post-content > h5:first-child,
.post-content > h6:first-child {
    margin-top: 0;
}

/* ----------------------------------
   Figure & Images
   ---------------------------------- */
.post-content figure {
    margin: 0 0 20px 0;
    text-align: center;
}

.post-content figure.image {
    display: table;
    margin-left: auto;
    margin-right: auto;
    clear: both;
}

.post-content figcaption {
    display: table-caption;
    caption-side: bottom;
    margin-top: 8px;
    font-size: 13px !important;
    font-weight: 400;
    font-style: italic;
    line-height: 20px !important;
    color: var(--color-text);
    text-align: center;
    word-break: break-word;
}

.post-content img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    vertical-align: bottom;
}

/* CKEditor image style classes */
.post-content figure.image-style-align-left {
    float: left !important;
    margin: 0 20px 20px 0 !important;
    max-width: 50% !important;
}

.post-content figure.image-style-align-right {
    float: right !important;
    margin: 0 0 20px 20px !important;
    max-width: 50% !important;
}

.post-content figure.image-style-align-center,
.post-content figure.image-style-block-align-center {
    display: table;
    margin-left: auto;
    margin-right: auto;
    float: none;
}

.post-content figure.image-style-block-align-left {
    margin-right: auto;
    margin-left: 0;
    float: none;
}

.post-content figure.image-style-block-align-right {
    margin-left: auto;
    margin-right: 0;
    float: none;
}

.post-content figure.image-style-side {
    float: right !important;
    margin: 0 0 20px 20px !important;
    max-width: 50% !important;
}

/* CKEditor image resize support */
.post-content figure .image_resized {
    display: block;
    margin: 0 auto;
}

.post-content figure[style*="width"] {
    display: table;
}

/* Clearfix after floated images */
.post-content::after {
    content: "";
    display: table;
    clear: both;
}

/* ----------------------------------
   Lists (ordered & unordered)
   ---------------------------------- */
.post-content ul {
    list-style: disc;
    list-style-position: outside;
    padding-left: 1.5rem;
    margin: 0 0 20px 0;
}

.post-content ol {
    list-style: decimal !important;
    list-style-position: outside !important;
    padding-left: 1.5rem !important;
    margin: 0 0 20px 0 !important;
}

.post-content li {
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 28px;
    color: var(--color-black-3);
}

/* Nested list styles */
.post-content ul ul {
    list-style: circle;
    margin-bottom: 0;
    margin-top: 8px;
}

.post-content ul ul ul {
    list-style: square;
}

.post-content ol ol {
    list-style: lower-alpha !important;
    margin-bottom: 0 !important;
    margin-top: 8px !important;
}

.post-content ol ol ol {
    list-style: lower-roman !important;
}

/* CKEditor todo-list */
.post-content .todo-list {
    list-style: none;
    padding-left: 0;
}

.post-content .todo-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.post-content .todo-list li input[type="checkbox"] {
    margin-top: 6px !important;
    accent-color: var(--color-primary);
}

/* ----------------------------------
   Blockquote
   ---------------------------------- */
.post-content blockquote {
    border-left: 4px solid var(--color-primary) !important;
    margin: 20px 0;
    padding: 12px 20px;
    background-color: rgba(57, 169, 53, 0.05);
    font-style: italic;
    color: var(--color-black-3);
}

.post-content blockquote p {
    margin-bottom: 0;
}

.post-content blockquote p + p {
    margin-top: 12px;
}

/* ----------------------------------
   Code & Pre-formatted
   ---------------------------------- */
.post-content code {
    font-family: "Courier New", Courier, monospace;
    font-size: 14px;
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    color: #c7254e;
}

.post-content pre {
    font-family: "Courier New", Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    background-color: #2b2b2b;
    color: #f8f8f2;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 0 0 20px 0;
    overflow-x: auto;
    white-space: pre;
}

.post-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
    font-size: inherit;
}

/* ----------------------------------
   Horizontal Rule
   ---------------------------------- */
.post-content hr {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 28px 0;
}

/* ----------------------------------
   Table Styles
   ---------------------------------- */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 28px;
    color: var(--color-black-3);
}

/* CKEditor wraps tables in <figure class="table"> */
.post-content figure.table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 0 0 20px 0;
    display: block;
}

.post-content figure.table table {
    margin-bottom: 0;
    min-width: 600px; /* Ensures table doesn't squish too much before scrolling */
}

/* Legacy .table class wrapper (non-figure) */
.post-content .table:not(figure) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    max-width: 100%;
    margin-bottom: 20px;
}

.post-content .table:not(figure) table {
    margin-bottom: 0;
}

.post-content table tbody {
    display: table-row-group;
    width: 100%;
}

.post-content table thead {
    display: table-header-group;
    width: 100%;
}

.post-content table td,
.post-content table th {
    border: 1px solid #ccc !important;
    padding: 10px 12px !important;
    text-align: left;
    font-size: 16px !important;
    line-height: 28px !important;
    color: var(--color-black-3) !important;
    vertical-align: top;
}

.post-content table th {
    font-weight: 600;
    background-color: #f5f5f5;
}

.post-content table td.label {
    font-weight: 600;
}

.post-content table td.value {
    font-weight: 400;
}

/* Zebra-stripe table rows */
.post-content table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

/* ----------------------------------
   Marker / Highlight (CKEditor)
   ---------------------------------- */
.post-content mark,
.post-content .marker-yellow {
    background-color: #fdfd77;
    padding: 1px 2px;
}

.post-content .marker-green {
    background-color: #63f963;
    padding: 1px 2px;
}

.post-content .marker-pink {
    background-color: #fc7999;
    padding: 1px 2px;
}

.post-content .marker-blue {
    background-color: #72cdfd;
    padding: 1px 2px;
}

.post-content .pen-red {
    color: #e91313;
}

.post-content .pen-green {
    color: #118800;
}

/* ----------------------------------
   Media Embed (CKEditor oembed)
   ---------------------------------- */
.post-content figure.media,
.post-content .media {
    margin: 0 0 20px 0;
    clear: both;
    max-width: 100%;
}

.post-content figure.media > div,
.post-content .media > div {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 10px;
}

.post-content figure.media iframe,
.post-content .media iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
}

/* Standalone iframes */
.post-content iframe {
    max-width: 100%;
    border: none;
    border-radius: 10px;
}

/* ----------------------------------
   Page break (CKEditor)
   ---------------------------------- */
.post-content .page-break {
    page-break-after: always;
    margin: 20px 0;
    border-top: 2px dashed #ccc;
}

/* ----------------------------------
   Mention (CKEditor)
   ---------------------------------- */
.post-content .mention {
    color: var(--color-primary);
    background-color: rgba(57, 169, 53, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ----------------------------------
   Font size / color overrides
   CKEditor outputs inline styles for
   font-size and color. We must NOT
   override them with !important.
   ---------------------------------- */
.post-content [style*="font-size"] {
    line-height: 1.6;
}

.post-content [style*="color"] {
    color: unset;
}

/* ----------------------------------
   Responsive Styles
   ---------------------------------- */
@media screen and (max-width: 992px) {
    .post-content div,
    .post-content p,
    .post-content span,
    .post-content li,
    .post-content table td,
    .post-content table th {
        font-size: 14px;
        line-height: 24px;
    }

    .post-content h1 {
        font-size: 26px;
    }

    .post-content h2 {
        font-size: 22px;
    }

    .post-content h3 {
        font-size: 18px;
    }

    .post-content h4 {
        font-size: 16px;
    }

    .post-content figcaption {
        font-size: 12px !important;
    }

    /* On mobile, floated images go full width */
    .post-content figure.image-style-align-left,
    .post-content figure.image-style-align-right,
    .post-content figure.image-style-side {
        float: none !important;
        max-width: 100% !important;
        margin: 0 0 20px 0 !important;
    }

    .post-content pre {
        font-size: 12px;
        padding: 12px 14px;
    }

    .post-content code {
        font-size: 12px;
    }

    .post-content blockquote {
        padding: 10px 16px;
    }
}

@media screen and (max-width: 576px) {
    .post-content h1 {
        font-size: 22px;
        margin: 24px 0 12px;
    }

    .post-content h2 {
        font-size: 20px;
        margin: 20px 0 10px;
    }

    .post-content h3 {
        font-size: 17px;
        margin: 18px 0 8px;
    }

    .post-content h4 {
        font-size: 15px;
    }

    .post-content table {
        font-size: 13px;
    }

    .post-content table td,
    .post-content table th {
        padding: 8px !important;
        font-size: 13px;
        line-height: 20px;
    }
}
