/* ── Forms / Schema Manager page ── */
.forms-container {
    min-height: 100vh;
    height: auto;
}

.forms-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.forms-toolbar h2 {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.title-help-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e8f0fe;
    color: #2563eb;
    margin-left: 8px;
    vertical-align: middle;
    transition: background 0.15s;
}

.title-help-link:hover {
    background: #2563eb;
    color: #fff;
}

.title-help-link svg {
    width: 13px;
    height: 13px;
}

.btn-add-schema {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-add-schema:hover {
    background: #1d4ed8;
}

/* ── Schema list ── */
.schemas-list {
    padding: 16px 24px;
}

.schemas-empty {
    color: #999;
    font-size: 0.95em;
    padding: 40px 0;
    text-align: center;
}

.schema-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    transition: border-color 0.15s;
}

.schema-card:hover {
    border-color: #ccc;
}

.schema-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.schema-card-title {
    font-weight: 600;
    font-size: 0.95em;
    color: #1a1a1a;
}

.schema-card-meta {
    font-size: 0.8em;
    color: #999;
}

.schema-card-name {
    font-size: 0.78em;
    color: #6b6b6b;
    background: #f5f5f5;
    padding: 1px 6px;
    border-radius: 3px;
    margin-top: 2px;
    display: inline-block;
}

.schema-card-actions {
    display: flex;
    gap: 6px;
}

.schema-card-actions .btn-action {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: none;
    font-size: 0.82em;
    cursor: pointer;
    color: #555;
    transition: background 0.15s, color 0.15s;
}

.schema-card-actions .btn-action:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

.schema-card-actions .btn-action.delete:hover {
    background: #fbe9e7;
    color: #c62828;
    border-color: #ffcdd2;
}

/* ── Schema editor ── */
.schema-editor {
    margin: 16px 24px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}

.schema-editor h3 {
    margin: 0 0 16px 0;
    font-size: 1.05em;
    font-weight: 700;
    color: #1a1a1a;
}

.schema-editor h4 {
    margin: 0 0 6px 0;
    font-size: 0.9em;
    font-weight: 700;
    color: #333;
}

.editor-section {
    margin-bottom: 20px;
}

.editor-hint {
    font-size: 0.8em;
    color: #999;
    margin-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.form-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 0.82em;
    font-weight: 600;
    color: #555;
}

.form-field input[type="text"],
.form-field select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    background: #fff;
    color: #1a1a1a;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.field-mappings {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-mappings .form-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.field-mappings .form-field label {
    min-width: 110px;
    margin-bottom: 0;
}

.field-mappings .form-field select {
    max-width: 200px;
}

.btn-introspect {
    margin-top: 4px;
    padding: 6px 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    color: #2563eb;
    transition: background 0.15s;
    align-self: flex-start;
}

.btn-introspect:hover {
    background: #e8f0fe;
}

/* ── Field editor rows ── */
.field-editor-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 5px;
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid #eee;
}

.field-drag-handle {
    cursor: grab;
    color: #bbb;
    font-size: 1.2em;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
    padding: 0 2px;
}

.field-drag-handle:hover {
    color: #666;
}

.field-editor-row.dragging {
    opacity: 0.4;
}

.field-editor-row.drag-over {
    border-top: 2px solid #2563eb;
}

.field-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
    flex-shrink: 0;
}

.field-key {
    font-size: 0.78em;
    color: #6b6b6b;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 120px;
    flex-shrink: 0;
}

.field-label-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.85em;
    background: #fff;
    color: #1a1a1a;
}

.field-label-input:focus {
    outline: none;
    border-color: #2563eb;
}

.field-type-select {
    padding: 3px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.82em;
    background: #fff;
    color: #1a1a1a;
    flex-shrink: 0;
    min-width: 80px;
    cursor: pointer;
}

.field-type-select:focus {
    outline: none;
    border-color: #2563eb;
}

.field-type-options {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.field-option-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.78em;
    color: #666;
    cursor: pointer;
    white-space: nowrap;
}

.field-option-cb {
    width: 13px;
    height: 13px;
    accent-color: #2563eb;
}

.field-placeholder-input {
    padding: 2px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 0.78em;
    width: 120px;
    color: #666;
}

.field-placeholder-input:focus {
    outline: none;
    border-color: #2563eb;
}

.field-editable-checkbox {
    width: 14px;
    height: 14px;
    accent-color: #2563eb;
    flex-shrink: 0;
}

.field-editable-label {
    font-size: 0.78em;
    color: #999;
    flex-shrink: 0;
}

/* ── Mode toggle ── */
.editor-mode-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}

.mode-btn {
    padding: 6px 20px;
    border: none;
    background: #fff;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    color: #999;
    transition: background 0.15s, color 0.15s;
}

.mode-btn + .mode-btn {
    border-left: 1px solid #ddd;
}

.mode-btn.active {
    background: #2563eb;
    color: #fff;
}

.mode-btn:hover:not(.active) {
    background: #f5f5f5;
    color: #333;
}

.editor-docs-link {
    font-size: 0.82em;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
    margin-left: 8px;
}

.editor-docs-link:hover {
    text-decoration: underline;
}

/* ── Raw JSON editor ── */
.raw-schema-editor {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    line-height: 1.5;
    background: #fafafa;
    color: #1a1a1a;
    resize: vertical;
    tab-size: 2;
}

.raw-schema-editor:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.raw-error {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.82em;
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* ── Editor actions ── */
.editor-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.btn-cancel {
    padding: 8px 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: none;
    font-size: 0.9em;
    cursor: pointer;
    color: #555;
}

.btn-cancel:hover {
    background: #f5f5f5;
}

.btn-submit {
    padding: 8px 24px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-submit:hover {
    background: #1d4ed8;
}

/* ── Messages ── */
.form-message {
    margin: 12px 24px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
}

.form-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.form-message.error {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.form-message.warning {
    background: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffecb3;
}
