.templates-container {
    padding: 30px 0;
}
.templates-category-section {
    margin-bottom: 40px;
}
.templates-category-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
    text-transform: uppercase;
    color: var(--text-main);
    letter-spacing: 0.5px;
}
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.template-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}
.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    border-color: var(--primary);
}
.template-card-preview {
    position: relative;
    padding-top: 75%; /* 4:3 Ratio */
    background: #f8fafc;
    overflow: hidden;
}
.template-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.template-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 50px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* File badge colors based on format */
.badge-canva { background: #7d2ae8; }
.badge-psd { background: #00c8ff; }
.badge-word { background: #1b5ebe; }
.badge-pdf { background: #ef4444; }
.badge-ai { background: #ff9f00; }
.badge-cdr { background: #00a859; }
.badge-zip { background: #6b7280; }

.template-card-body {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.template-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 38px;
}
.template-card-prod {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}
.template-card-prod i {
    margin-right: 4px;
    opacity: 0.7;
}
.template-card-actions {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.btn-template-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--bg-light);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}
.btn-template-download:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-template-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    color: #fff;
    transition: all 0.2s ease;
}
.btn-template-order:hover {
    opacity: 0.95;
    color: #fff;
}

/* Filter container styling */
.templates-filter-container {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 35px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

/* Search Box design */
.filter-search-box {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
}
.filter-search-box .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
    pointer-events: none;
}
.filter-search-box input {
    width: 100%;
    padding: 12px 45px 12px 45px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-light);
    color: var(--text-main);
    transition: all 0.3s ease;
    outline: none;
}
.filter-search-box input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
#clear-search-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}
#clear-search-btn.visible {
    display: flex;
}
#clear-search-btn:hover {
    color: var(--primary);
    background: rgba(0, 0, 0, 0.05);
}

/* Filter Groups and Pills */
.filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.filter-group:last-child {
    margin-bottom: 0;
}
.filter-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    min-width: 100px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-pill {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.02);
}
.filter-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* Dots inside format pills */
.pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-canva { background: #7d2ae8; }
.dot-psd { background: #00c8ff; }
.dot-pdf { background: #ef4444; }
.dot-word { background: #1b5ebe; }
.dot-ai { background: #ff9f00; }
.filter-pill.active .pill-dot {
    background: #fff; /* turn dot white when active */
}

/* List container and loader */
.templates-list-wrapper {
    position: relative;
    min-height: 200px;
}
#templates-wrapper {
    transition: opacity 0.3s ease;
}
#templates-wrapper.loading {
    opacity: 0.4;
    pointer-events: none;
}
.templates-loader {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 30px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid var(--border-color);
}
.templates-loader span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(37, 99, 235, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty Search results design */
.empty-templates-state {
    text-align: center;
    padding: 50px 20px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    margin: 20px 0;
    width: 100%;
}

/* Mobile responsive scroll for categories */
@media (max-width: 768px) {
    .templates-filter-container {
        padding: 15px;
    }
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .filter-pills {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }
    /* Hide scrollbar but allow scrolling */
    .filter-pills::-webkit-scrollbar {
        height: 4px;
    }
    .filter-pills::-webkit-scrollbar-thumb {
        background-color: rgba(0,0,0,0.1);
        border-radius: 10px;
    }
    .filter-pill {
        flex-shrink: 0;
    }
}

/* Dropdown style for multi-downloads */
.template-download-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}
.template-download-dropdown .btn-dropdown-trigger {
    width: 100%;
    cursor: pointer;
}
.download-dropdown-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    min-width: 180px;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.05);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    z-index: 100;
    margin-bottom: 5px;
    padding: 6px 0;
}
.download-dropdown-menu.show {
    display: block;
}
.download-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s ease;
}
.download-dropdown-menu .dropdown-item:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}
.download-dropdown-menu .dropdown-item i {
    width: 16px;
    text-align: center;
}

/* View All Card */
.view-all-card {
    background: linear-gradient(135deg, #ffffff 0%, rgba(37, 99, 235, 0.03) 100%) !important;
    border: 2px dashed rgba(37, 99, 235, 0.4) !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 250px;
}
.view-all-card:hover {
    border-color: var(--primary) !important;
    background: linear-gradient(135deg, #ffffff 0%, rgba(37, 99, 235, 0.08) 100%) !important;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.08) !important;
}
.view-all-card .view-all-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(37, 99, 235, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}
.view-all-card:hover .view-all-icon-wrapper {
    transform: scale(1.1);
    background-color: var(--primary);
    color: #ffffff;
}
