/* ==========================================================================
   PREMIUM COMMON SIDEBAR STYLES
   ========================================================================== */
.secondary-sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.widget-title {
    font-size: 16px;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid #fcf8f9;
    padding-bottom: 10px;
}

.widget-title i {
    color: #ff527b;
}

/* 1. Sidebar Advertorial Advanced */
.sidebar-adv-widget {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.sidebar-adv-tag {
    position: absolute;
    top: 12px; left: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    z-index: 3;
}

.sidebar-adv-card {
    height: 320px;
    position: relative;
}

.sidebar-adv-media {
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.6s ease;
}

.sidebar-adv-card:hover .sidebar-adv-media {
    transform: scale(1.04);
}

.sidebar-adv-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0; top: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.4) 60%, transparent 100%);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #ffffff;
    z-index: 2;
}

.adv-badge-hot {
    background: #ff527b;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    align-self: flex-start;
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(255, 82, 123, 0.4);
}

.sidebar-adv-overlay h4 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.sidebar-adv-overlay p {
    font-size: 12.5px;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 16px;
}

.btn-adv-sidebar {
    background: #ffffff;
    color: #1e272e;
    font-size: 12.5px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.sidebar-adv-card:hover .btn-adv-sidebar {
    background: #ff527b;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(255, 82, 123, 0.3);
}

/* 2. Popular Threads Widget & Pulsing */
.popular-threads-widget {
    background: #ffffff;
    border: 1px solid #f1f2f6;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
}

.top-threads-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-threads-list li {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 14px;
    border-bottom: 1px dashed #f1f2f6;
}

.top-threads-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.thread-tag-mini {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}
.thread-tag-mini.beauty { background: #fff2f5; color: #ff527b; }
.thread-tag-mini.fashion { background: #f6e8ff; color: #9b59b6; }
.thread-tag-mini.lifestyle { background: #fff5eb; color: #e67e22; }

.top-threads-list li a {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    color: #3f4e5e;
}

.top-threads-list li a:hover {
    color: #ff527b;
}

/* 3. Sponsored Products Review Ranking */
.sponsored-products-widget {
    background: #ffffff;
    border: 1px solid #f1f2f6;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
}

.product-review-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.product-review-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px dashed #fcf8f9;
}

.product-review-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.prod-rank-num {
    font-size: 16px;
    font-weight: 800;
    color: #cbd5e1;
    width: 24px;
    text-align: center;
}

.product-review-card:nth-child(1) .prod-rank-num { color: #ff527b; }
.product-review-card:nth-child(2) .prod-rank-num { color: #ffa502; }

.prod-img {
    width: 55px; height: 55px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #f1f2f6;
}

.prod-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prod-info h5 {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.4;
    color: #2c3e50;
}

.prod-info h5 a:hover {
    color: #ff527b;
}

.prod-score {
    font-size: 11px;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.prod-score i { color: #ffa502; }

.prod-brand-tag {
    font-size: 9.5px;
    font-weight: 700;
    color: #ff527b;
    background: #fff2f5;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   0. โครงสร้างพื้นฐานสำหรับ SEO & Accessibility
   -------------------------------------------------------------------------- */
/* ซ่อนข้อความสำหรับระบบช่วยอ่าน (Screen Reader) แต่ Google Bot ยังมาเก็บคะแนน SEO ได้ปกติ */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* --------------------------------------------------------------------------
   1. โครงสร้างหลักของกล่อง Widget และหัวข้อ
   -------------------------------------------------------------------------- */
.sidebar-widget {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f3f5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-widget:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.sidebar-widget-title {
    font-size: 16px;
    font-weight: 700;
    color: #222222;
    margin: 0 0 18px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #ff4d4d;
    display: inline-block;
    letter-spacing: 0.3px;
}

.sidebar-widget-title .title-icon {
    margin-right: 4px;
    display: inline-block;
}

/* --------------------------------------------------------------------------
   2. คลาสกล่องค้นหา (Search Box Widget)
   -------------------------------------------------------------------------- */
.search-form-flex {
    position: relative;
    display: flex;
}

.search-input {
    width: 100%;
    padding: 14px 45px 14px 16px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    background-color: #f8fafc;
    transition: all 0.25s ease-in-out;
}

.search-input:focus {
    background-color: #ffffff;
    border-color: #ff4d4d;
    box-shadow: 0 0 0 4px rgba(255, 77, 77, 0.1);
}

.search-input::placeholder {
    color: #a0aec0;
}

.search-submit-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #ff4d4d;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s ease;
}

.search-submit-btn:hover {
    transform: scale(1.15);
}

/* --------------------------------------------------------------------------
   3. คลาสกล่องบทความยอดนิยม (Popular Posts Widget)
   -------------------------------------------------------------------------- */
.popular-posts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* สไตล์พื้นฐานแกนหลักของรูปภาพ เพื่อควบคุมไม่ให้รูปภาพบิดเบี้ยว */
.post-item-thumb-img, .affiliate-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* ครอปรูปพอดีสัดส่วนเหมือน background-size: cover ของเดิม */
    object-position: center;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* สไตล์เริ่มต้นเมื่อแสดงผลบนหน้าจอมือถือ (Mobile / Tablet) */
.sidebar-post-item {
    display: flex;
    flex-direction: column; /* มือถือ: จัดรูปภาพไว้ด้านบน ข้อความอยู่ด้านล่าง เพื่อโชว์ภาพเต็มตา */
    gap: 10px;
    text-decoration: none;
    color: inherit;
    padding-bottom: 14px;
    border-bottom: 1px solid #f8f9fa;
}

.post-item-thumb-wrapper {
    width: 100%;
    height: 180px; /* มือถือ: ขยายรูปภาพให้ใหญ่ คล้ายหน้าฟีด สวยงามและกดง่าย */
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.post-item-details {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
}

.post-item-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    color: #333333;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.post-item-date {
    font-size: 11px;
    color: #999999;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Hover Effect */
.sidebar-post-item:hover .post-item-thumb-img {
    transform: scale(1.06);
}

.sidebar-post-item:hover .post-item-title {
    color: #ff4d4d;
}

/* --------------------------------------------------------------------------
   4. คลาสแนะนำสินค้า Affiliate (Affiliate Widget)
   -------------------------------------------------------------------------- */
.sidebar-affiliate-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.sidebar-affiliate-card:hover {
    border-color: #ff4d4d;
}

.affiliate-card-thumb-wrapper {
    width: 100%;
    height: 220px; /* มือถือ: รูปภาพสินค้ากว้างเต็มตา ดึงดูดความสนใจ */
    overflow: hidden;
    background-color: #f8fafc;
}

.sidebar-affiliate-card:hover .affiliate-card-img {
    transform: scale(1.04);
}

.affiliate-card-body {
    padding: 16px;
}

.affiliate-card-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0 0 12px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.affiliate-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.affiliate-card-price {
    font-size: 14px;
    font-weight: 700;
    color: #ff4d4d;
}

.affiliate-card-btn {
    font-size: 11px;
    background: rgba(255, 77, 77, 0.08);
    color: #ff4d4d;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-affiliate-card:hover .affiliate-card-btn {
    background: #ff4d4d;
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   5. คลาสกล่องแท็ก (Trending Tags Widget)
   -------------------------------------------------------------------------- */
.tags-pill-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill-item {
    font-size: 12px;
    color: #555555;
    background: #f8f9fa;
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    border: 1px solid #f1f3f5;
    transition: all 0.2s ease;
}

.tag-pill-item:hover {
    background: #ff4d4d;
    color: #ffffff;
    border-color: #ff4d4d;
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   6. คลาสกล่องโฆษณาเลื่อนตามหน้าจอ (Sticky Advertisement Widget)
   -------------------------------------------------------------------------- */
.sticky-advertisement-container {
    position: -webkit-sticky;
    position: sticky;
    top: 20px; /* ยึดกล่องโฆษณาค้างไว้เมื่อผู้ใช้งานสกรอลหน้าจอลงมาถึง */
    text-align: center;
}

.ad-label-text {
    font-size: 10px;
    color: #bbbbbb;
    display: block;
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 500;
}

.sidebar-sticky-ad-box {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.responsive-ad-img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s ease;
}

.responsive-ad-img:hover {
    opacity: 0.95;
}


/* ==========================================================================
   7. Media Queries - ปรับแต่งเมื่อแสดงบนหน้าจอขนาดใหญ่ (Desktop ความกว้าง >= 992px)
   ========================================================================== */
@media (min-width: 992px) {
    
    /* กล่องบทความยอดนิยมบน Desktop: สลับมาเป็นภาพเล็กอยู่ซ้าย ข้อความอยู่ขวา จะดูสมดุลไม่สับสนกับหน้าหลัก */
    .sidebar-post-item {
        flex-direction: row; 
        align-items: flex-start;
        gap: 14px;
        padding-bottom: 4px;
        border-bottom: none;
    }

    .post-item-thumb-wrapper {
        width: 85px;   /* ย่อขนาดความกว้างของรูปบทความยอดนิยมบนหน้าจอ Desktop */
        height: 64px;  /* ย่อขนาดความสูงลงเพื่อให้เรียงแถวแนวนอนคู่กับชื่อเรื่องได้สวยงาม */
        border-radius: 8px;
        margin-bottom: 0;
    }

    .post-item-details {
        min-height: 64px;
    }

    /* กล่องสินค้า Affiliate บน Desktop: ปรับความสูงรูปภาพให้ลดลงมา เพื่อไม่ให้แย่งความเด่นของบทความหลัก */
    .affiliate-card-thumb-wrapper {
        height: 150px; 
    }
}
