/* ============================================================
   Shared Forms UI — Clean, modern, consistent input styling
   Applied site-wide (login, register, profile, checkout, etc.)
   UI only — does NOT change WHMCS logic, names, or functionality
   ============================================================ */

:root {
    --fui-radius: 10px;
    --fui-radius-sm: 8px;
    --fui-border: #e5e7eb;
    --fui-border-strong: #111827;
    --fui-bg: #fafafa;
    --fui-bg-focus: #ffffff;
    --fui-text: #111827;
    --fui-text-muted: #6b7280;
    --fui-label: #374151;
    --fui-placeholder: #9ca3af;
    --fui-focus-ring: 0 0 0 3px rgba(17, 24, 39, 0.08);
    --fui-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
    --fui-error: #dc2626;
    --fui-error-bg: #fef2f2;
    --fui-success: #059669;
    --fui-success-bg: #ecfdf5;
    --fui-height: 44px;
}

/* ── Labels ─────────────────────────────────────────── */
.form-group > label:not(.form-check-label):not(.custom-control-label),
.form-group > .control-label,
.form-group > .form-control-label,
label.control-label,
label.form-control-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--fui-label);
    margin-bottom: 0.4rem;
    display: inline-block;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 1.1rem;
}

/* ── Base inputs ────────────────────────────────────── */
.form-control,
select.form-control,
textarea.form-control,
input[type="text"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="number"].form-control,
input[type="tel"].form-control,
input[type="search"].form-control,
input[type="url"].form-control,
input[type="date"].form-control {
    height: var(--fui-height);
    min-height: var(--fui-height);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    color: var(--fui-text);
    background-color: var(--fui-bg);
    border: 1.5px solid var(--fui-border);
    border-radius: var(--fui-radius);
    box-shadow: var(--fui-shadow);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    width: 100%;
    line-height: 1.4;
}

textarea.form-control {
    height: auto;
    min-height: 110px;
    resize: vertical;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    line-height: 1.5;
}

.form-control::placeholder,
input.form-control::placeholder,
textarea.form-control::placeholder {
    color: var(--fui-placeholder);
    opacity: 1;
    font-weight: 400;
}

.form-control:hover:not(:focus):not([readonly]):not([disabled]) {
    border-color: #d1d5db;
}

.form-control:focus {
    border-color: var(--fui-border-strong);
    background-color: var(--fui-bg-focus);
    box-shadow: var(--fui-focus-ring);
    outline: none;
}

.form-control[readonly],
.form-control[disabled],
.form-control:disabled {
    background-color: #f3f4f6;
    color: var(--fui-text-muted);
    opacity: 0.85;
    cursor: not-allowed;
}

/* ── Sizing variants ────────────────────────────────── */
.form-control-sm,
select.form-control-sm,
input.form-control-sm {
    height: 36px;
    min-height: 36px;
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
    border-radius: var(--fui-radius-sm);
}

.form-control-lg,
select.form-control-lg,
input.form-control-lg {
    height: 52px;
    min-height: 52px;
    padding: 0.8rem 1.1rem;
    font-size: 1rem;
    border-radius: 12px;
}

/* ── Select / custom-select with chevron icon ───────── */
select.form-control,
.custom-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3e%3cpath d='M5.25 7.75a.75.75 0 011.06 0L10 11.44l3.69-3.69a.75.75 0 111.06 1.06l-4.22 4.22a.75.75 0 01-1.06 0L5.25 8.81a.75.75 0 010-1.06z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 18px 18px;
    padding-right: 2.4rem;
    cursor: pointer;
}

select.form-control:focus,
.custom-select:focus {
    border-color: var(--fui-border-strong);
    background-color: var(--fui-bg-focus);
    box-shadow: var(--fui-focus-ring);
}

/* ── Input groups (icon prepend / button append) ───── */
.input-group {
    border-radius: var(--fui-radius);
}

.input-group .form-control {
    height: var(--fui-height);
}

.input-group.input-group-merge,
.input-group-merge {
    border: 1.5px solid var(--fui-border);
    border-radius: var(--fui-radius);
    background-color: var(--fui-bg);
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    box-shadow: var(--fui-shadow);
}

.input-group.input-group-merge:focus-within {
    border-color: var(--fui-border-strong);
    background-color: var(--fui-bg-focus);
    box-shadow: var(--fui-focus-ring);
}

.input-group.input-group-merge .form-control,
.input-group.input-group-merge input.form-control {
    border: none;
    background: transparent;
    box-shadow: none;
    height: calc(var(--fui-height) - 3px);
    padding-left: 0.25rem;
}

.input-group.input-group-merge .form-control:focus {
    box-shadow: none;
    background: transparent;
}

.input-group.input-group-merge .input-group-prepend,
.input-group.input-group-merge .input-group-append {
    background: transparent;
    border: none;
}

.input-group.input-group-merge .input-group-text {
    background: transparent;
    border: none;
    color: var(--fui-text-muted);
    min-width: 40px;
    justify-content: center;
    font-size: 0.9rem;
}

.input-group.input-group-merge .input-group-text i,
.input-group.input-group-merge .input-group-text .fa,
.input-group.input-group-merge .input-group-text .fas,
.input-group.input-group-merge .input-group-text .far {
    width: 16px;
    text-align: center;
    display: inline-block;
    line-height: 1;
}

.input-group.input-group-merge .btn,
.input-group.input-group-merge .btn-default,
.input-group.input-group-merge .btn-reveal-pw {
    background: transparent;
    border: none;
    color: var(--fui-text-muted);
    box-shadow: none;
    padding: 0 0.9rem;
}

.input-group.input-group-merge .btn:hover,
.input-group.input-group-merge .btn-default:hover,
.input-group.input-group-merge .btn-reveal-pw:hover {
    background: transparent;
    color: var(--fui-text);
}

/* Standard input-group (non-merge) unification */
.input-group > .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.input-group > .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group-prepend .input-group-text,
.input-group-append .input-group-text {
    background-color: #f3f4f6;
    border: 1.5px solid var(--fui-border);
    color: var(--fui-text-muted);
    font-size: 0.85rem;
    height: var(--fui-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.input-group-prepend .input-group-text {
    border-top-left-radius: var(--fui-radius);
    border-bottom-left-radius: var(--fui-radius);
    border-right: none;
}

.input-group-append .input-group-text {
    border-top-right-radius: var(--fui-radius);
    border-bottom-right-radius: var(--fui-radius);
    border-left: none;
}

/* ── Validation states ─────────────────────────────── */
.form-control.is-invalid,
.form-control.has-error,
.has-error .form-control {
    border-color: var(--fui-error);
    background-color: var(--fui-error-bg);
}

.form-control.is-invalid:focus,
.form-control.has-error:focus,
.has-error .form-control:focus {
    border-color: var(--fui-error);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-control.is-valid {
    border-color: var(--fui-success);
    background-color: var(--fui-success-bg);
}

.form-control.is-valid:focus {
    border-color: var(--fui-success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.invalid-feedback,
.help-block.with-errors {
    font-size: 0.78rem;
    color: var(--fui-error);
    margin-top: 0.35rem;
    display: block;
}

/* ── Checkboxes / radios ───────────────────────────── */
.form-check {
    padding-left: 1.6rem;
    min-height: 1.4rem;
    margin-bottom: 0.35rem;
}

.form-check-input,
input[type="checkbox"].form-check-input,
input[type="radio"].form-check-input {
    width: 16px;
    height: 16px;
    margin-top: 0.2rem;
    margin-left: -1.6rem;
    accent-color: var(--fui-border-strong);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.87rem;
    color: var(--fui-label);
    cursor: pointer;
    line-height: 1.5;
    font-weight: 400;
}

/* Bootstrap 4 custom-control (toggle/checkbox/radio) */
.custom-control {
    padding-left: 1.75rem;
    min-height: 1.4rem;
}

.custom-control-label {
    font-size: 0.87rem;
    color: var(--fui-label);
    cursor: pointer;
    line-height: 1.5;
    padding-top: 0.1rem;
}

.custom-control-label::before {
    width: 18px;
    height: 18px;
    top: 0.15rem;
    left: -1.75rem;
    border: 1.5px solid var(--fui-border);
    background-color: #fff;
    border-radius: 5px;
    box-shadow: none !important;
    transition: all 0.18s ease;
}

.custom-control-label::after {
    width: 18px;
    height: 18px;
    top: 0.15rem;
    left: -1.75rem;
}

.custom-radio .custom-control-label::before {
    border-radius: 50%;
}

.custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: var(--fui-focus-ring) !important;
    border-color: var(--fui-border-strong);
}

.custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--fui-border-strong);
    border-color: var(--fui-border-strong);
}

.custom-control-input:disabled ~ .custom-control-label {
    color: var(--fui-text-muted);
    cursor: not-allowed;
}

/* ── File input ────────────────────────────────────── */
.custom-file,
.custom-file-input,
.custom-file-label {
    height: var(--fui-height);
}

.custom-file-label {
    border: 1.5px solid var(--fui-border);
    border-radius: var(--fui-radius);
    background-color: var(--fui-bg);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    color: var(--fui-text);
    box-shadow: var(--fui-shadow);
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.custom-file-label::after {
    height: calc(var(--fui-height) - 3px);
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    background-color: #f3f4f6;
    border-left: 1.5px solid var(--fui-border);
    color: var(--fui-label);
    font-weight: 500;
    border-top-right-radius: var(--fui-radius);
    border-bottom-right-radius: var(--fui-radius);
}

.custom-file-input:focus ~ .custom-file-label {
    border-color: var(--fui-border-strong);
    box-shadow: var(--fui-focus-ring);
}

/* ── Phone number international input ──────────────── */
.iti {
    width: 100%;
}

.iti .form-control {
    padding-left: 3rem;
}

/* ── Fix form-control inside input-group (must flex, not force 100% width) ── */
.input-group > .form-control {
    width: auto;
    flex: 1 1 0%;
    min-width: 0;
}

/* ── Responsive tweaks ─────────────────────────────── */
@media (max-width: 575.98px) {
    .form-control,
    select.form-control,
    input[type="text"].form-control,
    input[type="email"].form-control,
    input[type="password"].form-control {
        font-size: 0.95rem;
    }
}
