/* Template Manager Styles */

.template-manager {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.template-manager-content {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    min-height: 0;
}

/* Sidebar */
.template-sidebar {
    width: 300px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.template-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.template-category {
    margin-bottom: 1.5rem;
}

.category-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.template-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.template-item:hover {
    background: var(--surface);
    border-color: var(--primary);
}

.template-item.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}

.template-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.template-name {
    font-weight: 500;
    color: var(--text);
}

.complexity-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    color: white;
}

.template-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Editor */
.template-editor {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-editor-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.editor-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

/* Tabs */
.editor-tabs {
    display: flex;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tab-button {
    padding: 1rem 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-button:hover {
    color: var(--text);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Form Elements */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--background);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Tag Input */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 42px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.tag-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    font-size: 1.125rem;
    line-height: 1;
}

.tag-input-field {
    flex: 1;
    min-width: 150px;
    border: none;
    outline: none;
    font-size: 0.875rem;
}

/* Pipeline Tab */
.pipeline-stages {
    margin: 1.5rem 0;
}

.pipeline-stage {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.stage-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stage-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.stage-name-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 500;
}

.stage-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Pipeline Flow */
.pipeline-preview {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.pipeline-flow {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
}

.flow-item {
    display: flex;
    align-items: center;
}

.flow-box {
    padding: 0.75rem 1.5rem;
    background: var(--primary-light);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    font-weight: 500;
    white-space: nowrap;
}

.flow-arrow {
    font-size: 1.5rem;
    color: var(--primary);
    margin: 0 0.5rem;
}

/* Parameter Editor */
.parameter-editor {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.parameter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.parameter-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.tier-checkboxes {
    display: flex;
    gap: 1rem;
}

.tier-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.welcome-content {
    max-width: 600px;
    text-align: center;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.template-tips {
    text-align: left;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.template-tips h3 {
    margin-bottom: 1rem;
}

.template-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.template-tips li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.template-tips li::before {
    content: attr(data-emoji);
    position: absolute;
    left: 0;
}

/* Buttons */
.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Messages */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.message-success {
    background: #10b981;
}

.message-error {
    background: #ef4444;
}

.message-info {
    background: #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .template-manager-content {
        flex-direction: column;
    }
    
    .template-sidebar {
        width: 100%;
        height: 200px;
    }
    
    .template-editor {
        min-height: 500px;
    }
}