/* Template Library Styles - Agent Library Design Pattern */

/* Main Layout */
.template-library {
    background: #fafafa;
    min-height: 100vh;
    padding: 0;
}

.template-library-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
}

/* Left Sidebar - Filters */
.template-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 2rem 1.5rem;
    overflow-y: auto;
}

.filter-section {
    margin-bottom: 2.5rem;
}

.filter-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    color: #374151;
}

.filter-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.filter-item.active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 500;
}

.filter-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Main Content Area */
.template-main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Header */
.template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.template-library-title {
    font-size: 1.875rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.025em;
    margin: 0;
}

.template-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Search */
.template-search {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

.search-input {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.875rem;
    width: 300px;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* AI Creator Button */
.ai-creator-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.ai-creator-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    color: white;
    text-decoration: none;
}

/* Category Sections */
.template-category-section {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 1.5rem 0;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Template Cards */
.template-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.template-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.template-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.template-favorite {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.template-favorite:hover {
    color: #fbbf24;
    background: #fef3c7;
}

.template-favorite.favorited {
    color: #fbbf24;
}

.template-card-content {
    flex: 1;
}

.template-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

.template-card-description {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .template-library-container {
        max-width: 100%;
    }
    
    .template-sidebar {
        width: 260px;
    }
    
    .template-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 1024px) {
    .template-library-container {
        flex-direction: column;
    }
    
    .template-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding: 1.5rem;
    }
    
    .filter-section {
        margin-bottom: 1.5rem;
    }
    
    .filter-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-item {
        padding: 0.5rem 0.75rem;
        background: #f9fafb;
        border-radius: 6px;
        border: 1px solid #e5e7eb;
    }
    
    .template-main-content {
        padding: 1.5rem;
    }
    
    .template-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .template-header-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-input {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .template-library-container {
        padding: 0;
    }
    
    .template-sidebar {
        padding: 1rem;
    }
    
    .template-main-content {
        padding: 1rem;
    }
    
    .template-library-title {
        font-size: 1.5rem;
    }
    
    .template-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .template-card {
        padding: 1.25rem;
    }
    
    .category-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 640px) {
    .template-header-actions {
        gap: 0.5rem;
    }
    
    .ai-creator-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8rem;
    }
    
    .search-input {
        padding: 0.625rem 1rem 0.625rem 2.25rem;
        font-size: 0.8rem;
    }
    
    .template-card {
        padding: 1rem;
    }
    
    .template-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .template-card-title {
        font-size: 1rem;
    }
    
    .template-card-description {
        font-size: 0.8rem;
    }
}

/* App Type Badge */
.template-app-badge {
    position: absolute;
    top: 12px;
    right: 48px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.template-card-header {
    position: relative;
}

/* App-specific badge colors */
.template-card[data-app="inspections"] .template-app-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.template-card[data-app="forms"] .template-app-badge {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.template-card[data-app="tasks"] .template-app-badge {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

.template-card[data-app="epms"] .template-app-badge {
    background: rgba(234, 179, 8, 0.1);
    color: #ca8a04;
}

.template-card[data-app="surveys"] .template-app-badge {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.template-card[data-app="onboarding"] .template-app-badge {
    background: rgba(236, 72, 153, 0.1);
    color: #db2777;
}

/* Animation for filtered items */
.template-card {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading states and empty states */
.template-grid:empty::after {
    content: "No templates match your current filters.";
    display: block;
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 3rem;
    grid-column: 1 / -1;
}

/* Focus states for accessibility */
.filter-item:focus,
.template-card:focus,
.template-favorite:focus,
.search-input:focus,
.ai-creator-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .template-sidebar,
    .template-header-actions {
        display: none;
    }
    
    .template-library-container {
        flex-direction: column;
    }
    
    .template-main-content {
        padding: 0;
    }
    
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}