/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.template-category {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.template-category h3 {
    color: #4a5568;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.template-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.template-item {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.template-item:hover {
    background: #edf2f7;
    border-color: #667eea;
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.template-preview {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
}

.template-item h4 {
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.template-item p {
    color: #718096;
    font-size: 0.9rem;
    margin: 0;
}

/* Template Preview Modal */
.template-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.template-preview-modal.active {
    display: flex;
}

.template-preview-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

.template-preview-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-preview-header h3 {
    color: #4a5568;
    margin: 0;
}

.template-preview-body {
    padding: 2rem;
    text-align: center;
}

.template-preview-canvas {
    background: #f7fafc;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.template-preview-description {
    color: #718096;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.template-preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Template Categories */
.template-category.character-cards {
    border-left: 4px solid #48bb78;
}

.template-category.action-cards {
    border-left: 4px solid #ed8936;
}

.template-category.boards {
    border-left: 4px solid #667eea;
}

.template-category.special-cards {
    border-left: 4px solid #9f7aea;
}

/* Template Tags */
.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.template-tag {
    background: #e2e8f0;
    color: #4a5568;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.template-tag.educational {
    background: #bee3f8;
    color: #2b6cb0;
}

.template-tag.gaming {
    background: #fbb6ce;
    color: #97266d;
}

.template-tag.printable {
    background: #c6f6d5;
    color: #276749;
}

/* Template Search */
.template-search {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.template-search-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.template-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.template-filters {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.filter-button {
    padding: 0.5rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-button:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Template Stats */
.template-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
}

.template-count {
    color: #4a5568;
    font-weight: 500;
}

.template-sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-sort select {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #4a5568;
}

/* Responsive Templates */
@media (max-width: 1024px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .template-items {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    .template-preview-modal {
        padding: 1rem;
    }
    
    .template-preview-content {
        max-height: 95vh;
    }
    
    .template-preview-header,
    .template-preview-body {
        padding: 1rem;
    }
    
    .template-preview-canvas {
        min-height: 200px;
        padding: 1rem;
    }
    
    .template-preview-actions {
        flex-direction: column;
    }
    
    .template-filters {
        justify-content: center;
    }
    
    .template-stats {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .template-items {
        grid-template-columns: 1fr;
    }
    
    .template-item {
        padding: 0.75rem;
    }
    
    .template-preview {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}
