/* Grouped Templates Layout for Contracts Management */

.contracts-management {
    height: calc(100vh - 120px); /* Adjust based on header height */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Keep header and actions fixed */
.contracts-management .section-header {
    flex-shrink: 0;
    background: white;
    z-index: 10;
    padding-bottom: 20px;
}

.contracts-management .section-actions {
    flex-shrink: 0;
    background: white;
    padding: 15px 0;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0;
}

/* Make the templates section scrollable */
.templates-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 20px;
}

.templates-grouped {
    padding: 20px 0;
}

/* Custom scrollbar styling */
.templates-section::-webkit-scrollbar {
    width: 8px;
}

.templates-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.templates-section::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.templates-section::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.template-group {
    margin-bottom: 40px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.template-group-unassigned {
    background: #f0f4f8;
    border: 1px dashed #6c757d;
}

.template-group-unassigned .group-header {
    color: #495057;
}

.template-group-global {
    background: #e8f5e9;
    border: 1px solid #4caf50;
}

.template-group-global .group-header i {
    color: #4caf50;
}

.template-group:last-child {
    margin-bottom: 0;
}

.group-header {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.group-header i {
    color: #007bff;
}

.template-count {
    margin-left: auto;
    font-size: 14px;
    font-weight: normal;
    color: #6c757d;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.template-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.template-card:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    transform: translateY(-2px);
}

.template-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.template-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.template-actions {
    display: flex;
    gap: 5px;
}

.template-info {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
}

.template-description {
    margin: 0 0 10px 0;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
}

.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
}

.template-meta span {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.template-type {
    background: #28a745 !important;
    color: white !important;
}

.template-language {
    background: #17a2b8 !important;
    color: white !important;
}

.template-updated {
    background: #ffc107 !important;
    color: #333 !important;
}

.no-templates {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.no-templates i {
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-templates h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 500;
}

.no-templates p {
    margin: 0;
    font-size: 16px;
}

/* Dark mode support */
.dark-mode .template-group {
    background: #1a1a1a;
}

.dark-mode .group-header {
    color: #e9ecef;
    border-bottom-color: #343a40;
}

.dark-mode .template-card {
    background: #212529;
    border-color: #343a40;
}

.dark-mode .template-card:hover {
    border-color: #0056b3;
}

.dark-mode .template-header h4 {
    color: #e9ecef;
}

.dark-mode .template-info {
    border-top-color: #343a40;
}

.dark-mode .template-description {
    color: #adb5bd;
}

.dark-mode .template-meta span {
    background: #343a40;
    color: #e9ecef;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .template-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .template-actions {
        align-self: flex-start;
    }
}