/* =========================================================
   APPLICATION FORM (/apply-now, "encode" mode)
   Builds on the tokens defined in job-details.css.
========================================================= */

.af-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 36px 0 24px;
}

/* ---------- Intro ---------- */

.af-intro {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #1d4ed8 0%, #1643b8 55%, #172554 100%);
    color: #ffffff;
    box-shadow: 0 14px 32px rgba(22, 67, 184, .22);
}

.af-intro-icon {
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, .14);
    font-size: 1.9rem;
}

.af-intro h2 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -.01em;
}

.af-intro p {
    margin: 0;
    color: rgba(255, 255, 255, .85);
    font-size: .95rem;
}

/* ---------- Job being applied for ---------- */

.af-job {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding: 18px 22px;
    border: 1px solid #fcd9a6;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #fff8ec, #fffdf8);
}

.af-job-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #f89b12, #ff7800);
    color: #ffffff;
    font-size: 1.3rem;
}

.af-job-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.af-job-copy small {
    color: #8a5a12;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.af-job-copy strong {
    color: var(--navy);
    font-size: 1.1rem;
    font-weight: 800;
}

.af-job-copy span {
    color: var(--muted);
    font-size: .85rem;
}

.af-job-copy span i {
    margin-right: 4px;
    color: var(--orange);
}

.af-job-link {
    flex: 0 0 auto;
    color: var(--blue);
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
}

.af-job-link i {
    margin-right: 6px;
}

.af-job-link:hover {
    text-decoration: underline;
}

/* ---------- Form shell ---------- */

.af-note {
    margin: 22px 4px 14px;
    color: var(--muted);
    font-size: .85rem;
}

.af-req {
    color: var(--red);
    font-weight: 700;
}

.af-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.af-card {
    min-width: 0;
    margin: 0;
    padding: 26px 30px 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.af-card-title {
    float: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border-soft);
    color: #173c9c;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.af-card-title i {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #edf0ff, #f1f3fb);
    color: var(--blue);
    font-size: 1rem;
}

.af-subhead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 28px 0 16px;
    padding-top: 22px;
    border-top: 1px dashed var(--border);
}

.af-subhead h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: #173c9c;
    font-size: .9rem;
    font-weight: 800;
    text-transform: uppercase;
}

.af-subhead .form-check-label {
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
}

/* ---------- Fields ---------- */

.af-label {
    display: block;
    margin-bottom: 6px;
    color: #263b73;
    font-size: .8rem;
    font-weight: 700;
}

.af-form .form-control,
.af-form .form-select {
    min-height: 44px;
    border-color: #cbd5e5;
    border-radius: var(--radius-sm);
    color: var(--navy);
    font-size: .9rem;
    box-shadow: none;
}

.af-form textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.af-form .form-control::placeholder {
    color: #8a96b0;
}

.af-form .form-control:focus,
.af-form .form-select:focus {
    border-color: #4366cb;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12);
}

.af-form .input-group-text {
    border-color: #cbd5e5;
    background: #f3f6fb;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
}

.af-form .af-currency {
    max-width: 130px;
    flex: 0 0 130px;
}

.af-form .form-control.is-invalid,
.af-form .form-select.is-invalid,
.af-form .af-group-invalid .input-group-text {
    border-color: var(--red);
}

.af-form .form-control.is-invalid:focus,
.af-form .form-select.is-invalid:focus {
    box-shadow: 0 0 0 .2rem rgba(239, 68, 68, .14);
}

.af-form .form-control.is-valid,
.af-form .form-select.is-valid {
    border-color: #3aa76d;
}

.af-form .form-control.is-valid:focus,
.af-form .form-select.is-valid:focus {
    box-shadow: 0 0 0 .2rem rgba(21, 153, 87, .12);
}

.af-segmented.af-group-invalid {
    border-color: var(--red);
}

.af-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    color: #c42929;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.35;
}

/* ---------- Restored draft notice ---------- */

.af-draft {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 18px;
    border: 1px solid #bfd3fb;
    border-radius: var(--radius-md);
    background: #eef4ff;
    color: #1e3a8a;
    font-size: .85rem;
    font-weight: 600;
}

.af-draft i {
    font-size: 1.1rem;
}

.af-draft span {
    flex: 1;
}

.af-draft-clear {
    flex: 0 0 auto;
    padding: 6px 14px;
    border: 1px solid #bfd3fb;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--blue);
    font-size: .8rem;
    font-weight: 700;
}

.af-draft-clear:hover {
    background: #f5f8ff;
}

/* ---------- SweetAlert error list ---------- */

.af-swal-list {
    margin: 0;
    padding-left: 1.1rem;
    text-align: left;
    font-size: .9rem;
    line-height: 1.6;
}

/* ---------- Gender segmented control ---------- */

.af-segmented {
    display: flex;
    min-height: 44px;
    padding: 4px;
    gap: 4px;
    border: 1px solid #cbd5e5;
    border-radius: var(--radius-sm);
    background: #f3f6fb;
}

.af-segmented label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 6px;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.af-segmented .btn-check:checked + label {
    background: #ffffff;
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(23, 37, 84, .12);
}

.af-segmented .btn-check:focus-visible + label {
    outline: 2px solid var(--blue-light);
    outline-offset: 1px;
}

/* ---------- Resume picker ---------- */

.af-file {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    margin: 0;
    padding: 22px 24px;
    border: 1.5px dashed #49956a;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(241, 249, 244, .9), rgba(255, 255, 255, .95));
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.af-file:hover,
.af-file.is-dragover {
    border-color: #1b8a49;
    background: #f4fbf6;
}

.af-file > i {
    color: #18733b;
    font-size: 2.2rem;
}

.af-file > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.af-file strong {
    overflow: hidden;
    color: #28303e;
    font-size: .92rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.af-file small {
    color: #435174;
    font-size: .78rem;
}

.af-file.is-invalid {
    border-color: var(--red);
    background: #fff6f6;
}

.af-file.has-file {
    border-style: solid;
    background: #effaf3;
}

.af-file-clear {
    margin-left: auto;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    color: #8a2a2a;
    box-shadow: 0 1px 4px rgba(23, 37, 84, .14);
}

.af-file-clear:hover {
    background: #fdecec;
}

/* ---------- Consent + actions ---------- */

.af-submit {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 10px 30px rgba(23, 37, 84, .12);
    backdrop-filter: blur(6px);
}

.af-consent {
    flex: 1 1 420px;
    margin: 0;
}

.af-consent .form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: .15em;
    cursor: pointer;
}

.af-consent .form-check-label {
    color: #31416c;
    font-size: .88rem;
    line-height: 1.5;
    cursor: pointer;
}

.af-consent a {
    color: var(--blue);
    font-weight: 700;
}

.af-actions {
    display: flex;
    gap: 10px;
}

.af-btn {
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 22px;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.af-btn-primary {
    background: linear-gradient(135deg, #f89b12, #ff7800);
    color: #ffffff;
}

.af-btn-primary:hover:not(:disabled) {
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(255, 120, 0, .25);
}

.af-btn-primary:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.af-btn-primary.is-loading {
    opacity: .75;
    pointer-events: none;
}

.af-btn-ghost {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--muted);
}

.af-btn-ghost:hover {
    background: #f3f6fb;
    color: var(--navy);
}

/* ---------- Privacy modal ---------- */

.af-privacy-modal .modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.af-privacy-modal .modal-header {
    background: linear-gradient(135deg, #1d4ed8, #172554);
    color: #ffffff;
}

.af-privacy-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.af-privacy-modal .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}

.af-privacy-body {
    padding: 26px 30px;
    color: #31416c;
    font-size: .9rem;
    line-height: 1.65;
}

.af-privacy-body h4 {
    margin: 20px 0 8px;
    color: #173c9c;
    font-size: .95rem;
    font-weight: 800;
}

.af-privacy-body h4:first-child {
    margin-top: 0;
}

.af-privacy-body img {
    max-width: 100%;
    height: auto;
}

/* ---------- Small screens ---------- */

@media (max-width: 767.98px) {
    .af-page {
        padding-top: 20px;
    }

    .af-intro {
        padding: 22px;
    }

    .af-intro-icon {
        display: none;
    }

    .af-job {
        flex-wrap: wrap;
    }

    .af-job-link {
        width: 100%;
    }

    .af-card {
        padding: 20px 18px 22px;
    }

    .af-submit {
        position: static;
        padding: 18px;
    }

    .af-actions {
        width: 100%;
    }

    .af-actions .af-btn {
        flex: 1;
        padding: 0 14px;
    }

    .af-prefix {
        display: none;
    }
}

/* The consent error sits in the flex submit bar; give it its own row under the checkbox. */
.af-submit > .af-error {
    flex: 0 0 100%;
    order: 1;
    margin-top: -8px;
    padding-left: 1.6em;
}

.af-submit > .af-actions {
    order: 2;
}

/* ---------- Height / weight converter ---------- */

.af-form .af-convert-btn {
    border: 1px solid #cbd5e5;
    border-left: 0;
    background: #eef2ff;
    color: var(--blue);
}

.af-form .af-convert-btn:hover,
.af-form .af-convert-btn:focus-visible {
    background: #e0e7ff;
    color: var(--blue-dark);
}

.af-converter .modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.af-converter .modal-header {
    background: linear-gradient(135deg, #1d4ed8, #172554);
    color: #ffffff;
}

.af-converter .modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 800;
}

.af-converter .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}

.af-converter .form-control {
    min-height: 44px;
}

.af-converter .form-control.is-invalid {
    border-color: var(--red);
}

.af-conv-result {
    margin-top: 16px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: #f3f6fb;
    color: var(--navy);
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
}

.af-conv-error {
    min-height: 1.2em;
    margin-top: 8px;
    color: #c42929;
    font-size: .8rem;
    font-weight: 600;
}

.af-converter .modal-footer .af-btn {
    height: 42px;
    padding: 0 16px;
    font-size: .85rem;
}

/* ---------- Job description editor ---------- */

.af-editor {
    border: 1px solid #cbd5e5;
    border-radius: var(--radius-sm);
    background: #ffffff;
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.af-editor.is-focused {
    border-color: #4366cb;
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12);
}

.af-editor.af-group-invalid {
    border-color: var(--red);
}

.af-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-soft);
    background: #f7f9fc;
}

.af-editor-toolbar[hidden] {
    display: none;
}

.af-tool {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #31416c;
    font-size: 1.05rem;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.af-tool:hover {
    background: #e8edf7;
    color: var(--navy);
}

.af-tool:focus-visible {
    outline: 2px solid var(--blue-light);
    outline-offset: 1px;
}

/* wysihtml marks the command that applies at the cursor. */
.af-tool.wysihtml5-command-active {
    background: #dbe4ff;
    color: var(--blue);
}

.af-tool.wysihtml5-command-disabled {
    opacity: .4;
    pointer-events: none;
}

.af-tool-sep {
    width: 1px;
    height: 20px;
    margin: 0 4px;
    background: var(--border);
}

.af-editor-count {
    margin-left: auto;
    padding-right: 4px;
    color: #6c7894;
    font-size: .75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.af-editor-count.is-over {
    color: #c42929;
}

/* Without the editor (library failed to load) the textarea shows as normal. */
.af-editor > textarea.form-control {
    border: 0;
    border-radius: 0;
}

.af-editor .af-editor-area {
    /* wysihtml copies the textarea's inline styles onto the editable area. */
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    min-height: 150px;
    max-height: 420px;
    overflow-y: auto;
    padding: 12px 14px;
    color: var(--navy);
    font-size: .9rem;
    line-height: 1.6;
    outline: none;
}

.af-editor .af-editor-area p,
.af-editor .af-editor-area div {
    margin: 0 0 .5em;
}

.af-editor .af-editor-area ul,
.af-editor .af-editor-area ol {
    margin: 0 0 .5em;
    padding-left: 1.6em;
}

.af-editor .af-editor-area {
    position: relative;
}

.af-editor .af-editor-area.is-empty::before {
    content: attr(data-placeholder);
    position: absolute;
    top: 12px;
    left: 14px;
    color: #8a96b0;
    pointer-events: none;
}

.af-hint {
    display: block;
    margin-top: 6px;
    color: #6c7894;
    font-size: .75rem;
}
