/* --- Post Page Custom Styles --- */

:root {
    --accent: #c0392b;
    --text-main: #2c3e50;
    --text-light: #7f8c8d;
    --bg-gray: #f8fafc;
}
/* post_style.css */

/* 1. จัดการ Container หลัก */
.post-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 20px;
    position: relative;
    z-index: 1; /* ต่ำกว่า header.php แน่นอน */
}

/* 2. แก้ปัญหา Breadcrumbs และ Header ไม่ให้ Sticky */
.breadcrumbs, 
.post-header {
    position: relative !important; /* ห้ามเป็น sticky หรือ fixed */
    top: auto !important;
    z-index: 1 !important; /* ต่ำกว่าเมนูหลักเสมอ */
    background: transparent !important;
}

/* 3. จัดสไตล์ Header บทความ (Layout ตามที่คุณต้องการ) */
.post-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.header-top-row {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 25px;
}

.featured-image-side img {
    width: 300px;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 20px;
}

.header-title-side h1 {
    font-size: 2.8rem;
    margin: 0;
    color: #1a1a1a;
    line-height: 1.2;
}

.cat-badges { display: flex; gap: 8px; margin-bottom: 12px; }
.badge-main { background: #1e293b; color: white; padding: 4px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; }
.badge-sub { background: #f1f5f9; color: #475569; padding: 4px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    color: #64748b;
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-top-row { flex-direction: column; align-items: flex-start; }
    .featured-image-side img { width: 100%; aspect-ratio: 16/9; }
}
/* Layout */
.post-container { 
    max-width: 900px; 
    margin: 0 auto; 
    padding: 0 20px; 
}

/* Breadcrumbs */
.breadcrumbs { 
    padding: 30px 0 10px; 
    font-size: 0.85rem; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    color: var(--text-light); 
}
.breadcrumbs a { 
    color: var(--text-main); 
    text-decoration: none; 
    font-weight: 500; 
}
.breadcrumbs a:hover { color: var(--accent); }

/* Post Header Section - ล้าง Sticky ออกให้ขาด */
.post-header { 
    text-align: left; 
    margin-bottom: 40px; 
    position: relative !important; /* บังคับไม่ให้ค้าง */
    top: auto !important;
}

.header-top-row {
    display: flex;
    align-items: center; 
    gap: 30px;
    margin-bottom: 25px;
}

.featured-image-side {
    flex: 0 0 320px;
}

.featured-image-side img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.header-title-side {
    flex: 1;
}

.header-title-side h1 { 
    font-size: clamp(1.8rem, 4vw, 2.8rem); 
    line-height: 1.2; 
    margin: 0; 
    color: #1a1a1a; 
}

/* Meta & Badges */
.header-bottom-row {
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.cat-badges { display: flex; gap: 8px; margin-bottom: 15px; }
.badge-main { background: var(--text-main); color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.75rem; text-transform: uppercase; font-weight: 700; }
.badge-sub { background: #ecf0f1; color: var(--text-main); padding: 4px 12px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }

.post-meta { 
    display: flex; 
    flex-wrap: wrap;
    gap: 20px; 
    font-size: 0.9rem; 
    color: var(--text-light); 
}

/* Content */
.post-content { 
    font-size: 1.15rem; 
    line-height: 1.8; 
    color: #334155; 
}
.post-content p { margin-bottom: 1.5rem; }
.post-content img { 
    max-width: 100%; 
    height: auto; 
    border-radius: 12px; 
    margin: 2rem 0; 
}

/* Tag Container */
.tag-container {
    margin-top: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px 0;
    border-top: 1px dashed #e2e8f0;
}

.tag-badge {
    background: #f1f5f9;
    color: #64748b;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: 0.2s;
}

.tag-badge:hover {
    background: var(--accent);
    color: white;
}

/* Share Section */
.share-container-mini {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 40px;
    padding: 25px;
    background: var(--bg-gray);
    border-radius: 12px;
}

.share-icon-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    text-decoration: none;
    color: #475569;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
}

.share-icon-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
    .header-top-row { flex-direction: column; align-items: flex-start; }
    .featured-image-side { width: 100%; flex: none; }
    .featured-image-side img { aspect-ratio: 16/9; }
    .share-container-mini { flex-direction: column; align-items: flex-start; }
}/* assets/css/post_style.css */

/* บังคับให้ Post Header ไหลไปตามแรงสโครล (Scroll) ไม่มีการค้าง */
.post-header-simple {
    position: relative !important; /* ป้องกันการใช้ sticky */
    top: auto !important;
    z-index: 1; /* ให้อยู่เลเยอร์ต่ำกว่าเมนูหลัก */
    background: transparent;
    padding: 20px 0 40px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.header-top-row {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.featured-image-side {
    flex: 0 0 250px;
}

.featured-image-side img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 12px;
}

.header-title-side {
    flex: 1;
}

.header-title-side h1 {
    font-size: 2.5rem;
    color: #1a1a1a;
    margin: 0 0 15px 0;
    line-height: 1.2;
}

.post-meta-mini {
    color: #64748b;
    font-size: 0.9rem;
    display: flex;
    gap: 15px;
}

/* ป้องกันเมนูหลักทับเนื้อหา (ถ้าใน style.css เมนูหลักเป็น Fixed) */
.post-container {
    padding-top: 20px; /* ระยะห่างจากเมนูหลัก */
}

/* สำหรับมือถือ */
@media (max-width: 768px) {
    .header-top-row {
        flex-direction: column;
    }
    .featured-image-side {
        width: 100%;
    }
}/* --- Related Articles Styling --- */
.related-posts-section {
    background: #f1f5f9; /* สีพื้นหลังอ่อนๆ เพื่อแยกโซน */
    padding: 80px 0;
    width: 100%;
    position: relative;
    z-index: 1; /* ต่ำกว่า Fixed Header แน่นอน */
}

.related-container-wide {
    max-width: 1100px; /* กว้างกว่าเนื้อหาบทความนิดหน่อยเพื่อให้ดูโปร่ง */
    margin: 0 auto;
    padding: 0 20px;
}

.related-header {
    text-align: center;
    margin-bottom: 40px;
}

.related-label {
    color: var(--at-red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
}

.related-title {
    font-size: 2rem;
    color: #1e293b;
    margin-top: 10px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.related-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.1);
}

.related-img-link {
    height: 180px;
    overflow: hidden;
}

.related-img-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-info {
    padding: 20px;
    flex-grow: 1;
}

.related-cat {
    font-size: 0.75rem;
    background: #fef2f2;
    color: var(--at-red);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 12px;
    display: inline-block;
}

.related-info h3 {
    font-size: 1.15rem;
    line-height: 1.4;
    margin: 0;
}

.related-info h3 a {
    text-decoration: none;
    color: #334155;
    transition: color 0.2s;
}

.related-info h3 a:hover {
    color: var(--at-red);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .related-posts-section { padding: 50px 0; }
    .related-grid { grid-template-columns: 1fr; }
}/* --- Related Articles Full Width --- */
.related-posts-full {
    background: #ffffff; /* เปลี่ยนเป็นขาวล้วนให้เข้ากับหน้าเว็บ หรือใช้ #f8fafc ตามชอบ */
    padding: 80px 5%; /* ใช้ % เพื่อให้ขยายตามขนาดจอ */
    border-top: 1px solid #eee;
    width: 100%;
    position: relative;
    z-index: 1;
}

.related-wrapper-fluid {
    width: 100%;
    max-width: 100%; /* เต็มความกว้างหน้าจอ */
}

.related-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    border-left: 5px solid var(--at-red); /* เพิ่มเส้นแดงหน้าหัวข้อให้เด่น */
    padding-left: 20px;
}

.related-label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.related-title-left {
    font-size: 1.8rem;
    margin: 5px 0 0 0;
    color: #1e293b;
}

/* ปุ่มดูทั้งหมด */
.btn-view-all {
    text-decoration: none;
    color: var(--at-red);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 20px;
    border: 1px solid var(--at-red);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.btn-view-all:hover {
    background: var(--at-red);
    color: white;
}

/* Grid แบบ 5 คอลัมน์ */
.related-grid-static {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* แบ่ง 5 ช่องเท่ากัน */
    gap: 20px;
}

.related-card-minimal {
    display: flex;
    flex-direction: column;
}

.related-card-minimal .related-img-link {
    width: 100%;
    aspect-ratio: 16/9; /* บังคับสัดส่วนรูปภาพให้เท่ากันหมด */
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 15px;
}

.related-card-minimal .related-img-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.related-card-minimal:hover img {
    transform: scale(1.08);
}

.related-card-minimal h3 {
    font-size: 1rem;
    line-height: 1.4;
    margin: 0;
}

.related-card-minimal h3 a {
    text-decoration: none;
    color: #334155;
    transition: color 0.2s;
}

.related-card-minimal h3 a:hover {
    color: var(--at-red);
}
/* บล็อกการคลุมดำข้อความและรูปภาพในบทความ */
    .article-content {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }
    
    /* บล็อกการลากรูปภาพ */
.article-content img {
    -webkit-user-drag: none; /* สำหรับ Chrome, Safari, Edge */
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    /* หากยังขึ้น Error ใน VS Code ให้ใช้บรรทัดล่างนี้แทนการล็อก drag โดยตรง */
    pointer-events: none; 
}
/* Responsive: ปรับจำนวนคอลัมน์ตามขนาดจอ */
@media (max-width: 1200px) {
    .related-grid-static { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .related-header-inline { flex-direction: column; align-items: flex-start; gap: 20px; }
    .related-grid-static { grid-template-columns: repeat(2, 1fr); }
    .btn-view-all { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
    .related-grid-static { grid-template-columns: 1fr; }
}
/* ==========================================================================
   🔥 เพิ่มเติม: จัดการระยะห่างรูปภาพในเนื้อหาบทความ ไม่ให้เบียดตัวหนังสือ
   ========================================================================== */

/* 1. ดักจับรูปภาพทั่วไป หรือรูปที่ถูกสั่งจัดกึ่งกลาง (Centered) */
.post-content img,
.article-content img {
    display: block; /* แยกบล็อกออกมา ไม่ให้แชร์บรรทัดเดียวกับข้อความปกติ */
    max-width: 100% !important;
    height: auto !important;
    margin: 30px auto !important; /* เว้นระยะ บน-ล่าง 30px และจัดกึ่งกลางซ้ายขวา */
    pointer-events: none; /* ล็อกการ Drag ตามที่นายตั้งค่าไว้เดิม */
}

/* 2. ดักจับกรณีแอดมินกดสั่งรูปภาพให้ "ชิดซ้าย (Float Left)" */
.post-content img[style*="float: left"],
.article-content img[style*="float: left"] {
    display: inline-block !important; /* ยอมให้ข้อความไหลขึ้นมาโอบล้อมได้ */
    float: left !important;
    margin-top: 10px !important;     /* ขยับหัวรูปลงมาให้ขนานกับบรรทัดแรก */
    margin-right: 25px !important;    /* ถ่างระยะห่างด้านขวา ดันภาษาไทยออกไป 25px */
    margin-bottom: 20px !important;   /* ถ่างระยะห่างด้านล่าง ไม่ให้บรรทัดถัดไปเบียด */
    margin-left: 0 !important;
}

/* 3. ดักจับกรณีแอดมินกดสั่งรูปภาพให้ "ชิดขวา (Float Right)" */
.post-content img[style*="float: right"],
.article-content img[style*="float: right"] {
    display: inline-block !important;
    float: right !important;
    margin-top: 10px !important;
    margin-left: 25px !important;     /* ถ่างระยะห่างด้านซ้าย ดันภาษาไทยออกไป 25px */
    margin-bottom: 20px !important;   /* ถ่างระยะห่างด้านล่าง */
    margin-right: 0 !important;
}

/* 4. เคลียร์ Layout (Clearfix) ป้องกันไม่ให้รูปที่อยู่ท้ายย่อหน้า ไหลทะลุไปทับหัวข้อ (H2, H3) ถัดไป */
.post-content h1, .post-content h2, .post-content h3, 
.post-content h4, .post-content h5, .post-content h6,
.article-content h1, .article-content h2, .article-content h3 {
    clear: both !important; /* บังคับให้หัวข้อสร้างบรรทัดใหม่เสมอ ไม่โดนรูปด้านบนเบียดทับ */
    padding-top: 15px;      /* เพิ่มช่องไฟด้านบนหัวข้อให้ดูโปร่ง สบายตา */
}