/**
 * Form controls — text, select, textarea, checkbox, radio (site-wide consistency)
 * Load after style.css / platform.css base rules.
 */

:root {
    --fc-height: 38px;
    --fc-pad-x: 12px;
    --fc-pad-y: 8px;
    --fc-radius: 10px;
    --fc-border: rgba(21, 101, 192, 0.22);
    --fc-bg: #ffffff;
    --fc-bg-muted: #f8fafc;
    --fc-focus-ring: 0 0 0 4px rgba(21, 101, 192, 0.14);
    --fc-font-size: 0.9rem;
    --fc-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23546E7A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ——— Text-like controls (NOT buttons/checkbox/radio/hidden/file) ——— */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]),
select,
textarea {
    box-sizing: border-box;
    font-family: inherit;
    font-size: var(--fc-font-size);
    line-height: 1.45;
    color: var(--dark-text, #0B1D3A);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius);
    background-color: var(--fc-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]),
select {
    min-height: var(--fc-height);
    height: var(--fc-height);
    padding: 0 var(--fc-pad-x);
}

textarea {
    min-height: 100px;
    height: auto;
    padding: var(--fc-pad-y) var(--fc-pad-x);
    resize: vertical;
}

select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: calc(var(--fc-pad-x) + 22px);
    background-image: var(--fc-select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    cursor: pointer;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="image"]):not([type="range"]):not([type="color"]):focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color, #1565C0);
    background-color: var(--fc-bg);
    box-shadow: var(--fc-focus-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--placeholder-text, #94a3b8);
    opacity: 1;
}

/* Full-width in forms / grids (default for block fields) */
.ng-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.ng-form select,
.ng-form textarea,
.admin-body .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.admin-body .form-group select,
.admin-body .form-group textarea,
.admin-body .field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.admin-body .field select,
.admin-body .field textarea,
.form-grid input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-grid select,
.form-grid textarea,
.filters input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.filters select,
.filters textarea {
    width: 100%;
}

/* Admin .form-control — align with unified height */
.admin-body .form-control,
.admin-body input.form-control,
.admin-body select.form-control,
.admin-body textarea.form-control {
    min-height: var(--fc-height);
    height: var(--fc-height);
    padding: 0 var(--fc-pad-x);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius);
    background: var(--fc-bg-muted);
    font-size: var(--fc-font-size);
}

.admin-body textarea.form-control {
    height: auto;
    min-height: 100px;
    padding: var(--fc-pad-y) var(--fc-pad-x);
}

.admin-body select.form-control {
    padding-right: calc(var(--fc-pad-x) + 22px);
    background-image: var(--fc-select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    -webkit-appearance: none;
}

.admin-body .form-control:focus {
    background: var(--fc-bg);
    box-shadow: var(--fc-focus-ring);
}

/* Platform .ng-form */
.ng-form .field { margin-bottom: 16px; }

.ng-form label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
    font-size: 0.84rem;
    color: var(--ng-text, #334155);
}

.ng-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.ng-form select,
.ng-form textarea {
    width: 100%;
}

.ng-form .muted,
.ng-form small.muted {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--ng-muted, #64748b);
    font-weight: 500;
    line-height: 1.4;
}

/* ——— Checkbox & Radio ——— */
input[type="checkbox"],
input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--primary-color, #1565C0);
    cursor: pointer;
    vertical-align: middle;
}

.ng-check,
label.ng-check,
.admin-body label:has(> input[type="checkbox"]),
.admin-body label:has(> input[type="radio"]) {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.45;
    cursor: pointer;
    margin: 10px 0;
    color: var(--dark-text, #0B1D3A);
}

.ng-check input[type="checkbox"],
.ng-check input[type="radio"] {
    margin-top: 3px;
}

.ng-check-row,
.ng-form .ng-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin: 12px 0;
}

.ng-check-row .ng-check {
    margin: 0;
}

/* Module grid checkboxes (billing plans) */
.ng-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 16px;
    margin: 12px 0;
}

.ng-module-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--fc-border);
    background: var(--fc-bg);
    margin: 0;
}

.ng-module-grid label:has(input:checked) {
    border-color: var(--primary-color, #1565C0);
    background: rgba(21, 101, 192, 0.06);
}

.ng-module-grid__group {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ng-muted, #64748b);
    margin-top: 6px;
    padding: 0 2px;
}

/* Inline compact inputs */
.ng-form-inline input[type="text"],
.ng-form-inline input[type="number"],
.ng-form-inline select {
    width: auto;
    min-width: 140px;
    min-height: 36px;
    height: 36px;
}

/* Select2 match unified height */
.select2-container .select2-selection--single {
    height: var(--fc-height) !important;
    min-height: var(--fc-height) !important;
    border: 1px solid var(--fc-border) !important;
    border-radius: var(--fc-radius) !important;
    background: var(--fc-bg-muted) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--fc-height) - 2px) !important;
    padding-left: var(--fc-pad-x) !important;
    color: var(--dark-text, #0B1D3A) !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(var(--fc-height) - 2px) !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--primary-color, #1565C0) !important;
    box-shadow: var(--fc-focus-ring) !important;
}

/* Disabled / readonly */
input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
    opacity: 0.72;
    cursor: not-allowed;
    background-color: var(--fc-bg-muted);
}
