/* Categories Page Styles */

/* Categories Section */
.categories-section {
    padding: 40px 0;
}

.categories-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    align-items: start;
}

/* Categories Main */
.categories-main {
    min-height: 100vh;
}

.categories-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #212427;
    margin: 0;
}

.filter-toggle-btn {
    display: none;
    background: none;
    border: 2px solid #356df1;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-toggle-btn:hover {
    background-color: #356df1;
}

.filter-toggle-btn:hover svg path {
    fill: #ffffff;
}

/* Categories Topbar */
.categories-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 1px solid #e9ecef;
}

.results-count {
    font-size: 14px;
    color: #6c757d;
}

.sort-select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background-color: #ffffff;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    min-width: 180px;
}

.sort-select:focus {
    outline: none;
    border-color: #356df1;
    box-shadow: 0 0 0 2px rgba(53, 109, 241, 0.1);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

/* Category Item */
.categories-grid .category-item {
    background: #f5f7f8;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
    position: relative;
    border: 1px solid #e9ecef;
}

.categories-grid .category-item:hover {
    transform: translateY(-5px);
    border-color: #356df1;
}

.category-tag-wrapper {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.category-tag {
    background-color: #ff971a;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    text-decoration: none;
    line-height: 1.3;
}

.category-image {
    position: relative;
    overflow: hidden;
    height: 200px;
}

.category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
    transition: transform 0.3s ease;
}

.categories-grid .category-item:hover .category-image img {
    transform: scale(1.05);
}



.category-content {
    padding: 25px;
}

.category-title {
    margin: 0 0 15px 0;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
}

.category-title a {
    color: #212427;
    text-decoration: none;
    transition: color 0.3s ease;
}

.category-title a:hover {
    color: #356df1;
}

.category-description {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.course-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.course-count svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.category-popularity {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-popularity svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.category-popularity span {
    color: #495057;
}

/* Popularity Status Colors */
.category-popularity svg[fill="#ffc107"]+span {
    color: #ffc107;
}

.category-popularity svg[fill="#dc3545"]+span {
    color: #dc3545;
}

.category-popularity svg[fill="#28a745"]+span {
    color: #28a745;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid #6c757d;
    border-radius: 50%;
    color: #6c757d;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.page-link:hover,
.page-link.active {
    background-color: #356df1;
    border-color: #356df1;
    color: #ffffff;
}

.page-link.prev,
.page-link.next {
    font-size: 14px;
}

.page-link.prev svg,
.page-link.next svg {
    width: 20px;
    height: 20px;
}

/* Sidebar styles are now unified in products.css */

.filter-section {
    margin-bottom: 30px;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #212427;
    margin: 0 0 16px 0;
}

.category-type-list,
.course-count-list,
.difficulty-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-type-list li,
.course-count-list li,
.difficulty-list li {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-type-list a,
.course-count-list a,
.difficulty-list a {
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
    flex: 1;
}

.category-type-list a:hover,
.course-count-list a:hover,
.difficulty-list a:hover {
    color: #356df1;
}

/* Radio button styles for filter */
.category-type-list label,
.course-count-list label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #495057;
    font-size: 14px;
    transition: color 0.3s ease;
    flex: 1;
}

.category-type-list label:hover,
.course-count-list label:hover {
    color: #356df1;
}

.category-type-list input[type="radio"],
.course-count-list input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: #356df1;
}

.count {
    color: #6c757d;
    font-size: 12px;
    margin-left: 8px;
}

.reset-filters-btn,
.apply-filters-btn {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #ffffff;
    background-color: #356df1;
}

.reset-filters-btn:hover,
.apply-filters-btn:hover {
    background-color: #000000;
    color: #ffffff;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .categories-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .filter-toggle-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .categories-section {
        padding: 20px 0;
    }

    .page-title {
        font-size: 2rem;
    }

    .categories-topbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .category-content {
        padding: 20px;
    }

    .category-image {
        height: 200px;
    }

    .pagination {
        gap: 8px;
    }

    .page-link {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .categories-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .page-title {
        font-size: 1.8rem;
        text-align: center;
    }

    .filter-toggle-btn {
        align-self: center;
    }

    .categories-grid .category-item {
        margin-bottom: 20px;
    }

    .category-image {
        height: 180px;
    }

    .category-content {
        padding: 16px;
    }

    .category-title {
        font-size: 1.1rem;
    }

    .category-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}



/* Loading States */
.categories-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.categories-grid .category-item.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Filter Active States */
.filter-active {
    color: #356df1 !important;
    font-weight: 600 !important;
}

.filter-active::after {
    content: '✓';
    margin-left: 8px;
    color: #356df1;
    font-weight: bold;
}

/* Category Accordion List Styles */
.category-accordion-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
    width: 100%;
}

.category-accordion-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.category-accordion-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-color: #356df1;
}

.category-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    cursor: pointer;
    user-select: none;
}

.category-accordion-header .header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.category-accordion-header .parent-image {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #e9ecef;
}

.category-accordion-header .parent-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-accordion-header .parent-info {
    flex: 1;
    min-width: 0;
}

.category-accordion-header .parent-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.category-accordion-header .parent-title a {
    color: #212427;
    text-decoration: none;
    transition: color 0.2s ease;
}

.category-accordion-header .parent-title a:hover {
    color: #356df1;
}

.category-accordion-header .parent-desc {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-accordion-header .header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.category-accordion-header .product-badge {
    background: #eef3ff;
    color: #356df1;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.category-accordion-header .accordion-toggle {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
    padding: 0;
}

.category-accordion-header:hover .accordion-toggle {
    background: #356df1;
    border-color: #356df1;
    color: #ffffff;
}

.category-accordion-item.active .accordion-toggle {
    background: #356df1;
    border-color: #356df1;
    color: #ffffff;
}

.category-accordion-header .accordion-toggle svg {
    transition: transform 0.3s ease;
}

.category-accordion-item.active .accordion-toggle svg {
    transform: rotate(180deg);
}

/* Subcategories Container */
.category-accordion-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
    opacity: 0;
    visibility: hidden;
}

.category-accordion-item.active .category-accordion-content {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
}

.subcategories-wrapper {
    max-height: 400px;
    overflow-y: auto;
    padding: 20px 25px;
    border-top: 1px solid #f1f3f5;
    background-color: #fafbfc;
}

/* Custom scrollbar for premium look */
.subcategories-wrapper::-webkit-scrollbar {
    width: 6px;
}

.subcategories-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.subcategories-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.subcategories-wrapper::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.node-children-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.category-tree-node {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    transition: all 0.2s ease;
}

.category-tree-node:hover {
    border-color: #356df1;
    box-shadow: 0 2px 8px rgba(53, 109, 241, 0.04);
}

.category-node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    user-select: none;
}

.category-node-header .node-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.category-node-header .node-image {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid #e9ecef;
}

.category-node-header .node-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-node-header .node-info {
    flex: 1;
    min-width: 0;
}

.category-node-header .node-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.category-node-header .node-title a {
    color: #212427;
    text-decoration: none;
    transition: color 0.2s ease;
}

.category-node-header .node-title a:hover {
    color: #356df1;
}

.category-node-header .node-desc {
    color: #868e96;
    font-size: 0.8rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-node-header .node-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.category-node-header .node-count {
    font-size: 0.8rem;
    color: #356df1;
    font-weight: 600;
    white-space: nowrap;
}

.category-node-header .node-toggle {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
    padding: 0;
}

.category-node-header:hover .node-toggle {
    background: #356df1;
    border-color: #356df1;
    color: #ffffff;
}

.category-tree-node.active>.category-node-header .node-toggle {
    background: #356df1;
    border-color: #356df1;
    color: #ffffff;
}

.category-node-header .node-toggle svg {
    transition: transform 0.3s ease;
}

.category-tree-node.active>.category-node-header .node-toggle svg {
    transform: rotate(180deg);
}

/* Collapsible nested content using CSS grid auto transition */
.category-node-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
    opacity: 0;
    visibility: hidden;
}

.category-tree-node.active>.category-node-content {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
}

.category-node-content>.node-children-list {
    overflow: hidden;
    padding: 12px 12px 12px 25px;
    /* Indent nested lists */
    border-top: 1px solid #f1f3f5;
    background-color: #fafbfc;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .category-accordion-header {
        padding: 15px;
    }

    .category-accordion-header .parent-image {
        width: 48px;
        height: 48px;
    }

    .category-accordion-header .parent-title {
        font-size: 1.1rem;
    }

    .category-accordion-header .header-right {
        gap: 10px;
    }

    .category-accordion-header .product-badge {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .category-node-content>.node-children-list {
        padding-left: 15px;
        /* Less indentation on small screens */
    }
}