/* form/ — ZDDC generic form renderer.
   Form-specific layout only; theme tokens (--primary, --bg, --text,
   --border, --bg-secondary, --text-muted, --font-mono, --radius) come
   from shared/base.css. Button styles (.btn, .btn-primary,
   .btn-secondary, .btn-sm) likewise inherit from shared. */

.form-main {
    max-width: 800px;
    margin: 1.5rem auto;
    padding: 0 1rem 4rem;
}

.form-status {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.form-status.is-error {
    background: var(--bg-secondary);
    border-color: var(--danger);
    color: var(--danger);
}

.form-status.is-success {
    background: var(--bg-secondary);
    border-color: var(--success);
    color: var(--success);
}

.form-root {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-field__label {
    font-weight: 600;
    font-size: 0.95rem;
}

.form-field__label .required-mark {
    color: var(--danger);
    margin-left: 0.15rem;
}

.form-field__description {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-field__error {
    font-size: 0.85rem;
    color: var(--danger);
    margin-top: 0.15rem;
}

.form-field__help {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.form-field__input,
.form-field__textarea,
.form-field__select {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    width: 100%;
    box-sizing: border-box;
}

.form-field__textarea {
    min-height: 5em;
    resize: vertical;
}

.form-field__input:focus,
.form-field__textarea:focus,
.form-field__select:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

.form-field--invalid .form-field__input,
.form-field--invalid .form-field__textarea,
.form-field--invalid .form-field__select {
    border-color: var(--danger);
}

.form-field__radio-group,
.form-field__checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-field__radio-group label,
.form-field__checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-fieldset__legend {
    font-weight: 600;
    padding: 0 0.4rem;
}

.form-array {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-array__row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    background: var(--bg-secondary);
}

.form-array__row-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-array__row-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-array__add {
    align-self: flex-start;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

/* Standalone welcome — shown when form.html is opened directly (no
   server-injected #form-context). */
.form-welcome {
    max-width: 36rem;
    margin: 2rem auto;
    padding: 1.5rem 1.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.form-welcome h2 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}
.form-welcome h3 {
    margin: 1rem 0 0.35rem;
    font-size: 0.95rem;
}
.form-welcome p { margin-bottom: 0.75rem; line-height: 1.5; }
.form-welcome ol { margin: 0 0 0.75rem 1.25rem; }
.form-welcome li { margin-bottom: 0.35rem; }
.form-welcome code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-secondary);
    padding: 0.05em 0.3em;
    border-radius: 3px;
}
