/* ==========================================================================
   User Location (Lat/Lng) Field Component
   Inputs mirror the form's floating-label text inputs (_gravityforms.scss),
   the button mirrors the DLS field's Clear button and the confirmation
   dialog mirrors the site dialogs (_dialogs.scss).
   ========================================================================== */

/* Axiomatic Margin Reset - prevent lobotomized owl (* + *) from breaking layout */
.c-user-location,
.c-user-location *,
.c-user-location * + *,
.gfield--type-user_location * + * {
    margin-top: 0;
}

/* The form's generic field rules zero line-height on nested divs/spans for its
   floating-label inputs; this field lays out its own sub-inputs */
main#page div.gform_wrapper .gfield--type-user_location div:not(.gfield_description),
main#page div.gform_wrapper .gfield--type-user_location span {
    line-height: 1.3 !important;
}

/* Field label - static and bold like the other compound fields */
main#page div.gform_wrapper .gfield--type-user_location > .gfield_label,
.gfield--type-user_location > .gfield_label,
main#page div.gform_wrapper .gfield--type-user_location.focus > .gfield_label,
main#page div.gform_wrapper .gfield--type-user_location.populated > .gfield_label {
    position: static !important;
    inset: unset !important;
    transform: none !important;
    display: block !important;
    width: 100% !important;
    margin: 0 0 0.5rem 0 !important;
    padding: 0 !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: var(--brand-black, #191919) !important;
    pointer-events: auto !important;
}

main#page div.gform_wrapper .gfield--type-user_location > .gfield_label .gfield_required {
    color: #717171 !important;
}

.c-user-location {
    display: block;
    width: 100%;
}

/* Lat / Lng - two columns matching gf_left_half / gf_right_half spacing */
.c-user-location__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.c-user-location__item {
    position: relative;
    min-width: 0;
}

main#page div.gform_wrapper .c-user-location .c-user-location__input {
    display: block;
    width: 100% !important;
    padding: 1.3rem 1rem 0.6rem !important;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    background: #fff;
    line-height: 1.3 !important;
    margin: 0 !important;
    transition: 0.3s ease;
    box-sizing: border-box;
}

main#page div.gform_wrapper .c-user-location .c-user-location__input:focus {
    border-color: #007AF8;
    outline: none;
}

/* Floating sub-labels, same motion as the form's text fields */
main#page div.gform_wrapper .c-user-location .c-user-location__label {
    position: absolute;
    top: 1.1rem;
    left: 1rem;
    right: 0;
    width: auto !important;
    margin: 0 !important;
    padding: 0;
    color: #1a1a1a;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1;
    transform-origin: top left;
    transition: 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

main#page div.gform_wrapper .c-user-location .c-user-location__label .gfield_required {
    color: #717171 !important;
    margin-left: 2px;
}

main#page div.gform_wrapper .c-user-location .c-user-location__input:focus + .c-user-location__label,
main#page div.gform_wrapper .c-user-location .c-user-location__input:not(:placeholder-shown) + .c-user-location__label {
    color: #007AF8;
    font-size: 12px;
    transform: translateY(-75%);
}

main#page div.gform_wrapper .c-user-location .c-user-location__input:focus + .c-user-location__label .gfield_required,
main#page div.gform_wrapper .c-user-location .c-user-location__input:not(:placeholder-shown) + .c-user-location__label .gfield_required {
    color: #007AF8 !important;
}

/* Actions row */
.c-user-location__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    /* padding rather than margin: the form forces margin-top: 0 on nested divs */
    padding-top: 1rem;
}

main#page div.gform_wrapper .c-user-location__locate-btn {
    height: 48px;
    padding: 0 1.5rem;
    background-color: #fff;
    border: 1px solid #000;
    border-radius: 0;
    color: #1a1a1a;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

main#page div.gform_wrapper .c-user-location__locate-btn:hover,
main#page div.gform_wrapper .c-user-location__locate-btn:focus-visible {
    background-color: #007AF8;
    border-color: #007AF8;
    color: #fff;
    outline: none;
}

main#page div.gform_wrapper .c-user-location__locate-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

main#page div.gform_wrapper .c-user-location__locate-btn:active:not(:disabled) {
    transform: translateY(1px);
}

main#page div.gform_wrapper .c-user-location__status {
    flex: 1 1 16rem;
    margin: 0 !important;
    padding: 0;
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.4;
    color: #717171;
}

.c-user-location__status:empty {
    display: none;
}

main#page div.gform_wrapper .c-user-location__status.is-success {
    color: #007AF8;
    font-style: normal;
}

main#page div.gform_wrapper .c-user-location__status.is-error {
    color: #c02b0a;
    font-style: normal;
}

/* Validation message sits below the whole field instead of on an input border */
main#page div.gform_wrapper .gfield--type-user_location .validation_message {
    position: static !important;
    margin-top: 0.5rem !important;
    padding: 0 !important;
    line-height: 1.3 !important;
    background: none !important;
}

/* Confirmation dialog - margin: auto centres the modal, which the margin resets above would otherwise undo */
main#page .c-user-location .c-user-location__dialog {
    margin: auto !important;
}

.c-user-location__dialog {
    width: calc(100% - 2rem);
    max-width: 600px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.c-user-location__dialog::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

.c-user-location__dialog-heading {
    padding: 1.25rem 2rem;
    background-color: #007AF8;
}

.c-user-location__dialog-heading h3 {
    margin: 0;
    color: #fff;
    line-height: 1.2;
}

.c-user-location__dialog-heading h3::after {
    content: none;
}

.c-user-location__dialog-content {
    padding: 2rem;
    background: #fff;
}

.c-user-location__dialog-content p {
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.5;
    color: #1a1a1a;
}

.c-user-location__dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 2rem;
}

.c-user-location__dialog-btn {
    min-width: 8rem;
    padding: 0.5rem 2rem;
    border: 2px solid transparent;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.c-user-location__dialog-btn--yes {
    background-color: #007AF8;
    color: #fff;
}

.c-user-location__dialog-btn--no {
    background-color: #fff;
    border-color: #1a1a1a;
    color: #1a1a1a;
}

.c-user-location__dialog-btn--yes:hover,
.c-user-location__dialog-btn--yes:focus-visible,
.c-user-location__dialog-btn--no:hover,
.c-user-location__dialog-btn--no:focus-visible {
    background-color: transparent;
    border-color: #1a1a1a;
    color: #1a1a1a;
    outline: none;
}

.c-user-location__dialog-btn--no:hover,
.c-user-location__dialog-btn--no:focus-visible {
    border-color: #007AF8;
    color: #007AF8;
}

/* Admin entry detail */
.c-user-location-display a {
    margin-left: 0.5rem;
}

@media screen and (max-width: 767px) {
    .c-user-location__grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .c-user-location__actions {
        flex-direction: column;
        align-items: stretch;
    }

    main#page div.gform_wrapper .c-user-location__locate-btn {
        width: 100%;
        justify-content: center;
    }

    main#page div.gform_wrapper .c-user-location__status {
        flex-basis: auto;
    }

    .c-user-location__dialog-heading h3 {
        font-size: 1.5rem;
    }

    .c-user-location__dialog-content,
    .c-user-location__dialog-heading {
        padding: 1.25rem;
    }

    .c-user-location__dialog-buttons {
        flex-direction: column-reverse;
    }
}
