/* Form layout */
.form-layout {
    --form-field-radius: 0.5rem;
    width: 100%;
}

/* Fix nested row wrappers used in create/edit pages */
.form-layout > .row > .row {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
    margin-inline: 0;
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

.form-layout > .row > .form-actions {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
}

/* Field wrapper */
.form-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.form-field-label {
    display: block;
    width: 100%;
    text-align: start;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #566a7f;
    margin-bottom: 0;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.form-field-required {
    color: var(--bs-danger, #ff3e1d);
    margin-inline-start: 0.2rem;
    font-weight: 700;
}

/* Text inputs & selects */
.form-field .form-control,
.form-field .form-select {
    border-radius: var(--form-field-radius);
    border-color: #d9dee3;
    padding-block: 0.625rem;
    padding-inline: 0.875rem;
    font-size: 0.9375rem;
    background-color: #fff;
    text-align: start;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-field .form-control::placeholder {
    text-align: start;
    color: #b4bdc6;
}

.form-field .form-control:focus,
.form-field .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

.form-field .form-control:hover:not(:focus):not(:disabled):not([readonly]),
.form-field .form-select:hover:not(:focus):not(:disabled) {
    border-color: rgba(var(--bs-primary-rgb), 0.45);
}

.form-field .form-control[readonly],
.form-field .form-control.text-bg-light {
    background-color: #f5f5f9;
    border-color: #e7e7ef;
    color: #697a8d;
}

.form-field .form-control:disabled,
.form-field .form-select:disabled {
    background-color: #f5f5f9;
    opacity: 0.85;
}

.form-field .form-control.is-invalid,
.form-field .form-select.is-invalid,
.form-field .form-control.invalid,
.form-field .form-select.invalid {
    border-color: var(--bs-danger, #ff3e1d);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-danger-rgb, 255, 62, 29), 0.12);
}

.form-field .invalid-feedback {
    font-size: 0.8125rem;
    margin-top: 0.35rem;
}

.form-field .error-message,
.form-field + .error-message {
    display: block;
    font-size: 0.8125rem;
    color: var(--bs-danger, #ff3e1d);
    margin-top: 0.35rem;
}

/* Date / time pickers */
.form-field--picker {
    position: relative;
}

.form-field--picker .abs-cal {
    color: var(--bs-primary);
    opacity: 0.75;
    transition: opacity 0.2s ease;
}

.form-field--picker .form-control:focus ~ .abs-cal,
.form-field--picker:hover .abs-cal {
    opacity: 1;
}

/* Select2 */
.form-field .select2-container .select2-selection--single,
.form-field .select2-container .select2-selection--multiple {
    border-radius: var(--form-field-radius) !important;
    border-color: #d9dee3 !important;
    min-height: calc(2.25rem + 2px) !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.form-field .select2-container--focus .select2-selection--single,
.form-field .select2-container--focus .select2-selection--multiple,
.form-field .select2-container--open .select2-selection--single,
.form-field .select2-container--open .select2-selection--multiple {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15) !important;
}

.form-field .select2-container .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(var(--bs-primary-rgb), 0.12) !important;
    border-color: rgba(var(--bs-primary-rgb), 0.2) !important;
    color: var(--bs-primary) !important;
    border-radius: 0.375rem !important;
}

.form-field .select2-container .select2-selection__rendered {
    text-align: start !important;
    padding-inline: 0.875rem !important;
    width: 100%;
}

.form-field .select2-container .select2-selection--single .select2-selection__rendered {
    padding-inline-end: 2rem !important;
}

.form-field .select2-hidden-accessible {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Switch - system-wide */
.form-check.form-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding-inline: 0 !important;
    margin-bottom: 0;
    min-height: auto;
}

.form-check.form-switch .form-check-input {
    --app-switch-width: 2.875rem;
    --app-switch-height: 1.5rem;
    width: var(--app-switch-width);
    height: var(--app-switch-height);
    margin: 0 !important;
    float: none;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: var(--app-switch-height);
    border: 1px solid #d9dee3;
    background-color: #e8eaee;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 0.15rem center;
    background-size: 1.15rem 1.15rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, background-position 0.2s ease, box-shadow 0.2s ease;
}

.form-check.form-switch .form-check-input:checked {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: right 0.15rem center;
}

[dir="rtl"] .form-check.form-switch .form-check-input {
    background-position: right 0.15rem center;
}

[dir="rtl"] .form-check.form-switch .form-check-input:checked {
    background-position: left 0.15rem center;
}

.form-check.form-switch .form-check-input:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
    border-color: rgba(var(--bs-primary-rgb), 0.55);
}

.form-check.form-switch .form-check-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.form-check.form-switch .form-check-label {
    cursor: pointer;
    color: #566a7f;
    font-weight: 500;
    font-size: 0.9375rem;
    margin-bottom: 0;
}

/* Switch field component */
.form-field--switch {
    margin-bottom: 1.25rem;
}

.form-field--switch .form-field-label {
    margin-bottom: 0;
    cursor: pointer;
}

.form-field--switch .form-switch-row {
    display: flex;
    align-items: center;
    min-height: calc(2.25rem + 2px);
}

/* Textarea */
.form-field textarea.form-control {
    min-height: 6rem;
    resize: vertical;
}

/* File upload */
.form-field--file .attachment-uploader {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem;
    border: 1px dashed rgba(var(--bs-primary-rgb), 0.35);
    border-radius: var(--form-field-radius);
    background-color: rgba(var(--bs-primary-rgb), 0.03);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-field--file .attachment-uploader:hover {
    border-color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.06);
}

/* Form actions */
.form-actions {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(var(--bs-primary-rgb), 0.12);
}

.form-actions .btn-primary {
    background: linear-gradient(135deg, var(--bs-primary) 0%, rgba(var(--bs-primary-rgb), 0.88) 100%);
    border-color: var(--bs-primary);
    box-shadow: 0 2px 8px rgba(var(--bs-primary-rgb), 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.form-actions .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.35);
}

.form-actions .btn-outline-secondary {
    border-color: #d9dee3;
    color: #697a8d;
}

.form-actions .btn-outline-secondary:hover {
    background-color: #f5f5f9;
    border-color: #c9cdd3;
    color: #566a7f;
}

/* Legacy wrappers */
.form-group.relative-parent,
.relative-parent.form-field {
    margin-bottom: 1.25rem;
}

.plate-number-group label,
.license-number-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #566a7f;
    margin-bottom: 0.5rem;
}

.plate-number-group .form-control,
.license-number-group .form-control {
    border-radius: var(--form-field-radius);
}
