.catpage-section {
    padding: 50px 0;
}

.catpage-heading {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 40px;
    color: #0097DC;
}

.catpage-layout {
    display: grid;
    grid-template-columns: 8fr 2fr;
    gap: 40px;
}

.catpage-content {
    width: 100%;
}

.catpage-title {
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Giới hạn 2 dòng */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-sec-blog .catpage-sidebar {
    margin-bottom: 25px;
}

.catpage-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.catpage-item {
    display: flex;
    flex-direction: column;
}

.catpage-thumb img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 8px;
}

.catpage-title {
    font-size: 18px;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 0;
}

.catpage-title a {
    color: inherit;
    text-decoration: none;
}

.catpage-excerpt {
    margin-top: 8px;
    color: #555;
    line-height: 1.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Sidebar --- */
.catpage-sidebar {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.catpage-cats li {
    margin-bottom: 0;
}

.catpage-cats h3 {
    font-size: 22px;
    font-weight: 700;
    color: #0097DC;
    margin-bottom: 20px;
    text-align: center;
}

.catpage-catlist {
    list-style: none;
    margin: 0;
    padding: 15px;
}

.catpage-catlist>.cat-item:last-child {
    border-bottom: none;
}

.title-cate {
    text-align: center;
    padding: 10px 0;
    margin-bottom: 0;
    background: #0097DC;
    color: #fff;
}

.cat-item {
    border-bottom: 1px dashed #0097DC;
    padding: 5px 10px;
    background: #fff;
}

.cat-item:hover {
    background-color: #56bceb;
}

.cat-item:hover .cat-header a {
    color: #fff;
}

.cat-item.open:hover {
    background-color: unset;
}

.subcat-list li:hover {
    background-color: #56bceb;
}

.cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-header a {
    color: #333;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    flex-grow: 1;
    transition: color 0.3s ease;
}

.toggle-subcats {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.toggle-subcats .arrow-icon {
    transition: transform 0.3s ease;
}

.cat-item.open .toggle-subcats .arrow-icon {
    transform: rotate(180deg);
}

.subcat-list {
    margin: 8px 0 0 15px;
    display: none;
    animation: fadeIn 0.3s ease forwards;
}

.subcat-list a {
    color: #555;
    text-decoration: none;
    font-size: 15px;
    transition: color 0.3s ease;
}

.subcat-list li:hover a {
    color: #fff;
}

.subcat-list a:hover {
    color: #0097DC;
}

.subcat-list {
    list-style: none;
}

.catpage-cats {
    background: aliceblue;
}

.cat-item.open {
    padding: 0;
}

.cat-item.open .cat-header {
    padding: 5px 15px;
    background: #56bceb;
    border-bottom: 1px dashed #0097DC;
}

.cat-item.open .cat-header .toggle-subcats svg path {
    stroke: #fff;
}

.cat-item.open .cat-header a {
    color: #fff;
}

.cat-item.open .subcat-list {
    margin: 0;
}

.cat-item.open .subcat-list li {
    padding: 5px 25px;
    border-bottom: 1px dashed #0097DC;
}

.cat-item.open .subcat-list li:last-child {
    border-bottom: none;
}

.catpage-loadmore {
    text-align: center;
    margin-top: 40px;
}

#catpage-loadmore-btn {
    border: 1px solid;
    border-radius: 10px;
    color: #fff;
    background: #0097DC;
    padding: 0px 25px;
}

/* Hiệu ứng mở */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .catpage-layout {
        grid-template-columns: 1fr;
    }

    .catpage-sidebar {
        margin-top: 30px;
    }

    .catpage-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .catpage-grid {
        grid-template-columns: 1fr;
    }

    .section-news-blog .catpage-mobile-catlist {
        margin-bottom: 30px;
    }
}

/* --- MENU DANH MỤC MOBILE --- */
.catpage-mobile-menu {
    display: none;
    position: relative; /* tham chiếu cho danh mục con */
    background: #fff;
    z-index: 10;
}

.catpage-mobile-catlist {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 10px 15px;
    list-style: none;
    gap: 15px;
    overflow-x: auto;
    position: relative;
}

.catpage-mobile-catlist {
    overflow-x: visible; /* thay overflow-x: auto nếu cần */
}

.mobile-cat-item {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.mobile-cat-item a {
    text-decoration: none;
    font-size: 15px;
    color: #0097DC;
    font-weight: 600;
    white-space: nowrap;
}

.mobile-cat-item .toggle-mobile-subcats {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    margin-bottom: 0;
}

.mobile-cat-item .arrow-icon {
    transition: transform 0.3s ease;
}

.mobile-cat-item.open .arrow-icon {
    transform: rotate(180deg);
}

/* --- DANH MỤC CON NẰM RIÊNG --- */
.mobile-subcat-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px; /* tối thiểu cho menu con */
    background: #fff;
    flex-wrap: nowrap;
    overflow-x: auto; /* scroll ngang nếu nhiều item */
    gap: 8px;
    padding: 8px 10px;
    z-index: 9999;
    white-space: nowrap; /* giữ các item trên 1 hàng */
    list-style: none;
    margin: 0;
}

.mobile-subcat-list li {
    flex: 0 0 auto;
    margin: 0 5px;
}

.mobile-subcat-list a {
    display: block;
    padding: 5px 14px;
    font-size: 14px;
    color: #0097DC;
    border: 1px solid #0097DC;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.mobile-subcat-list a:hover,
.mobile-subcat-list a.active {
    background: #0097DC;
    color: #fff;
}

/* Mở menu con */
.mobile-cat-item.open .mobile-subcat-list {
    display: flex !important;
    overflow-x: auto;
    width: 290px;
}

/* Chỉ hiển thị trên mobile */
@media (max-width: 768px) {
    .catpage-sidebar {
        display: none;
    }

    .catpage-mobile-menu {
        display: block;
    }

    .catpage-section {
        padding: 0;
        padding-bottom: 30px;
    }
}
