/* =========================================
   1. Page Layout & Base
   ========================================= */
.categories-page {
    padding: 100px 0 60px;
    background: #f8f9fa;
    min-height: 60vh;
}

.container {
    width: 100%;
    max-width: 1450px;
    margin: 0 auto;
}

/* =========================================
   2. Unified Header Card
   ========================================= */
.category-header-card {
    background: #fff;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 30px;
    border-radius: 0px;
}

/* --- Left Side: Title & Info --- */
.header-card-left {
    flex: 1;
    min-width: 250px;
}

.simple-breadcrumb {
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 10px;
}

.simple-breadcrumb a {
    color: #999;
    text-decoration: none;
    transition: color 0.3s;
}

.simple-breadcrumb a:hover {
    color: #3498db;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.category-header-card h1 {
    margin: 0;
    font-size: 2.2rem;
    color: #2c3e50;
    line-height: 1;
}

.count-badge {
    background: #f0f2f5;
    color: #666;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.header-desc {
    color: #666;
    margin: 0;
    max-width: 500px;
    line-height: 1.6;
}

/* --- Right Side: Search & Filters --- */
.header-card-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    max-width: 500px;
}

/* Search Bar */
.header-search {
    position: relative;
    width: 100%;
}

.header-search input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
    background: #fcfcfc;
    box-sizing: border-box; /* Ensures padding doesn't break width */
}

.header-search input:focus {
    border-color: #3498db;
    background: #fff;
    outline: none;
}

.header-search input::placeholder {
    color: #999;
}

.header-search i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 1.1rem;
}

/* Filters Row */
.header-filters {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}

.sort-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-wrapper .label {
    color: #888;
    font-size: 0.9rem;
}

.sort-wrapper select {
    border: 1px solid #e1e8ed;
    padding: 8px 12px;
    border-radius: 6px;
    color: #444;
    cursor: pointer;
    background: #fff;
    outline: none;
}

.sort-wrapper select:focus {
    border-color: #3498db;
}

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 2px;
}

.view-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.view-btn.active {
    background: #3498db;
    color: #fff;
}

.view-btn:hover:not(.active) {
    color: #3498db;
    background: #f0f2f5;
}

/* =========================================
   3. Categories Grid & Cards
   ========================================= */
.categories-container {
    margin-top: 30px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

/* --- Card Styles --- */
.category-card-page {
    position: relative;
    background: #fff;
    border-radius: 0px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.category-card-page:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.category-card-inner {
    position: relative;
    height: 100%;
}

.category-image-link {
    display: block;
    width: 100%;
    height: 250px;
    overflow: hidden;
}

.category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.category-card-page:hover .category-image {
    transform: scale(1.05);
}

.category-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    color: #fff;
    padding: 20px;
    pointer-events: none; /* Let clicks pass through to link if needed */
}

.category-card-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* =========================================
   4. List View Styles
   ========================================= */
.categories-grid.list-view {
    grid-template-columns: 1fr;
    gap: 20px;
}

.categories-grid.list-view .category-card-page {
    display: flex;
    flex-direction: row;
    height: 160px; /* Fixed height for list items */
}

.categories-grid.list-view .category-card-inner {
    display: flex;
    width: 100%;
}

.categories-grid.list-view .category-image-link {
    width: 260px;
    height: 100%;
    flex-shrink: 0;
}

.categories-grid.list-view .category-card-content {
    position: relative;
    background: none;
    color: #2c3e50;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    flex: 1;
}

.categories-grid.list-view .category-card-title {
    font-size: 1.4rem;
    color: #2c3e50;
    text-shadow: none;
}

/* =========================================
   5. States (Empty & Loading)
   ========================================= */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: #999;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #e1e8ed;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #444;
    margin-bottom: 10px;
}

.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   6. Responsive Design
   ========================================= */

/* Tablet (max 992px) */
@media (max-width: 992px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* Mobile Large (max 768px) */
@media (max-width: 768px) {
    /* Header Adjustments */
    .category-header-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        padding: 20px;
    }

    .header-card-right,
    .header-filters,
    .header-search {
        width: 100%;
        max-width: 100%;
    }

    .header-filters {
        justify-content: space-between;
    }

    .sort-wrapper {
        flex: 1;
    }

    .sort-wrapper select {
        width: 100%;
    }

    /* Grid Adjustments */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    /* List View Adjustments for Mobile */
    .categories-grid.list-view .category-card-page {
        height: auto;
        flex-direction: column;
    }

    .categories-grid.list-view .category-card-inner {
        flex-direction: column;
    }

    .categories-grid.list-view .category-image-link {
        width: 100%;
        height: 200px;
    }

    .categories-grid.list-view .category-card-content {
        padding: 15px;
    }

    .categories-grid.list-view .category-card-title {
        font-size: 1.1rem;
    }
}

/* Mobile Small (max 480px) */
@media (max-width: 480px) {
    .categories-page {
        padding: 80px 0 40px;
    }

    .category-header-card h1 {
        font-size: 1.8rem;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .header-filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-toggle {
        width: 100%;
        justify-content: center;
    }

    .view-btn {
        flex: 1;
    }
}
