/* =================================================================== */
/* === CSS ĐỒNG BỘ CHO BLOG & SEARCH === */
/* =================================================================== */
/* --- Nền tảng (Bắt buộc) --- */
/* Đặt container của ảnh thành relative để Date Box có thể định vị theo nó */
.post-thumbnail {
    position: relative;
}

/* Style chung cho TẤT CẢ các Date Box */
.post-date-box {
    position: absolute; /* Quan trọng nhất: để có thể dùng top/left/right/bottom */
    z-index: 2;
    width: 50px;
    height: 50px;
    background-color: #ffffff;
    color: #1A202C;
    display: flex;
    flex-direction: column-reverse;
    justify-content: center;
    align-items: center;
    text-align: center;
    line-height: 1.1;
    transition: all 0.3s ease;
}

.post-date-box .date-day {
    font-size: 1.5rem;
    font-weight: 600;
}

.post-date-box .date-month {
    font-size: 0.6rem;
    text-transform: uppercase;
    font-weight: 500;
}

/* --- Các Style Lựa chọn --- */

/* Style 1: Dạng Hộp Vuông */
.post-date-box.style-1 {
    border-radius: 6px 0 6px 0; /* Bo góc nhẹ cho hình vuông */
}

/* Style 2: Dạng Hình Tròn */
.post-date-box.style-2 {
    border-radius: 50%; /* Bo 50% để tạo thành hình tròn hoàn hảo */
}

/* --- Container chung --- */
.blog-archive-wrapper,
.search-results-container {
    padding-bottom: 60px;
    margin: 2rem auto;
    max-width: 1200px;
}
.blog-archive-wrapper .col-md-4,
.blog-archive-wrapper .col-md-6,
.blog-archive-wrapper .col-md-12 {
    margin-bottom: 40px;
}

/* --- Nút chuyển đổi giao diện --- */
.layout-switcher {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 0 auto 2rem;
    max-width: 1200px;
}
.layout-switcher .layout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 38px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #d40511;
    font-size: 1.2rem;
}
.layout-switcher .layout-btn:hover {
    border-color: #d40511;
}
.layout-switcher .layout-btn.active {
    background-color: #d40511;
    border-color: #d40511;
    color: #fff;
}

/* --- Style chung cho mỗi thẻ bài viết/kết quả --- */
.blog-post-item,
.search-result-item {
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    height: 100%;
}
.blog-post-item:hover,
.search-result-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* --- Ảnh đại diện --- */
.blog-post-item .post-thumbnail a {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    background-color: #f0f2f5; 
}
.blog-post-item .post-thumbnail,
.search-result-item .post-thumbnail {
    display: block;
    overflow: hidden;
    background-color: #f0f2f5;
    flex-shrink: 0;
}
.blog-post-item .post-thumbnail img,
.search-result-item .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.blog-post-item .post-thumbnail .is-fallback-svg {
    width: 100px;
    height: 100px;
    stroke: #d1d5db;
    fill: none;
    opacity: 0.8;
}
/* CSS cho ảnh logo thay thế */
.post-thumbnail img.is-fallback-logo {
    object-fit: contain;
    padding: 1rem;
}
.blog-post-item:hover .post-thumbnail img,
.search-result-item:hover .post-thumbnail img {
    transform: scale(1.05);
}

/* --- Nội dung bên trong thẻ --- */
.blog-post-item .post-content-wrapper,
.search-result-item .search-result-content-wrapper {
    padding: 24px 30px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.blog-post-item .entry-header,
.search-result-item .entry-header {
    padding: 0;
}

.blog-post-item .entry-title,
.search-result-item .entry-title {
    margin-top: 0;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;   
}
.blog-post-item .entry-title a,
.search-result-item .entry-title a {
    text-decoration: none;
    color: #000000;
}
.blog-post-item .entry-title a:hover,
.search-result-item .entry-title a:hover {
    color: #d40511;
}

/* --- Thông tin meta --- */
.blog-post-item .entry-meta,
.search-result-item .entry-meta {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

/* --- Tóm tắt --- */
.blog-post-item .entry-summary,
.search-result-item .entry-summary {
    color: #555;
    flex-grow: 1;
}

/* --- Nút đọc thêm --- */
.blog-post-item .entry-footer,
.search-result-item .entry-footer {
    margin-top: auto;
    padding: 0;
}
.blog-post-item .read-more-link,
.search-result-item .read-more-link {
    display: inline-block;
    font-weight: 600;
    text-decoration: none;
    color: #d40511;
    background-color: rgba(212, 5, 17, 0.08);
    padding: 10px 20px;
    border-radius: 50px;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.blog-post-item .read-more-link:hover,
.search-result-item .read-more-link:hover {
    background-color: #d40511;
    color: #ffd700;
}

/* ======================================================
   CSS CĂN LỀ CHO TIÊU ĐỀ & TÓM TẮT
   ====================================================== */

/* Căn lề trái (Mặc định) */
.post-content-wrapper.content-align-left {
    text-align: left;
}

/* Căn lề giữa (Center) -> Áp dụng Justify */
.post-content-wrapper.content-align-center .entry-header,
.post-content-wrapper.content-align-center {
    text-align: justify;
}
.post-content-wrapper.content-align-center .entry-summary {
    text-align: justify; /* Căn đều 2 lề cho đoạn tóm tắt */
}

/* Căn lề phải */
.post-content-wrapper.content-align-right {
    text-align: right;
}

/* ======================================================
   CHẾ ĐỘ LIST & GRID VIEW (DESKTOP)
   ====================================================== */

/* --- Dạng Danh sách (List) --- */
/* --- Cấu trúc chính của Item dạng List --- */
.list-view .blog-post-item,
.list-view .search-result-item {
    display: flex;
    flex-direction: row;
    margin-bottom: 30px; 
}

/* --- 1. Khung bao ngoài của Thumbnail --- */
.list-view .post-thumbnail {
    width: 300px;
    flex: 0 0 300px;
    aspect-ratio: 4 / 3;    
    position: relative;
    background-color: #f8f9fa;
    border-radius: 6px 0 0 6px;         
    overflow: hidden;         
    border: 1px solid #eee;   
}

/* --- 2. Thẻ A bao quanh ảnh --- */
.list-view .post-thumbnail a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;   
    justify-content: center; 
    overflow: hidden;
}

/* --- 3. TRƯỜNG HỢP 1: Ảnh đại diện (Featured Image) --- */
/* Mặc định cho tất cả thẻ img trong thumbnail */
.list-view .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;  
    transition: transform 0.3s ease;
}

/* Hiệu ứng hover (tùy chọn) */
.list-view .blog-post-item:hover .post-thumbnail img {
    transform: scale(1.05);
}

/* --- 4. TRƯỜNG HỢP 2: Logo Fallback (Ghi đè style img ở trên) --- */
.list-view .post-thumbnail img.is-fallback-logo {
    width: 100%;
    height: 90%;
    object-fit: contain;
    transform: none !important;
}

/* --- 5. TRƯỜNG HỢP 3: SVG Fallback --- */
.list-view .post-thumbnail svg.is-fallback-svg {
    width: 100px;
    height: 100px;
    stroke: #adb5bd; 
    fill: none;
    transition: stroke 0.3s;
}

/* Hover vào thì icon SVG đậm màu hơn chút */
.list-view .blog-post-item:hover .post-thumbnail svg.is-fallback-svg {
    stroke: #6c757d;
}

/* --- Phần nội dung chữ bên phải --- */
.list-view .entry-content-wrap {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.list-view .entry-footer {
    margin-top: auto;
    text-align: right;
}


/* --- Dạng Lưới (Grid) --- */
.grid-view {
    display: grid;
    gap: 30px; 
}

/* Cấu trúc cột Responsive */
@media (min-width: 992px) {
    .grid-view.grid-three-col { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .grid-view.grid-two-col { grid-template-columns: repeat(2, 1fr); }
}
/* Mobile mặc định 1 cột */
@media (max-width: 767px) {
    .grid-view.grid-three-col,
    .grid-view.grid-two-col { 
        grid-template-columns: 1fr; 
    }
}

/* --- Cấu trúc Card Item --- */
.grid-view .blog-post-item,
.grid-view .search-result-item {
    display: flex;
    flex-direction: column; 
    background-color: #fff;
    border: 1px solid #eee; 
    border-radius: 6px;     
    overflow: hidden;
    height: 100%;           
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* Hiệu ứng hover lên cả card */
.grid-view .blog-post-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

/* --- 1. Khung bao ngoài Thumbnail --- */
.grid-view .post-thumbnail {
    width: 100%;
    aspect-ratio: 4 / 3; /* Tỉ lệ chuẩn cho Grid */
    position: relative;
    background-color: #f8f9fa; /* Màu nền xám nhẹ (cho Logo/SVG) */
    overflow: hidden;
    border-bottom: 1px solid #f0f0f0;
}

/* --- 2. Thẻ A bao quanh ảnh --- */
.grid-view .post-thumbnail a {
    display: flex; /* Dùng flex để căn giữa Logo/SVG */
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* --- 3. TRƯỜNG HỢP 1: Ảnh đại diện (Featured Image) --- */
.grid-view .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover; 
    transition: transform 0.5s ease;
}

/* Zoom ảnh khi hover */
.grid-view .blog-post-item:hover .post-thumbnail img {
    transform: scale(1.05);
}

/* --- 4. TRƯỜNG HỢP 2: Logo Fallback --- */
.grid-view .post-thumbnail img.is-fallback-logo {
    width: 100%; 
    height: 90%;
    object-fit: contain; 
    transform: none !important; 
}

/* --- 5. TRƯỜNG HỢP 3: SVG Fallback --- */
.grid-view .post-thumbnail svg.is-fallback-svg {
    width: 100px;
    height: 100px;
    stroke: #adb5bd;
    fill: none;
    transition: stroke 0.3s;
}

.grid-view .blog-post-item:hover .post-thumbnail svg.is-fallback-svg {
    stroke: #6c757d;
}

/* --- Phần nội dung chữ bên dưới --- */
.grid-view .entry-content-wrap {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.grid-view .entry-title {
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grid-view .entry-summary {
    font-size: 0.95rem;
    line-height: 1.3;
    min-height: 3.9em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grid-view .entry-footer {
    margin-top: auto;
    padding-top: 15px;
}

/* ======================================================
   RESPONSIVE (ĐÃ CẬP NHẬT THEO YÊU CẦU)
   ====================================================== */

/* --- Áp dụng cho màn hình Tablet trở xuống (dưới 992px) --- */
@media (max-width: 991.98px) {
    /* 1. Ẩn các nút chuyển đổi giao diện */
    .layout-switcher {
        display: none;
    }

    /* 2. Bắt buộc TẤT CẢ các layout (cả list và grid) phải hiển thị dạng lưới 1 cột */
    .blog-archive-container,
    .search-results-container {
        display: grid;
        grid-template-columns: 1fr !important; /* Chỉ 1 cột duy nhất */
        gap: 2rem;
    }

    .grid-view.grid-three-col .entry-title {
        min-height: unset;
    }
    .grid-view.grid-two-col .entry-title {
        min-height: unset;
    }

    /* 3. Đảm bảo các item bên trong luôn là dạng cột dọc (ảnh trên, chữ dưới) */
    .blog-post-item,
    .search-result-item {
        flex-direction: column !important; /* Dùng !important để ghi đè lên flex-direction: row của list-view */
    }

    /* 4. Đảm bảo ảnh đại diện luôn rộng 100% */
    .post-thumbnail {
        width: 100% !important; /* Ghi đè lên width: 300px của list-view */
        aspect-ratio: 16/9;
    }

    .list-view .entry-footer {
        text-align: right; /* Căn lề trái lại cho nút "đọc thêm" */
    }
}
