/* --- 1. CƠ BẢN & RESET --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: #f9f9f9;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* --- 2. HEADER FULL (Fix lỗi nhảy dòng trên Mobile) --- */
.site-header {
    background: #fff;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    position: relative;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    position: relative;
    min-height: 40px;
    /* Đảm bảo chiều cao cố định để không bị nhảy */
}

/* Logo & Title cùng hàng */
.logo-wrapper {
    display: flex;
    align-items: center;
    z-index: 5;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #1a1a1a;
}

.custom-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
    display: block;
}

.site-title {
    font-size: 1.3rem;
    font-weight: 800;
    white-space: nowrap;
    line-height: 1;
}

/* Controls */
.header-controls {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Dropdown */
.category-dropdown {
    padding: 8px 30px 8px 15px;
    border-radius: 20px;
    border: 1px solid #eee;
    background: #fdfdfd;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ff4757' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* --- Search Box (Chung) --- */
.search-container {
    display: flex;
    align-items: center;
    background: #f1f1f1;
    border-radius: 25px;
    padding: 2px;
    transition: 0.3s;
    position: relative;
}

.search-container input {
    border: none;
    background: transparent;
    padding: 8px 12px;
    outline: none;
    width: 160px;
    font-size: 0.9rem;
}

/* Nút kính lúp xám (Mặc định ẩn trên PC vì PC hiện luôn thanh search) */
.search-toggle {
    display: none;
    background: #f1f1f1;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #555;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
}

.search-submit {
    background: #ff4757;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 767px) {
    .custom-logo-img {
        height: 26px;
    }

    .site-title {
        font-size: 1.1rem;
    }

    /* 1. Trạng thái bình thường: Ẩn input/submit, HIỆN nút kính lúp xám */
    .search-container {
        background: transparent;
        padding: 0;
    }

    .search-container input,
    .search-submit {
        display: none;
    }

    .search-toggle {
        display: flex;
        /* Hiện nút tròn xám */
        color: #666;
    }

    /* 2. Trạng thái ACTIVE (Khi click vào kính lúp) */
    .search-container.active {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        background: #fff;
        border: 1px solid #ff4757;
        z-index: 1001;
        border-radius: 25px;
        display: flex;
        padding: 0 5px;
    }

    /* Khi active thì ẩn cái nút kính lúp xám đi để hiện input */
    .search-container.active .search-toggle {
        display: none;
    }

    .search-container.active input {
        display: block;
        flex: 1;
        width: 100%;
        padding: 0 15px;
        height: 100%;
        background: transparent;
        font-size: 1rem;
    }

    .search-container.active .search-submit {
        display: block;
        height: calc(100% - 10px);
        margin: auto 5px;
        padding: 0 15px;
    }

    /* Ẩn các thành phần xung quanh để nhường chỗ cho thanh search */
    .search-open .logo-wrapper,
    .search-open .category-select-wrapper {
        opacity: 0;
        visibility: hidden;
        transition: 0.2s;
    }
}







/* --- 3. GRID BÀI VIẾT (TRANG CHỦ) --- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    padding: 30px 0;
}

.post-item {
    background: #ffffff;
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    top: 0;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

.post-item:hover {
    top: -8px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
}

.post-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.post-thumbnail img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    border-bottom: 1px solid #f0f0f0;
    display: block;
}

.post-info-container {
    padding: 20px;
}

.cat,
.cat-label a {
    background: #ff4757 !important;
    /* Đổi sang màu đỏ chủ đạo của bạn */
    color: #fff !important;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: bold;
    font-size: 10px;
    text-decoration: none;
    display: inline-block;
    transition: background 0.3s ease;
}

/* Hiệu ứng khi hover vào category */
.cat:hover,
.cat-label a:hover {
    background: #e04050 !important;
    /* Đỏ đậm hơn một chút khi hover */
    color: #fff !important;
}

.post-title {
    font-size: 1.15rem;
    margin: 8px 0;
    line-height: 1.4;
    font-weight: 700;
    color: #2d3436;
    overflow-wrap: break-word;
    word-break: break-word;
}

.post-excerpt {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* --- 4. PHÂN TRANG (PAGINATION) - ĐÃ KHÔI PHỤC --- */
.pagination-wrapper {
    text-align: center;
    margin: 40px 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.pagination-wrapper .page-numbers {
    display: inline-block;
    padding: 10px 18px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #ddd;
    text-decoration: none;
    font-weight: bold;
    color: #333;
    transition: all 0.3s ease;
}

.pagination-wrapper .page-numbers:hover {
    border-color: #ff4757;
    color: #ff4757;
    background: #fff5f6;
}

.pagination-wrapper .current {
    background: #ff4757 !important;
    color: #fff !important;
    border-color: #ff4757 !important;
    box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3);
}

.pagination-wrapper .prev,
.pagination-wrapper .next {
    font-weight: 800;
}

/* --- 5. SINGLE POST V2 --- */
.single-post-v2 {
    background: #f4f4f4;
    padding-bottom: 60px;
}

.full-featured-image {
    max-width: 1100px;
    margin: 0 auto;
    padding-top: 30px;
}

.full-featured-image img {
    width: 100%;
    height: auto;
    border-radius: 15px 15px 0 0;
    display: block;
}

.content-overlay {
    max-width: 1100px;
    margin: 0 auto;
}

.article-card {
    background: #fff;
    padding: 50px 60px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border-radius: 0 0 15px 15px;
    overflow: hidden;
}

.entry-title {
    font-size: 2.1rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 15px 0;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-word;
}

.post-meta-top {
    margin-bottom: 30px;
    color: #777;
    font-size: 0.85rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.entry-content {
    font-size: 1rem;
    line-height: 1.8;
    color: #333;
    margin-bottom: 50px;
    overflow-wrap: break-word;
    /* Ngắt dòng ở các từ dài */
    word-wrap: break-word;
    /* Hỗ trợ các trình duyệt cũ */
    word-break: break-word;
}

/* --- 6. NEXT PART CTA SLIM (CLICKABLE BLOCK) --- */
.next-part-cta-slim {
    background: #ffffff;
    border: 1px solid #eee;
    border-radius: 15px;
    margin: 40px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

/* Hover cả khối */
.next-part-cta-slim:hover {
    border-color: #ff4757;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 71, 87, 0.1);
}

.cta-full-link {
    text-decoration: none;
    display: block;
    padding: 20px 25px;
}

.cta-slim-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* Label Next Chapter */
.cta-slim-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cta-slim-label {
    font-size: 12px;
    font-weight: 800;
    color: #ff4757;
    text-transform: uppercase;
    border: 1.5px solid #ff4757;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(255, 71, 87, 0.05);
    transition: 0.3s;
}

/* Giả lập nút bấm */
.cta-slim-btn-mock {
    background: #1a1a1a;
    color: #fff;
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* Hiệu ứng khi hover vào khối thì nút đổi màu */
.next-part-cta-slim:hover .cta-slim-btn-mock {
    background: #ff4757;
}

/* --- ANIMATION PULSE --- */
.cta-pulse-ring {
    width: 8px;
    height: 8px;
    background: #ff4757;
    border-radius: 50%;
    position: relative;
}

.cta-pulse-ring::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #ff4757;
    border-radius: 50%;
    animation: cta-pulse 1.5s infinite;
}

@keyframes cta-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

/* --- MOBILE --- */
@media (max-width: 767px) {
    .cta-full-link {
        padding: 20px;
    }

    .cta-slim-inner {
        flex-direction: column;
        gap: 15px;
    }

    .cta-slim-btn-mock {
        width: 100%;
        text-align: center;
    }
}

/* --- KHỐI NEXT CHAPTER MINIMAL --- */
.next-chapter-minimal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 30px auto;
    padding: 20px;
    max-width: 400px;
    /* Làm khối nhỏ lại */
    background: #000;
    /* Mặc định màu đen */
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.next-chapter-minimal .next-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    /* Chữ trắng mờ trên nền đen */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.next-chapter-minimal .btn-continue-reading {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    /* Chữ trắng */
}

/* HIỆU ỨNG HOVER: Chuyển toàn bộ sang màu đỏ */
.next-chapter-minimal:hover {
    background: #ff4757;
    /* Màu đỏ chủ đạo của bạn */
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 71, 87, 0.3);
}

.next-chapter-minimal:hover .next-label {
    color: #fff;
    /* Chữ label sáng lên khi hover */
}

/* Mobile */
@media (max-width: 767px) {
    .next-chapter-minimal {
        margin: 20px 0;
        max-width: 100%;
    }
}




/* --- CẬP NHẬT VIỀN ĐỎ & GLOW CHO FLOATING POPUP --- */
.floating-popup {
    position: fixed;
    bottom: -150px;
    right: 30px;
    width: 320px;
    background: #fff;
    border-radius: 15px;
    z-index: 9999;
    transition: bottom 0.5s ease;

    /* Thêm viền đỏ và hiệu ứng Glow */
    border: 2px solid #ff4757;
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.4);
}

/* Giữ hiệu ứng bay nhưng thêm glow mạnh hơn khi show */
.floating-popup.show {
    bottom: 30px;
    animation: floating-up-down 3s ease-in-out infinite;
}

/* Khi hover thì glow đậm hơn nữa */
.floating-popup:hover {
    animation-play-state: paused;
    box-shadow: 0 0 25px rgba(255, 71, 87, 0.6);
}


/* Hiệu ứng trồi sụt nhẹ nhàng */
@keyframes floating-up-down {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}


/* CSS cho các thành phần bên trong (giữ nguyên cấu trúc bạn đã có) */
.popup-content-link {
    display: flex;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: inherit;
}

.popup-thumb {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
}

.popup-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-text {
    padding-left: 12px;
}

.popup-label {
    font-size: 10px;
    font-weight: 800;
    color: #ff4757;
    text-transform: uppercase;
}

.popup-title {
    margin: 2px 0 0;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
}

/* Nút đóng popup */
.close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

/* Hàng tiêu đề chứa nút tròn */
.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    width: 100%;
}

.popup-title {
    font-size: 0.85rem;
    margin: 0;
    color: #1a1a1a;
    line-height: 1.3;
    font-weight: 700;
    flex: 1;
    /* Để title chiếm hết chỗ trống còn lại */
}

/* Nút tròn màu đen thay thế button cũ */
.arrow-circle {
    width: 30px;
    /* Tăng nhẹ kích thước để dễ nhìn */
    height: 30px;
    background: #1a1a1a;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    /* Căn giữa dọc */
    justify-content: center;
    /* Căn giữa ngang */
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);

    /* Font này giúp ký tự > trông giống icon hơn */
    font-family: "Consolas", "Monaco", monospace;
    font-size: 18px;
    font-weight: bold;

    /* Khử răng cưa cho ký tự */
    -webkit-font-smoothing: antialiased;

    /* Đẩy nhẹ sang phải 1px để bù trừ thị giác (optical alignment) 
       giúp dấu > trông thật sự nằm giữa vòng tròn */
    padding-left: 2px;
}

.popup-content-link:hover .arrow-circle {
    background: #ff4757;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
}

.close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4757;
    color: #fff;
    border: 2px solid #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767px) {
    .floating-popup {
        left: 15px;
        right: 15px;
        width: auto;
    }
}



/* --- 8. FOOTER --- */
.site-footer {
    background: #1a1a1a;
    color: #bdc3c7;
    padding: 60px 0 0;
    margin-top: 80px;
    border-top: 5px solid #ff4757;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr;
    gap: 40px;
    padding-bottom: 50px;
}

.footer-col h3,
.footer-col h4 {
    color: #fff;
    margin-bottom: 20px;
    font-weight: 800;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links a {
    color: #bdc3c7;
    text-decoration: none;
    transition: 0.3s;
}

.footer-links a:hover {
    color: #ff4757;
    padding-left: 5px;
}

.footer-copyright {
    background: #111;
    padding: 25px 0;
    text-align: center;
    font-size: 0.85rem;
    border-top: 1px solid #222;
}

/* --- 9. RESPONSIVE --- */
@media (max-width: 992px) {
    .post-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 767px) {
    .header-flex {
        gap: 10px;
    }

    .site-title {
        font-size: 1.1rem;
    }

    .search-container.active {
        position: absolute;
        right: 0;
        top: 0;
        background: #fff;
        border: 1px solid #ff4757;
        z-index: 100;
        width: 220px;
        border-radius: 20px;
    }

    .search-container.active input {
        width: 120px;
        opacity: 1;
        visibility: visible;
    }

    .article-card {
        padding: 30px 20px;
        overflow: hidden;
    }

    .entry-title {
        font-size: 1.5rem;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .post-grid {
        grid-template-columns: 1fr !important;
    }

    .cta-inner {
        flex-direction: column;
        text-align: center;
    }

    .cta-thumb img {
        width: 100%;
        height: 180px;
    }

    .floating-popup {
        left: 15px;
        right: 15px;
        width: auto;
        bottom: -300px;
    }

    .floating-popup.show {
        bottom: 15px;
    }

    .close-btn {
        top: 5px;
        right: 5px;
    }
}