/**
 * Registration Form - Location Autocomplete Styles
 * Select2 theme matching form inputs
 */

.select2-container {
    display: inline-block !important;
    margin: 10px 0px 10px 30px !important;
    vertical-align: middle;
}

.select2-container--default .select2-selection--single {
    border: 1px solid #999999;
    border-radius: 6px;
    height: auto;
    padding: 5px;
    font-size: 24px;
    background-color: #ffffff;
    width: 420px;
    /* content-box to match .text-input sizing */
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #666666;
    line-height: normal;
    /* Match standard input line-height */
    padding-left: 0;
    padding-right: 20px;
    padding-top: 1px;
    /* Slight adjustment for visual centering */
    padding-bottom: 1px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #999999;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 5px;
    top: 0;
}

.select2-dropdown {
    border: 1px solid #999999;
    border-radius: 6px;
    font-size: 20px;
    z-index: 9999;
}

.select2-container--default .select2-results__option {
    padding: 8px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0066cc;
}

.select2-container--open .select2-dropdown--below {
    border-top: 1px solid #999999;
    margin-top: 2px;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #999999;
    border-radius: 4px;
    padding: 4px;
}

#location-autocomplete-section {
    position: relative;
    display: inline-block;
    vertical-align: bottom;
    /* Align with other form items */
}

/* Remove separate margin for inner element since container handles it */
#location-autocomplete-section .select2-location {
    margin: 0;
}

.location-toggle {
    margin: 5px 0px 10px 30px;
    font-size: 16px;
    color: #0066cc;
    cursor: pointer;
    text-decoration: underline;
    display: block;
    clear: both;
}

.location-toggle:hover {
    color: #004499;
}

.location-note {
    margin: 5px 0px 5px 30px;
    font-size: 14px;
    color: #666666;
    display: block;
    clear: both;
}

#profile-update-form #location-autocomplete-section {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

#register-form #location-autocomplete-section {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

#profile-update-form #location-autocomplete-section .select2-container {
    display: block !important;
    flex: 1 1 auto;
    width: 100% !important;
    max-width: none !important;
    margin: 10px 0 0 0 !important;
}

#register-form #location-autocomplete-section .select2-container {
    display: block !important;
    flex: 1 1 auto;
    width: 100% !important;
    max-width: none !important;
    margin: 10px 0 0 0 !important;
}

#profile-update-form #location-autocomplete-section .select2.select2-container {
    width: 100% !important;
    max-width: none !important;
    margin: 10px 0 0 0 !important;
}

#register-form #location-autocomplete-section .select2.select2-container {
    width: 100% !important;
    max-width: none !important;
    margin: 10px 0 0 0 !important;
}

#location-autocomplete-section .location-field-wrap {
    flex: 0 1 auto;
    min-width: 0;
    width: calc(100% - 40px);
}

/* Location pickers: full-width selection box in every form (the base theme
   fixes it at 420px, clipping long addresses outside the two section forms). */
.select2-location + .select2-container .select2-selection--single {
    width: 100%;
    box-sizing: border-box;
}

#profile-update-form #location-autocomplete-section .location-note {
    margin: 5px 0 5px 0;
}

#register-form #location-autocomplete-section .location-note {
    margin: 5px 0 5px 0;
}

#profile-update-form .resume-on-file-card {
    margin-left: 30px;
    max-width: 100%;
    box-sizing: border-box;
    width: calc(100% - 40px);
}

#profile-update-form .profile-change-password-row {
    margin: 10px 0 16px 30px;
}

#profile-update-form .btn-change-password-resume {
    background: #28a745;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    display: inline-block;
}

#profile-update-form .btn-change-password-resume:hover {
    background: #218838;
    color: #ffffff;
}

#profile-update-form .profile-linkedin-input-group {
    display: block;
    width: 100%;
}

#profilePasswordModal .modal-body .form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 16px;
    color: #333333;
}

#profilePasswordModal .modal-body .text-input {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
}

#profilePasswordModal .text-error {
    margin-left: 0;
    text-align: left;
    display: block;
}

#profilePasswordModal .profile-password-modal__hint {
    margin: 12px 0 0 0;
}

#profile-update-form #location-autocomplete-section .text-error {
    margin-left: 0px;
}

#register-form #location-autocomplete-section .text-error {
    margin-left: 0px;
}

.hidden {
    display: none;
}

/* Keep share-jobs registration grid compact when company fields are toggled off. */
#share-jobs-guest-form .form-holder,
#share-jobs-logged-in-form .form-holder {
    grid-auto-flow: row dense;
}

/* Company select spans full row so contact fields pair correctly in existing-company flow. */
#share-jobs-guest-form .share-jobs-company-field,
#share-jobs-logged-in-form .share-jobs-company-field {
    grid-column: 1 / -1;
}

/*
 * Company Select2 clear (×) placement — Select2 4.1.0-rc.0 prepends the clear
 * <button> onto .select2-selection (sibling of .select2-selection__rendered),
 * NOT inside __rendered. The shared theme also forces
 * .select2-selection--single { width: 420px } while the container is full-width,
 * so float:right lands mid-field. Stretch selection and absolutely pin × just
 * left of the dropdown arrow (scoped to company field only).
 */
#share-jobs-guest-form .share-jobs-company-field .select2-container,
#share-jobs-logged-in-form .share-jobs-company-field .select2-container,
#share-jobs-guest-form .share-jobs-company-field .select2.select2-container,
#share-jobs-logged-in-form .share-jobs-company-field .select2.select2-container {
    width: calc(100% - 40px) !important;
    max-width: 100%;
    box-sizing: border-box;
}

#share-jobs-guest-form .share-jobs-company-field .select2-selection--single,
#share-jobs-logged-in-form .share-jobs-company-field .select2-selection--single {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#share-jobs-guest-form .share-jobs-company-field .select2-selection--single .select2-selection__rendered,
#share-jobs-logged-in-form .share-jobs-company-field .select2-selection--single .select2-selection__rendered {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 56px !important; /* room for × + arrow */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

#share-jobs-guest-form .share-jobs-company-field .select2-selection--single .select2-selection__clear,
#share-jobs-logged-in-form .share-jobs-company-field .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    top: 50% !important;
    right: 28px !important; /* just left of the dropdown arrow */
    left: auto !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 4px !important;
    height: auto !important;
    transform: translateY(-50%);
    z-index: 2;
    font-weight: 700;
    font-size: 1em;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    background: transparent !important;
    border: none !important;
}

#share-jobs-guest-form .share-jobs-company-field .select2-container--default .select2-selection--single .select2-selection__arrow,
#share-jobs-logged-in-form .share-jobs-company-field .select2-container--default .select2-selection--single .select2-selection__arrow {
    right: 5px !important;
    z-index: 1;
}

/* Scoped sub-grids: new-company vs existing-company contact rows */
#share-jobs-guest-form .share-jobs-new-company-grid,
#share-jobs-logged-in-form .share-jobs-new-company-grid,
#share-jobs-guest-form .share-jobs-existing-contact-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

#share-jobs-guest-form .share-jobs-form-row,
#share-jobs-logged-in-form .share-jobs-form-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

#share-jobs-guest-form .share-jobs-new-company-grid .form-item-large,
#share-jobs-logged-in-form .share-jobs-new-company-grid .form-item-large,
#share-jobs-guest-form .share-jobs-new-company-grid .form-section-title,
#share-jobs-logged-in-form .share-jobs-new-company-grid .form-section-title,
#share-jobs-guest-form .share-jobs-manual-location,
#share-jobs-logged-in-form .share-jobs-manual-location {
    grid-column: 1 / -1;
}

#share-jobs-guest-form .share-jobs-new-company-grid .form-item-large {
    margin-left: 0;
    margin-right: 0;
}

#share-jobs-guest-form .share-jobs-new-company-grid #location-autocomplete-section-guest,
#share-jobs-logged-in-form .share-jobs-new-company-grid #location-autocomplete-section {
    position: relative;
    display: block;
    vertical-align: bottom;
}

#share-jobs-guest-form .share-jobs-new-company-grid #location-autocomplete-section-guest .location-note,
#share-jobs-logged-in-form .share-jobs-new-company-grid #location-autocomplete-section .location-note {
    margin-left: 30px;
}

#share-jobs-guest-form .share-jobs-new-company-grid .checkbox-group + .checkbox-group,
#share-jobs-logged-in-form .share-jobs-new-company-grid .checkbox-group + .checkbox-group {
    margin-top: 8px;
}

@media (max-width: 768px) {
    #share-jobs-guest-form .share-jobs-new-company-grid,
    #share-jobs-logged-in-form .share-jobs-new-company-grid,
    #share-jobs-guest-form .share-jobs-existing-contact-grid,
    #share-jobs-guest-form .share-jobs-form-row,
    #share-jobs-logged-in-form .share-jobs-form-row {
        grid-template-columns: 1fr;
    }
}

#share-jobs-guest-form.existing-company-selected .company-fields-group,
#share-jobs-logged-in-form.existing-company-selected .company-fields-group {
    display: none !important;
}

#share-jobs-guest-form.existing-company-selected .company-fields-group .select2,
#share-jobs-guest-form.existing-company-selected .company-fields-group .select2-container,
#share-jobs-logged-in-form.existing-company-selected .company-fields-group .select2,
#share-jobs-logged-in-form.existing-company-selected .company-fields-group .select2-container {
    display: none !important;
}

/* Keep share-jobs lower sections aligned without changing behavior. */
#share-jobs-guest-form .share-jobs-new-company-grid .form-section-title,
#share-jobs-logged-in-form .share-jobs-new-company-grid .form-section-title {
    grid-column: 1 / -1;
}

#share-jobs-guest-form .share-jobs-logo-section {
    margin-bottom: 20px;
}

#share-jobs-guest-form .share-jobs-logo-section .form-section-title {
    margin-top: 0;
    margin-bottom: 10px;
}

/* OSM address correction fields (shown after picker selection) */
#share-jobs-guest-form .share-jobs-address-picker-row .form-item,
#share-jobs-logged-in-form .share-jobs-address-picker-row .form-item {
    grid-column: 1 / -1;
}

#share-jobs-guest-form .share-jobs-osm-address-details,
#share-jobs-logged-in-form .share-jobs-osm-address-details {
    grid-column: 1 / -1;
    width: 100%;
    display: none;
}

#share-jobs-guest-form .share-jobs-osm-address-details.is-visible,
#share-jobs-logged-in-form .share-jobs-osm-address-details.is-visible {
    display: block;
}

#share-jobs-guest-form .share-jobs-osm-address-details .share-jobs-form-row,
#share-jobs-logged-in-form .share-jobs-osm-address-details .share-jobs-form-row {
    width: 100%;
}

/* Detail fields: keep the required star on the same line as its input,
   like the address search field above (issue #401). */
#share-jobs-guest-form .share-jobs-osm-address-details .form-item,
#share-jobs-logged-in-form .share-jobs-osm-address-details .form-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

#share-jobs-guest-form .share-jobs-osm-address-details .form-item .text-input-star,
#share-jobs-logged-in-form .share-jobs-osm-address-details .form-item .text-input-star {
    margin-top: 10px;
}

#share-jobs-guest-form .share-jobs-osm-address-details .form-item .text-input,
#share-jobs-logged-in-form .share-jobs-osm-address-details .form-item .text-input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    margin-left: 0;
}

#share-jobs-guest-form .share-jobs-osm-address-details .form-item .text-error,
#share-jobs-logged-in-form .share-jobs-osm-address-details .form-item .text-error {
    flex-basis: 100%;
}

/* Opt-in rows: one line gap between newsletter and privacy; aligned checkboxes */
#share-jobs-guest-form .share-jobs-opt-in-newsletter,
#share-jobs-logged-in-form .share-jobs-opt-in-newsletter {
    margin-bottom: 0;
}

#share-jobs-guest-form .share-jobs-opt-in-privacy,
#share-jobs-logged-in-form .share-jobs-opt-in-privacy {
    margin-top: 10px;
}

#share-jobs-guest-form #newsletter-block.newsletter-block,
#share-jobs-logged-in-form #newsletter-block.newsletter-block,
#share-jobs-guest-form #privacy-block.privacy-block,
#share-jobs-logged-in-form #privacy-block.privacy-block {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 890px;
    margin-left: 30px;
}

#share-jobs-guest-form #newsletter-block.newsletter-block input[type="checkbox"],
#share-jobs-logged-in-form #newsletter-block.newsletter-block input[type="checkbox"],
#share-jobs-guest-form #privacy-block.privacy-block input[type="checkbox"],
#share-jobs-logged-in-form #privacy-block.privacy-block input[type="checkbox"] {
    margin-top: 6px;
    flex-shrink: 0;
}

#share-jobs-guest-form #privacy-block.privacy-block label,
#share-jobs-logged-in-form #privacy-block.privacy-block label,
#share-jobs-guest-form #newsletter-block.newsletter-block label,
#share-jobs-logged-in-form #newsletter-block.newsletter-block label {
    margin: 0;
    flex: 1;
}

#share-jobs-guest-form #privacy-block.privacy-block label .text-input-star,
#share-jobs-logged-in-form #privacy-block.privacy-block label .text-input-star {
    margin-left: 0;
    margin-right: 0.15em;
}

/* ATS Feed URL label — matches optional checkbox labels (not section title) */
#share-jobs-guest-form .share-jobs-ats-feed-field,
#share-jobs-logged-in-form .share-jobs-ats-feed-field {
    margin-top: 20px;
}

#share-jobs-guest-form .share-jobs-ats-feed-label,
#share-jobs-logged-in-form .share-jobs-ats-feed-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    font-size: 18px;
    font-weight: 400 !important;
    color: #666666;
    margin: 0 0 4px 0;
    padding: 0;
    cursor: default;
}

#share-jobs-guest-form .share-jobs-ats-feed-label .text-input-star,
#share-jobs-logged-in-form .share-jobs-ats-feed-label .text-input-star {
    margin-left: 10px;
    margin-right: 0.15em;
    flex-shrink: 0;
    vertical-align: baseline;
}

#share-jobs-guest-form .share-jobs-ats-feed-field .text-input,
#share-jobs-logged-in-form .share-jobs-ats-feed-field .text-input {
    display: block;
    margin-top: 0;
}

/* #256: Change Password row — the 30px left margin pushed the row past the
   right edge on phones and threw its centred button off-centre. */
@media (max-width: 861px) {
  #profile-update-form .profile-change-password-row {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/*
 * Location picker clear (×) placement — same fix as the company field above:
 * stretch the selection full-width, pin × just left of the arrow, and give
 * the selected text room so it is not cut off underneath the ×.
 */
#share-jobs-guest-form #location-autocomplete-section-guest .select2-container,
#share-jobs-logged-in-form #location-autocomplete-section .select2-container,
#share-jobs-guest-form #location-autocomplete-section-guest .select2.select2-container,
#share-jobs-logged-in-form #location-autocomplete-section .select2.select2-container {
    width: calc(100% - 40px) !important;
    max-width: 100%;
    box-sizing: border-box;
}

#share-jobs-guest-form #location-autocomplete-section-guest .select2-selection--single,
#share-jobs-logged-in-form #location-autocomplete-section .select2-selection--single {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#share-jobs-guest-form #location-autocomplete-section-guest .select2-selection--single .select2-selection__rendered,
#share-jobs-logged-in-form #location-autocomplete-section .select2-selection--single .select2-selection__rendered {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 56px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

#share-jobs-guest-form #location-autocomplete-section-guest .select2-selection--single .select2-selection__clear,
#share-jobs-logged-in-form #location-autocomplete-section .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    top: 50% !important;
    right: 28px !important;
    left: auto !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 4px !important;
    height: auto !important;
    transform: translateY(-50%);
    z-index: 2;
    font-weight: 700;
    font-size: 1em;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    background: transparent !important;
    border: none !important;
}

/* Manage Company: same address picker, employer form markup (issue #509) */
#employer-company-form .osm-address-details {
    display: none;
}

#employer-company-form .osm-address-details.is-visible {
    display: block;
}
