/* --------------------------------------------------------------------------
   Proposal Templates Page
   -------------------------------------------------------------------------- */

/* Sections Tab — Orderable List */
.pt-sections-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
}

.pt-sections-list {
    background-color: var(--bg-tile);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.pt-section-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    cursor: grab;
}

.pt-section-row:last-child {
    border-bottom: none;
}

.pt-section-row:hover {
    background-color: rgba(var(--accent-primary-rgb), 0.04);
}

.pt-section-row.dragging {
    opacity: 0.4;
}

.pt-section-row.drag-over {
    border-top: 2px solid var(--accent-primary);
    padding-top: calc(var(--space-sm) - 2px);
}

.pt-section-drag {
    color: var(--text-muted);
    cursor: grab;
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.pt-section-title-col {
    flex: 1;
    min-width: 0;
}

.pt-section-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pt-section-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.pt-section-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.pt-section-badge-fixed {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
}

.pt-section-badge-variable {
    background-color: rgba(var(--accent-primary-rgb), 0.1);
    color: var(--accent-primary);
}

.pt-section-order {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.pt-section-snippets {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 60px;
    flex-shrink: 0;
}

.pt-section-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.pt-section-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* Snippets Tab — Table */
.pt-snippets-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* Snippet Edit Modal */
.pt-snippet-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.pt-snippet-form .form-group-full {
    grid-column: 1 / -1;
}

.pt-snippet-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.pt-snippet-form input,
.pt-snippet-form select,
.pt-snippet-form textarea {
    width: 100%;
    background-color: var(--bg-input, var(--bg-secondary));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.pt-snippet-form input:focus,
.pt-snippet-form select:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.15);
}

.pt-snippet-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: rgba(var(--accent-primary-rgb), 0.05);
    border: 1px solid rgba(var(--accent-primary-rgb), 0.15);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    margin-top: var(--space-xs);
}

/* Fields Panel */
.pt-fields-panel,
.pt-products-panel {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.pt-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.pt-panel-header h6 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.pt-field-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-color);
}

.pt-field-row:last-child {
    border-bottom: none;
}

.pt-field-row input,
.pt-field-row select {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-input, var(--bg-secondary));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.pt-field-row .field-id { flex: 1; min-width: 80px; }
.pt-field-row .field-label { flex: 2; min-width: 100px; }
.pt-field-row .field-type { width: 80px; flex-shrink: 0; }
.pt-field-row .field-default { width: 60px; flex-shrink: 0; }
.pt-field-row .field-placeholder { width: 60px; flex-shrink: 0; }

/* Linked Products */
.pt-product-link {
    padding: var(--space-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    background-color: var(--bg-secondary);
}

.pt-product-link-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.pt-product-link select[multiple] {
    width: 100%;
    font-size: 0.8125rem;
    padding: 0.25rem;
    background-color: var(--bg-input, var(--bg-secondary));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.pt-product-link .qty-field-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
    font-size: 0.8125rem;
}

/* Empty state */
.pt-empty-fields,
.pt-empty-products {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: var(--space-sm) 0;
    text-align: center;
}

/* Section Preview Modal */
.pt-section-preview-modal .pt-preview-info {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-md);
}

.pt-preview-rendered {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.pt-preview-rendered h1,
.pt-preview-rendered h2,
.pt-preview-rendered h3 {
    color: var(--text-primary);
    margin-top: 0;
}

.pt-preview-rendered p {
    margin-bottom: 0.75rem;
}

.pt-preview-rendered ul {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.pt-preview-placeholders {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background-color: rgba(var(--accent-primary-rgb), 0.05);
    border-radius: var(--radius-sm);
}

/* HTML Editor */
.pt-html-editor {
    width: 100%;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: var(--space-sm);
    background-color: var(--bg-input, var(--bg-secondary));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    resize: vertical;
    tab-size: 4;
}

.pt-html-editor:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb), 0.15);
}

.pt-preview-pane-hidden {
    display: none;
}

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

    .pt-sections-toolbar,
    .pt-snippets-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .pt-field-row {
        flex-wrap: wrap;
    }
}
