/*
 * สไตล์กลางของเนื้อหาข่าวที่ดึงมาจากระบบ ServiceCenter
 *
 * เนื้อหาก้อนนี้ถูกส่งมาเป็น HTML ทั้งเอกสาร (มี <head> และ <style> ของตัวเอง)
 * แล้วถูกแปะเข้าหน้าเราด้วย Html.Raw ทำให้เกิดปัญหา 2 อย่าง
 *   1. <style> และ style="" ที่ติดมา ทำให้ CSP ต้องเปิด 'unsafe-inline' ค้างไว้
 *   2. selector ใน <style> นั้นเป็น global (body, h1, p, *) จึงรั่วไปทับสไตล์ของหน้าเรา
 *
 * ฝั่ง ALPHAX จึงตัด <head> กับ style="" ออกตอนนำเนื้อหามาแสดง
 * (ดู StripEmbeddedInlineCode ใน DoProcessController) แล้วยกกฎที่จำเป็นมาไว้ที่ไฟล์นี้
 * โดยจำกัดขอบเขตทุกกฎไว้ใต้ .ir-news-content เท่านั้น ไม่ให้รั่วออกไปนอกกล่องเนื้อหา
 *
 * ทุกข่าวจึงแสดงผลเป็นรูปแบบเดียวกัน และไม่ละเมิด CSP ไม่ว่าเนื้อหาจะใส่อะไรมา
 */

/* ---------- โครงกล่องเนื้อหา ---------- */

.ir-news-content {
    font-size: 14px;
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: break-word;
}

    .ir-news-content * {
        box-sizing: border-box;
    }

    /* เดิม ServiceCenter ส่ง .news-wrapper / .news-box มาพร้อมสไตล์ของตัวเอง */
    .ir-news-content .news-wrapper {
        width: 100%;
        padding: 15px;
    }

    .ir-news-content .news-box {
        max-width: 900px;
        margin: 0 auto;
        padding: 25px;
        background: #ffffff;
        border-radius: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    }

/* ---------- ตัวอักษร ---------- */

    .ir-news-content h1 {
        font-size: 24px;
        font-weight: 600;
        line-height: 1.5;
        margin-bottom: 20px;
        color: #1f2d3d;
        text-align: center;
        word-break: break-word;
    }

    .ir-news-content p {
        font-size: clamp(14px, 2.2vw, 16px);
        color: #333;
        text-align: justify;
        margin-bottom: 16px;
    }

    /* เนื้อข่าวเก่าใช้แท็ก <font> กำหนดขนาดเอง ให้ยึดขนาดกลางแทน */
    .ir-news-content font {
        font-size: 16px;
    }

/* ---------- รูปภาพ ---------- */

    .ir-news-content img {
        max-width: 100%;
        height: auto;
    }

    .ir-news-content .image {
        margin: 25px 0;
        text-align: center;
    }

        .ir-news-content .image img {
            display: block;
            width: 100%;
            max-width: 100%;
            height: auto;
            border-radius: 10px;
        }
body.public-detail {
 background: #f2f2f2 ;      
 }
/* ---------- ตาราง ---------- */

    /* เนื้อข่าวเก่ากำหนดความกว้างตารางเป็น px มาด้วย attribute width
       บังคับไม่ให้ล้นกรอบไม่ว่าจะกำหนดมาแบบไหน */
    .ir-news-content table {
        max-width: 100%;
        border-collapse: collapse;
        white-space: normal !important;
    }

    .ir-news-content td,
    .ir-news-content th {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .ir-news-content pre {
        white-space: pre-wrap;
        word-break: break-word;
    }

/* ---------- จอแท็บเล็ต ---------- */

@media (max-width: 768px) {
    .ir-news-content .news-box {
        width: 100%;
        padding: 20px;
    }
}

/* ---------- จอมือถือ ---------- */

@media (max-width: 767px) {
    /* ตารางที่กว้างเกินจอ ให้เลื่อนดูในกรอบของตัวเอง
       ไม่ให้ไปดันความกว้างของทั้งหน้าจนเนื้อหาล้นออกนอกจอ */
    .ir-news-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .ir-news-content .news-wrapper {
        padding: 10px;
    }

    .ir-news-content .news-box {
        padding: 15px;
        border-radius: 8px;
    }

    .ir-news-content h1 {
        text-align: left;
    }

    .ir-news-content p {
        text-align: left;
    }
}

/* ---------- ปุ่ม Close ที่ ServiceCenter ส่งมา ---------- */

/*
 * ของเดิมเป็น <input type="submit" name="bclose"> วางชิดขอบล่างของเนื้อหา
 * ไม่มีระยะห่างและหน้าตาเป็นปุ่มดีฟอลต์ของเบราว์เซอร์
 * จัดระยะและหน้าตาให้เข้ากับหน้าอื่นของเว็บ ส่วนการทำงานอยู่ใน js/pages/ir-news-content.js
 */
.ir-news-content input[name="bclose"] {
    display: inline-block;
    margin: 40px 0 32px;
    padding: 10px 40px;
    border: 1px solid #1f2d3d;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2d3d;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

    .ir-news-content input[name="bclose"]:hover,
    .ir-news-content input[name="bclose"]:focus {
        background: #1f2d3d;
        color: #ffffff;
    }

@media (max-width: 767px) {
    .ir-news-content input[name="bclose"] {
        margin: 28px 0 24px;
        padding: 10px 32px;
        width: auto;
    }
}
