/**
 * Template Builder Styles
 * Version: 1.0.0
 */

.template-builder {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.builder-header h2 {
    margin: 0;
    font-size: 28px;
    background: linear-gradient(135deg, #f0b400 0%, #d38a00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.builder-actions {
    display: flex;
    gap: 10px;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.template-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.template-card:hover {
    box-shadow: 0 5px 20px rgba(240, 180, 0, 0.2);
    transform: translateY(-3px);
}

.template-icon {
    font-size: 48px;
    text-align: center;
    padding: 10px;
}

.template-info h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #333;
}

.template-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.template-meta {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 12px;
    color: #888;
}

.template-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.template-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template-card.marketplace {
    border: 2px solid #f0b400;
}

/* Builder Sections */
.builder-section {
    background: #f7f9fc;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.builder-section h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h4 {
    margin: 0;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #f0b400;
    box-shadow: 0 0 0 3px rgba(240, 180, 0, 0.15);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Fields List */
.fields-list,
.sections-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field-item,
.section-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.field-info,
.section-info {
    flex: 1;
}

.field-info strong,
.section-info strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.field-meta,
.section-meta {
    font-size: 12px;
    color: #888;
}

.section-preview {
    margin-top: 10px;
    padding: 10px;
    background: #f7f9fc;
    border-left: 3px solid #f0b400;
    font-size: 12px;
    color: #666;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 16px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #f0b400;
    font-size: 16px;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-small,
.btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #f0b400 0%, #d38a00 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(240, 180, 0, 0.3);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: #f0f0f0;
    color: #333;
}

.btn-small:hover {
    background: #e0e0e0;
}

.btn-small.btn-primary {
    background: linear-gradient(135deg, #f0b400 0%, #d38a00 100%);
    color: white;
}

.btn-small.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-small.btn-danger,
.btn-danger {
    background: #f56565;
    color: white;
}

.btn-small.btn-danger:hover,
.btn-danger:hover {
    background: #e53e3e;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Marketplace */
.marketplace-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.marketplace-search input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.marketplace-search select {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    min-width: 150px;
}

.marketplace-list {
    max-height: 60vh;
    overflow-y: auto;
}

/* Dark Mode */
[data-theme="dark"] .template-builder {
    color: var(--text-primary);
}

[data-theme="dark"] .builder-header {
    border-color: var(--border-color);
}

[data-theme="dark"] .template-card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .field-item,
[data-theme="dark"] .section-item {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .builder-section {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .template-info h4,
[data-theme="dark"] .field-info strong,
[data-theme="dark"] .section-info strong,
[data-theme="dark"] .modal-header h3,
[data-theme="dark"] .builder-section h4 {
    color: var(--text-primary);
}

[data-theme="dark"] .template-info p,
[data-theme="dark"] .template-meta,
[data-theme="dark"] .field-meta,
[data-theme="dark"] .section-meta {
    color: var(--text-secondary);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .marketplace-search input,
[data-theme="dark"] .marketplace-search select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-light);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-color);
}

[data-theme="dark"] .section-preview {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-small {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .btn-small:hover {
    background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: 1fr;
    }

    .builder-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .builder-actions {
        flex-direction: column;
    }

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

    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    .template-actions {
        flex-direction: column;
    }

    .marketplace-search {
        flex-direction: column;
    }
}
