/*
 * =================================================================
 * File: building-template-gallery.css
 * Purpose: Styles for the building template gallery component
 * Spec Reference: tickets/active/TK-VB3-013-BUILDING-TEMPLATE-GALLERY-UI.md
 *
 * Note: These styles are shared by BuildingCard component across
 *       building-template-gallery.js and auto-populate-modal.js
 *
 * Quality Verification:
 *   Test:   Not Started
 *   Review: Not Started
 *   Spec:   Not Started
 * =================================================================
 */

/* Gallery Container */
.template-gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
}

/* Template Card */
.template-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    border-color: #6366f1;
}

/* Template Icon */
.template-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    line-height: 1;
}

/* Template Name */
.template-name {
    font-size: 0.875rem;
    font-weight: bold;
    margin: 0.25rem 0;
    color: #1f2937;
    min-height: 1.5rem;
    display: flex;
    align-items: center;
    text-align: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin: 0.25rem;
    font-weight: 500;
}

.badge-basic {
    background: #6c757d;
    color: white;
}

.badge-standard {
    background: #0d6efd;
    color: white;
}

.badge-quality {
    background: #198754;
    color: white;
}

.badge-masterwork {
    background: #ffc107;
    color: #000;
}

.badge-type {
    background: #e9ecef;
    color: #495057;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5c636a;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Badge Container */
.badge-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    margin: 0.5rem 0;
}

/* Employee Count */
.employee-count {
    font-size: 0.75rem;
    color: #059669;
    font-weight: 500;
    margin: 0.25rem 0;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

.card-actions .btn {
    flex: 1;
}

/* Modal Base */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    padding: 20px;
}

/* Modal Content */
.modal-content {
    background: white;
    margin: 5% auto;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.modal-header .close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.modal-header .close:hover {
    color: #1f2937;
}

/* Modal Body */
.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* Template Meta */
.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 4px;
}

.template-meta span {
    font-size: 0.875rem;
}

.template-meta strong {
    color: #1f2937;
    margin-right: 0.25rem;
}

/* Template Description */
.template-description {
    margin-bottom: 1.5rem;
}

.template-description h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.template-description p {
    color: #4b5563;
    line-height: 1.6;
}

/* Template Features */
.template-features h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.template-features ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.template-features li {
    padding: 0.375rem 0;
    color: #4b5563;
    line-height: 1.5;
}

/* Filters Section */
.filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filters input,
.filters select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding: 1rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: #4f46e5;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#page-info {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Responsive Design */
@media (max-width: 768px) {
    .template-gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .template-card {
        min-height: 200px;
        padding: 0.75rem;
    }

    .template-icon {
        font-size: 2.5rem;
    }

    .template-name {
        font-size: 0.875rem;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .modal-body {
        max-height: 50vh;
    }

    .template-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .template-gallery-container {
        grid-template-columns: 1fr;
    }

    .pagination {
        flex-direction: column;
        gap: 1rem;
    }

    .pagination button {
        width: 100%;
    }
}

/* Loading State */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}
