/* ==========================================
   CATEGORY PAGE - OPTIMIZED VERSION
   - Compact category header
   - Search by name and description/content
   - Sort functionality
   - Full description display
   - Clean layout matching product page
   ========================================== */

.category-page {
    padding: 20px 0 40px;
    background: #f8f9fa;
}

.category-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ==========================================
   CATEGORY HEADER - COMPACT
   ========================================== */
.category-header {
    text-align: center;
    padding: 10px 20px; /* Compact padding - was 60px */
    border-radius: 12px; /* Smaller radius - was 20px */
    margin-bottom: 20px; /* Less space - was 50px */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-header h1 {
    font-size: 28px; /* Smaller - was 42px */
    margin: 0 0 8px 0; /* Compact margin - was 15px */
    font-weight: 700;
}

.category-header p {
    font-size: 14px; /* Smaller - was 18px */
    margin: 0;
}

/* ==========================================
   FILTER SECTION - CỰC MỎNG, TINH TẾ (-50% HEIGHT)
   ========================================== */
/* ==========================================
   FILTER SECTION - RESPONSIVE & CONTAINED
   Elements scale với container, không tràn ra ngoài
   ========================================== */
.category-filter-section {
    background: white;
    padding: 10px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.filter-form {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    width: 100%;
    box-sizing: border-box;
}

.filter-search {
    display: flex;
    gap: 6px;
    min-width: 0;
}

.search-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.3s;
    line-height: 1.4;
    min-width: 0;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: #1e5ba8;
    box-shadow: 0 0 0 2px rgba(30, 91, 168, 0.1);
}

.search-btn {
    padding: 7px 16px;
    background: #1e5ba8;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    box-sizing: border-box;
    flex-shrink: 0;
}

.search-btn:hover {
    background: #164a8a;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(30, 91, 168, 0.3);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    box-sizing: border-box;
}

.filter-group label {
    font-size: 10px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.filter-group select {
    padding: 7px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1.4;
    min-width: 0;
    box-sizing: border-box;
}

.filter-group select:focus {
    outline: none;
    border-color: #1e5ba8;
    box-shadow: 0 0 0 2px rgba(30, 91, 168, 0.1);
}

.clear-filter-btn {
    padding: 7px 14px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.3s;
    line-height: 1.4;
    box-sizing: border-box;
    flex-shrink: 0;
}

.clear-filter-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(220, 53, 69, 0.3);
}

.results-info {
    padding: 6px 0 0;
    border-top: 1px solid #f0f0f0;
}

.results-info p {
    font-size: 11px;
    color: #888;
    margin: 0;
    font-weight: 400;
    line-height: 1.3;
}

/* ==========================================
   PRODUCTS GRID - DESKTOP 4 COLUMNS
   ========================================== */
.category-page .products-grid,
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

/* ==========================================
   PRODUCT CARD
   ========================================== */
.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.product-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* ==========================================
   PRODUCT IMAGE
   ========================================== */
.product-image {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

/* ==========================================
   CATEGORY BADGE - OVERLAY ON IMAGE
   ========================================== */
.product-category-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    backdrop-filter: blur(4px);
}

.out-of-stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 5px 12px;
    background: rgba(220, 53, 69, 0.95);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ==========================================
   PRODUCT INFO - COMPACT SPACING
   ========================================== */
.product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2px;
}

.product-name {
    font-size: 14px;
    margin: 0 0 2px 0;
    line-height: 1.3;
    font-weight: 600;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 36px;
}

.product-description {
    font-size: 12px;
    color: #666;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ==========================================
   PRODUCT META (PRICE & VIEWS)
   ========================================== */
.product-meta {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #eee;
    flex-wrap: nowrap !important;
    gap: 8px;
    background: none !important;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: #1e5ba8;
    white-space: nowrap;
    flex-shrink: 0;
    background: none !important;
    padding: 0 !important;
    border: none !important;
}

.product-price small {
    font-size: 12px;
    font-weight: 400;
}

.product-price.contact {
    font-size: 14px;
    color: #228b22;
}

.product-views {
    font-size: 12px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.product-views i {
    font-size: 12px;
}

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px; /* Reduced - was 80px */
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.empty-state i {
    font-size: 60px; /* Reduced - was 80px */
    color: #ccc;
    margin-bottom: 15px; /* Reduced - was 20px */
}

.empty-state h3 {
    font-size: 22px; /* Reduced - was 28px */
    color: #333;
    margin-bottom: 8px; /* Reduced - was 10px */
}

.empty-state p {
    color: #666;
    margin-bottom: 20px; /* Reduced - was 30px */
    font-size: 14px;
}

.btn-primary {
    display: inline-block;
    padding: 10px 24px;
    background: #1e5ba8;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #164a8a;
    transform: translateY(-2px);
}

/* ==========================================
   OTHER CATEGORIES SECTION
   ========================================== */
.other-categories {
    margin-top: 35px; /* Giảm từ 40px xuống 35px */
}

.section-title {
    text-align: center;
    font-size: 22px; /* Giảm từ 24px xuống 22px */
    color: #1e5ba8;
    margin-bottom: 18px; /* Giảm từ 20px xuống 18px */
    font-weight: 700;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px; /* Giảm từ 20px xuống 15px */
}

.category-card {
    background: white;
    border-radius: 10px; /* Giảm từ 12px xuống 10px */
    padding: 20px 16px; /* Giảm từ 25px 20px xuống 20px 16px (-20%) */
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08); /* Giảm shadow */
    transition: all 0.3s ease;
    display: block;
}

.category-card:hover {
    transform: translateY(-4px); /* Giảm từ -5px xuống -4px */
    box-shadow: 0 5px 14px rgba(0,0,0,0.12); /* Giảm shadow */
}

.category-content h3 {
    font-size: 24px; /* Giảm từ 20px xuống 18px */
    margin-bottom: 6px; /* Giảm từ 8px xuống 6px */
    font-weight: 700;
    line-height: 1.3;
}

.category-content p {
    font-size: 13px; /* Giảm từ 14px xuống 13px */
    margin: 0;
    line-height: 1.4;
}

/* ==========================================
   RESPONSIVE - TABLET (1024px)
   ========================================== */
@media (max-width: 1024px) {
    .category-page .products-grid,
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    .filter-form {
        grid-template-columns: 2fr 1fr auto;
        gap: 8px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px; /* Giảm từ 15px xuống 12px */
    }

    .category-card {
        padding: 18px 15px; /* Giảm từ 22px 18px xuống 18px 15px */
    }
}

/* ==========================================
   RESPONSIVE - MOBILE (768px)
   ========================================== */
@media (max-width: 768px) {
    .category-page {
        padding: 15px 0 30px;
    }

    .category-page .container {
        padding: 0 5px !important; /* Giảm để tận dụng không gian */
        max-width: 100% !important;
    }

    .category-header {
        padding: 25px 15px;
        margin-bottom: 15px;
        border-radius: 10px;
    }

    .category-header h1 {
        font-size: 22px;
    }

    .category-header p {
        font-size: 13px;
    }

    .category-filter-section {
        padding: 6px 8px; /* Giảm từ 10px xuống 6px 8px (-40%) */
        margin-bottom: 10px; /* Giảm từ 12px xuống 10px */
    }

    .filter-form {
        grid-template-columns: 1fr;
        gap: 5px; /* Giảm từ 6px xuống 5px */
    }

    .filter-search {
        grid-column: 1;
    }

    .search-input {
        font-size: 13px;
        padding: 5px 8px; /* Giảm từ 8px 10px xuống 5px 8px (-38%) */
    }

    .search-btn {
        padding: 5px 12px; /* Giảm từ 8px 16px xuống 5px 12px (-38%) */
        font-size: 13px;
    }

    .filter-group label {
        font-size: 9px; /* Giảm từ 10px xuống 9px */
    }

    .filter-group select {
        font-size: 13px;
        padding: 5px 8px; /* Giảm từ 8px 10px xuống 5px 8px (-38%) */
    }

    .results-info p {
        font-size: 10px; /* Giảm từ 11px xuống 10px */
    }

    /* MOBILE: 2 COLUMNS */
    .category-page .products-grid,
    .products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 5px !important; /* Giảm gap để ô to hơn */
        width: 100% !important;
    }

    .product-image {
        height: 165px !important; /* Tăng để nhìn rõ hơn */
    }

    .product-category-badge {
        top: 6px;
        left: 6px;
        padding: 4px 10px;
        font-size: 7px;
        border-radius: 10px;
    }

    .out-of-stock-badge {
        top: 6px;
        right: 6px;
        padding: 4px 10px;
        font-size: 10px;
    }

    .product-info {
        padding: 8px;
        gap: 2px;
    }

    .product-name {
        font-size: 13px;
        line-height: 1.3;
        min-height: 34px;
        margin: 0 0 2px 0;
    }

    .product-description {
        font-size: 11px;
        line-height: 1.4;
        margin: 0 !important;
        padding: 0 !important;
    }

    .product-meta {
        padding-top: 6px;
        flex-wrap: nowrap !important;
        background: none !important;
    }

    .product-price {
        font-size: 14px;
        background: none !important;
        padding: 0 !important;
        border: none !important;
    }

    .product-price small {
        font-size: 10px;
    }

    .product-price.contact {
        font-size: 13px;
    }

    .product-views {
        font-size: 11px;
    }

    .product-views i {
        font-size: 10px;
    }

    .empty-state {
        padding: 40px 15px;
    }

    .empty-state i {
        font-size: 50px;
    }

    .empty-state h3 {
        font-size: 18px;
    }

    .empty-state p {
        font-size: 13px;
    }

    .other-categories {
        margin-top: 25px; /* Giảm từ 30px xuống 25px */
    }

    .section-title {
        font-size: 18px; /* Giảm từ 20px xuống 18px */
        margin-bottom: 12px; /* Giảm từ 15px xuống 12px */
    }

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 10px; /* Giảm từ 12px xuống 10px */
    }

    .category-card {
        padding: 16px 12px; /* Giảm từ 20px 15px xuống 16px 12px */
    }

    .category-content h3 {
        font-size: 16px; /* Giảm từ 18px xuống 16px */
    }

    .category-content p {
        font-size: 12px; /* Giảm từ 13px xuống 12px */
    }
}

/* ==========================================
   RESPONSIVE - SMALL MOBILE (480px)
   ========================================== */
@media (max-width: 480px) {
    .category-page .container {
        padding: 0 4px !important; /* Giảm để tận dụng không gian */
    }

    .category-header {
        padding: 20px 12px;
    }

    .category-header h1 {
        font-size: 20px;
    }

    .category-page .products-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 4px !important; /* Giảm gap để ô to hơn */
    }

    .product-image {
        height: 150px !important; /* Tăng để nhìn rõ hơn */
    }

    .product-info {
        padding: 6px;
        gap: 1px;
    }

    .product-name {
        font-size: 12px;
        min-height: 32px;
        margin: 0 0 1px 0;
    }

    .product-description {
        font-size: 10px;
        margin: 0 !important;
        padding: 0 !important;
    }

    .product-meta {
        padding-top: 4px;
    }

    .product-price {
        font-size: 13px;
    }

    .product-price small {
        font-size: 9px;
    }

    .product-views {
        font-size: 10px;
    }

    .product-views i {
        font-size: 9px;
    }

    .category-card {
        padding: 15px 10px; /* Giảm từ 18px 12px xuống 15px 10px */
    }

    .category-content h3 {
        font-size: 15px; /* Giảm từ 16px xuống 15px */
    }

    .category-content p {
        font-size: 11px; /* Giảm từ 12px xuống 11px */
    }
}

/* ==========================================
   FORCE OVERRIDES
   ========================================== */
.category-page .product-image,
.category-page .product-image img {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.category-page .product-meta {
    flex-wrap: nowrap !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: none !important;
}

.category-page .product-price {
    background: none !important;
    padding: 0 !important;
    border: none !important;
}

.category-page .product-info {
    gap: 2px !important;
}

.category-page .product-name {
    margin: 0 0 2px 0 !important;
}

.category-page .product-description {
    margin: 0 !important;
    padding: 0 !important;
}
/* ==========================================
   FORCE RESPONSIVE IMPROVEMENTS
   ========================================== */
@media (max-width: 768px) {
    .category-filter-section {
        padding: 8px 10px;
    }
    
    .filter-form {
        gap: 6px;
    }
    
    .search-input {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .search-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .filter-group select {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .clear-filter-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* FORCE badge 7px trên mobile */
    .product-category-badge {
        font-size: 7px !important;
    }
}

@media (max-width: 480px) {
    .category-filter-section {
        padding: 6px 8px;
    }
    
    .filter-form {
        gap: 5px;
    }
    
    .search-input {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .search-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .filter-group label {
        font-size: 9px;
    }
    
    .filter-group select {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .clear-filter-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    
    /* FORCE badge 7px trên mobile */
    .product-category-badge {
        font-size: 7px !important;
    }
}