/* Base Section Styles */
.section {
    padding: var(--spacing-xl) 0;
}

.section.latest-templates {
    padding-top: var(--spacing-md);
}

/* 
   NEW CATEGORY COMPONENT STYLES 
   Replaces the old .category-grid 
*/

.category-row {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin-bottom: 0;
}

.cat-box {
    background: var(--color-bg-white);
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 1.5rem 1rem;
    width: 140px;
    /* Small boxes as requested */
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    z-index: 2;
}

.cat-box .cat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
    /* Default icon color */
    transition: color 0.2s;
}

.cat-box .cat-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text-main);
    transition: color 0.2s;
}

/* Hover & Active States */
.cat-box:hover,
.cat-box.active {
    background-color: var(--color-primary);
    /* Using Primary Dark Blue instead of Red */
    border-color: var(--color-primary);
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.cat-box:hover .cat-icon,
.cat-box.active .cat-icon,
.cat-box:hover .cat-name,
.cat-box.active .cat-name {
    color: var(--color-bg-white);
}

/* The little triangle pointer for active state */
.cat-box.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: var(--color-primary) transparent transparent transparent;
    z-index: 10;
}

/* Subcategories Row */
.subcategory-wrapper {
    text-align: center;
    min-height: 40px;
    /* Prevent jumpiness */
    padding: 10px 0;
}

.subcategory-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
}

.subcategory-row a {
    color: var(--color-text-main);
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s;
}

.subcategory-row a:hover {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
}


/* Template Grid (Shared style, but used on Home too) */
.template-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.template-card {
    background: var(--color-bg-white);
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    box-shadow: var(--shadow-md);
}

.template-image {
    height: 200px;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    overflow: hidden;
}

.template-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-content {
    padding: var(--spacing-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.template-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: var(--spacing-sm);
    background: #f5f5f5;
    color: #d32f2f;
}

.template-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--color-primary);
}

.template-desc {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
    flex-grow: 1;
    /* Pushes button down */
}

/* Responsive adjustments */


@media (max-width: 768px) {
    .stats-grid {
        flex-direction: column;
        gap: 3rem;
    }

    .stats-grid::before {
        display: none;
        /* Hide line on mobile */
    }

    .hero h1 {
        font-size: 2.5rem;
    }
}