/**
 * Rehab Helper — "Add your practice to the directory" form (GeoDirectory add-listing form).
 *
 * Restyles GeoDirectory's own form (#geodirectory-add-post) to the design: a white card,
 * section headings, a two-column field grid, tidy inputs / selects / tags, and a right-aligned
 * Preview + Submit footer. No markup is changed, so every GeoDirectory field, validation and
 * the saving logic keep working. Loaded only on the add-listing page.
 *
 * Tune the look with the variables below (or override them in Elementor → Custom CSS).
 */
body #geodirectory-add-post{
    --rhf-primary:#0B4EA2;
    --rhf-primary-dark:#093F82;
    --rhf-text:#0F172A;
    --rhf-muted:#64748B;
    --rhf-placeholder:#94A3B8;
    --rhf-border:#D5DCE7;
    --rhf-border-soft:#E5E9F0;
    --rhf-bg-soft:#F5F7FB;
    --rhf-danger:#DC2626;
    --rhf-radius:6px;
    --rhf-field-h:40px;

    box-sizing:border-box;
    width:100%;
    max-width:none;
    margin:0;
    padding:28px 24px 24px;
    background:#fff;
    border:1px solid var(--rhf-border-soft);
    border-radius:12px;
    box-shadow:0 1px 3px rgba(15,23,42,.05);
    color:var(--rhf-text);
    font-size:14px;
    line-height:1.5;

    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    column-gap:20px;
    row-gap:14px;
    align-items:start;
}
body #geodirectory-add-post *,
body #geodirectory-add-post *::before,
body #geodirectory-add-post *::after{ box-sizing:border-box; }

/* ---- everything that spans the whole width -------------------------------------------- */
body #geodirectory-add-post > fieldset,
body #geodirectory-add-post > h1,
body #geodirectory-add-post > h2,
body #geodirectory-add-post > h3,
body #geodirectory-add-post > h4,
body #geodirectory-add-post > h5,
body #geodirectory-add-post > .geodir-fieldset-row,
body #geodirectory-add-post > .geodir-note,
body #geodirectory-add-post > .alert,
body #geodirectory-add-post > p,
body #geodirectory-add-post > #geodir-add-listing-submit,
body #geodirectory-add-post > :has(textarea),
body #geodirectory-add-post > :has(.wp-editor-wrap),
body #geodirectory-add-post > :has(.mce-tinymce),
body #geodirectory-add-post > :has(.dropzone),
body #geodirectory-add-post > :has(.geodir-add-files),
body #geodirectory-add-post > :has(.geodir-map-container),
body #geodirectory-add-post > :has(#geodir_map),
body #geodirectory-add-post > :has(.geodir-gd-map),
body #geodirectory-add-post > :has(input[type="file"]),
body #geodirectory-add-post > .geodir_form_row.clear_both{
    grid-column:1 / -1;
}
/* hidden inputs and scripts must not take a grid cell */
body #geodirectory-add-post > input[type="hidden"],
body #geodirectory-add-post > script,
body #geodirectory-add-post > noscript{ display:none; }

/* ---- section headings ------------------------------------------------------------------- */
body #geodirectory-add-post fieldset{
    margin:0;
    padding:0;
    border:0;
    min-width:0;
}
body #geodirectory-add-post > fieldset:not(:first-of-type),
body #geodirectory-add-post > .geodir-fieldset-row:not(:first-of-type){
    margin-top:14px;
}
body #geodirectory-add-post h1,
body #geodirectory-add-post h2,
body #geodirectory-add-post h3,
body #geodirectory-add-post h4,
body #geodirectory-add-post h5,
body #geodirectory-add-post .h3,
body #geodirectory-add-post .geodir-fieldset-row{
    margin:0;
    padding:0 0 10px;
    font-size:15px;
    font-weight:600;
    line-height:1.3;
    color:var(--rhf-text);
    border-bottom:1px solid var(--rhf-border-soft);
}
body #geodirectory-add-post .geodir-fieldset-row{ padding-bottom:10px; }
/* first heading = the form's own title row */
body #geodirectory-add-post > fieldset:first-of-type h3,
body #geodirectory-add-post > .geodir-fieldset-row:first-of-type{
    font-size:16px;
}

/* ---- field rows: stack the label above the control ---------------------------------------- */
body #geodirectory-add-post .row,
body #geodirectory-add-post .geodir_form_row,
body #geodirectory-add-post .form-group,
body #geodirectory-add-post .mb-3{
    margin-left:0;
    margin-right:0;
    margin-bottom:0;
}
body #geodirectory-add-post .row{
    display:flex;
    flex-direction:column;
    gap:6px;
}
body #geodirectory-add-post .row > [class*="col-"],
body #geodirectory-add-post .row > label{
    flex:0 0 auto;
    width:100%;
    max-width:100%;
    padding-left:0;
    padding-right:0;
}
body #geodirectory-add-post .geodir_form_row{
    display:flex;
    flex-direction:column;
    gap:6px;
    float:none;
    width:auto;
    padding:0;
}
body #geodirectory-add-post .geodir_form_row > label,
body #geodirectory-add-post .geodir_form_row > .geodir_form_label{ float:none; width:auto; }

/* ---- labels ---------------------------------------------------------------------------------- */
body #geodirectory-add-post label,
body #geodirectory-add-post .col-form-label,
body #geodirectory-add-post .form-label{
    display:block;
    margin:0 0 2px;
    padding:0;
    font-size:12px;
    font-weight:500;
    line-height:1.4;
    color:#334155;
    text-align:left;
}
body #geodirectory-add-post .text-danger,
body #geodirectory-add-post .geodir-required,
body #geodirectory-add-post .required label::after{
    color:var(--rhf-danger) !important;
}
body #geodirectory-add-post .required_field > label::after{
    content:" *";
    color:var(--rhf-danger);
}
/* "(Optional)" and friends */
body #geodirectory-add-post label small,
body #geodirectory-add-post label .optional{ font-weight:400; color:var(--rhf-muted); }

/* ---- inputs, selects, textareas --------------------------------------------------------------- */
body #geodirectory-add-post input[type="text"],
body #geodirectory-add-post input[type="email"],
body #geodirectory-add-post input[type="url"],
body #geodirectory-add-post input[type="tel"],
body #geodirectory-add-post input[type="number"],
body #geodirectory-add-post input[type="search"],
body #geodirectory-add-post input[type="password"],
body #geodirectory-add-post input[type="date"],
body #geodirectory-add-post input[type="time"],
body #geodirectory-add-post select,
body #geodirectory-add-post .form-control,
body #geodirectory-add-post .form-select,
body #geodirectory-add-post .select2-container .select2-selection--single,
body #geodirectory-add-post .select2-container .select2-selection--multiple{
    width:100%;
    min-height:var(--rhf-field-h);
    padding:8px 12px;
    font-family:inherit;
    font-size:14px;
    line-height:1.4;
    color:var(--rhf-text);
    background-color:#fff;
    border:1px solid var(--rhf-border);
    border-radius:var(--rhf-radius);
    box-shadow:none;
    transition:border-color .15s ease, box-shadow .15s ease;
}
body #geodirectory-add-post textarea,
body #geodirectory-add-post textarea.form-control{
    width:100%;
    min-height:96px;
    padding:10px 12px;
    font-family:inherit;
    font-size:14px;
    line-height:1.5;
    color:var(--rhf-text);
    background:#fff;
    border:1px solid var(--rhf-border);
    border-radius:var(--rhf-radius);
    box-shadow:none;
    resize:vertical;
}
body #geodirectory-add-post input::placeholder,
body #geodirectory-add-post textarea::placeholder{
    color:var(--rhf-placeholder);
    opacity:1;
}
body #geodirectory-add-post input:focus,
body #geodirectory-add-post select:focus,
body #geodirectory-add-post textarea:focus,
body #geodirectory-add-post .form-control:focus,
body #geodirectory-add-post .select2-container--focus .select2-selection,
body #geodirectory-add-post .select2-container--open .select2-selection{
    outline:0;
    border-color:var(--rhf-primary);
    box-shadow:0 0 0 3px rgba(11,78,162,.14);
}
body #geodirectory-add-post input[disabled],
body #geodirectory-add-post select[disabled],
body #geodirectory-add-post textarea[disabled]{
    background:var(--rhf-bg-soft);
    color:var(--rhf-muted);
}
/* invalid */
body #geodirectory-add-post .is-invalid,
body #geodirectory-add-post .form-control.is-invalid{ border-color:var(--rhf-danger); }
body #geodirectory-add-post .invalid-feedback,
body #geodirectory-add-post .geodir_message_error{ font-size:12px; color:var(--rhf-danger); }

/* select2 (category, tags, country…) */
body #geodirectory-add-post .select2-container{ width:100% !important; }
body #geodirectory-add-post .select2-container .select2-selection--single{ display:flex; align-items:center; }
body #geodirectory-add-post .select2-container .select2-selection--single .select2-selection__rendered{
    padding:0;
    line-height:1.4;
    color:var(--rhf-text);
}
body #geodirectory-add-post .select2-container .select2-selection--single .select2-selection__placeholder{ color:var(--rhf-placeholder); }
body #geodirectory-add-post .select2-container .select2-selection--single .select2-selection__arrow{ height:100%; right:8px; }
body #geodirectory-add-post .select2-container .select2-selection--multiple{ display:flex; flex-wrap:wrap; gap:6px; padding:5px 8px; }
body #geodirectory-add-post .select2-container .select2-selection--multiple .select2-selection__choice,
body #geodirectory-add-post .tagify__tag,
body #geodirectory-add-post .badge{
    margin:0;
    padding:3px 10px;
    font-size:12px;
    font-weight:500;
    color:#334155;
    background:var(--rhf-bg-soft);
    border:1px solid var(--rhf-border-soft);
    border-radius:999px;
}

/* helper text under a field */
body #geodirectory-add-post .form-text,
body #geodirectory-add-post .help-text,
body #geodirectory-add-post small.text-muted,
body #geodirectory-add-post .geodir-help{
    display:block;
    margin-top:4px;
    font-size:12px;
    line-height:1.4;
    color:var(--rhf-muted) !important;
}

/* ---- checkboxes / radios ----------------------------------------------------------------------- */
body #geodirectory-add-post input[type="checkbox"],
body #geodirectory-add-post input[type="radio"]{
    width:16px;
    height:16px;
    min-height:0;
    margin-right:8px;
    accent-color:var(--rhf-primary);
}
body #geodirectory-add-post .form-check-label,
body #geodirectory-add-post .form-check label{ display:inline; font-size:13px; font-weight:400; color:#334155; }

/* ---- photo / file upload ------------------------------------------------------------------------- */
body #geodirectory-add-post .dropzone,
body #geodirectory-add-post .geodir-add-files .dropzone,
body #geodirectory-add-post .plupload-upload-uic{
    padding:16px;
    background:#fff;
    border:1.5px dashed #C9D3E6;
    border-radius:10px;
    color:var(--rhf-muted);
}
body #geodirectory-add-post .dropzone:hover,
body #geodirectory-add-post .plupload-upload-uic:hover{ border-color:var(--rhf-primary); background:#F8FAFD; }
body #geodirectory-add-post .dz-message{ margin:0; font-size:14px; color:#334155; }
body #geodirectory-add-post .dz-preview .dz-image,
body #geodirectory-add-post .dz-preview img{ border-radius:8px; }
body #geodirectory-add-post input[type="file"]{
    min-height:0;
    padding:8px;
    font-size:13px;
}

/* ---- rich-text editor (reviews embed, descriptions) -------------------------------------------- */
body #geodirectory-add-post .wp-editor-wrap,
body #geodirectory-add-post .mce-tinymce{
    border:1px solid var(--rhf-border);
    border-radius:var(--rhf-radius);
    overflow:hidden;
    box-shadow:none;
}
body #geodirectory-add-post .wp-editor-tools{ padding:6px 8px 0; background:var(--rhf-bg-soft); }
body #geodirectory-add-post .mce-toolbar-grp,
body #geodirectory-add-post .quicktags-toolbar{ background:var(--rhf-bg-soft); border-bottom:1px solid var(--rhf-border-soft); }

/* ---- map block ------------------------------------------------------------------------------------ */
body #geodirectory-add-post .geodir-map-container,
body #geodirectory-add-post #geodir_map,
body #geodirectory-add-post .geodir-map-wrap{
    border-radius:10px;
    overflow:hidden;
    border:1px solid var(--rhf-border);
}

/* ---- footer: Preview + Submit, right aligned ---------------------------------------------------------- */
body #geodirectory-add-post #geodir-add-listing-submit{
    display:flex !important;
    flex-direction:row-reverse;          /* GeoDirectory prints Submit first; the design shows Preview first */
    justify-content:flex-start;
    align-items:center;
    flex-wrap:wrap;
    gap:12px;
    margin:10px 0 0;
    padding:18px 0 0 !important;
    border-top:1px solid var(--rhf-border-soft);
    text-align:right !important;
}
body #geodirectory-add-post #geodir-add-listing-submit > label,
body #geodirectory-add-post #geodir-add-listing-submit > .col-sm-2{ display:none; }
body #geodirectory-add-post #geodir-add-listing-submit > .col-sm-10{
    display:flex;
    flex-direction:row-reverse;
    gap:12px;
    width:auto;
    max-width:none;
    padding:0;
}
body #geodirectory-add-post .geodir_button,
body #geodirectory-add-post .btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    min-height:var(--rhf-field-h);
    margin:0;
    padding:0 18px;
    font-family:inherit;
    font-size:14px;
    font-weight:500;
    line-height:1;
    text-decoration:none;
    border-radius:8px;
    cursor:pointer;
    transition:background-color .15s ease, border-color .15s ease, color .15s ease;
}
/* Submit */
body #geodirectory-add-post button.geodir_button,
body #geodirectory-add-post .btn-primary{
    color:#fff;
    background:var(--rhf-primary);
    border:1px solid var(--rhf-primary);
}
body #geodirectory-add-post button.geodir_button:hover,
body #geodirectory-add-post .btn-primary:hover{
    background:var(--rhf-primary-dark);
    border-color:var(--rhf-primary-dark);
    color:#fff;
}
/* Preview */
body #geodirectory-add-post a.geodir_preview_button,
body #geodirectory-add-post .btn-outline-primary{
    color:var(--rhf-primary);
    background:#EEF2F8;
    border:1px solid transparent;
}
body #geodirectory-add-post a.geodir_preview_button:hover,
body #geodirectory-add-post .btn-outline-primary:hover{
    color:#fff;
    background:var(--rhf-primary);
}
body #geodirectory-add-post a.geodir_preview_button i{ display:none; }

/* ---- tablet / phone: single column ------------------------------------------------------------------- */
@media (max-width:760px){
    body #geodirectory-add-post{
        grid-template-columns:minmax(0,1fr);
        padding:20px 16px 18px;
        border-radius:10px;
    }
    body #geodirectory-add-post #geodir-add-listing-submit{
        flex-direction:column-reverse;
        align-items:stretch;
    }
    body #geodirectory-add-post #geodir-add-listing-submit .btn,
    body #geodirectory-add-post #geodir-add-listing-submit .geodir_button{ width:100%; }
}


/* ---- sections inside the form (Address, Photo…): bold title, plain description, no rule ------------ */
body #geodirectory-add-post > fieldset.rh-gd-section{
    margin-top:12px;
}
body #geodirectory-add-post > fieldset.rh-gd-section h3,
body #geodirectory-add-post > fieldset.rh-gd-section .h3{
    padding:0;
    border:0;
    font-size:15px;
    font-weight:600;
}
body #geodirectory-add-post .rh-gd-section__desc{
    margin:2px 0 0;
    font-size:12px;
    line-height:1.4;
    color:var(--rhf-muted);
}

/* ---- fields that take the whole row (the rest sit two to a row) --------------------------------------------- */
body #geodirectory-add-post > :has(select[name^="post_category"]),
body #geodirectory-add-post > :has([id^="post_category"]),
body #geodirectory-add-post > :has(input[name="street"]),
body #geodirectory-add-post > :has(input[name="street2"]),
body #geodirectory-add-post > #post_category_row,
body #geodirectory-add-post > #geodir_street_row{
    grid-column:1 / -1;
}

/* the "0/200" style counter under a textarea and the little info line under a field */
body #geodirectory-add-post .geodir-char-count,
body #geodirectory-add-post .char-count{ font-size:11px; color:var(--rhf-placeholder); text-align:right; }

/* ---- input prefix / icons and character counter (added by rehab-helper-directory-form.js) ---- */
body #geodirectory-add-post .rh-gd-affix{ position:relative; display:flex; align-items:stretch; width:100%; }
body #geodirectory-add-post .rh-gd-affix > input{ flex:1 1 auto; min-width:0; }
body #geodirectory-add-post .rh-gd-affix__tag{ display:flex; align-items:center; color:var(--rhf-placeholder,#9CA3AF); font-size:12px; }
body #geodirectory-add-post .rh-gd-affix--prefix .rh-gd-affix__tag{ padding:0 12px; border:1px solid var(--rhf-border,#E5E7EB); border-right:0; border-radius:6px 0 0 6px; background:#fff; }
body #geodirectory-add-post .rh-gd-affix--prefix > input{ border-radius:0 6px 6px 0 !important; }
body #geodirectory-add-post .rh-gd-affix--icon .rh-gd-affix__tag{ position:absolute; left:12px; top:0; bottom:0; pointer-events:none; }
body #geodirectory-add-post .rh-gd-affix--icon > input{ padding-left:36px !important; }
body #geodirectory-add-post .rh-gd-count{ display:block; margin-top:-22px; padding:0 10px 0 0; text-align:right; font-size:11px; line-height:1; color:var(--rhf-placeholder,#9CA3AF); pointer-events:none; position:relative; }

/* ---- page header: back link, title, subtitle, rule ---- */
.rh-gd-head{ margin:0 0 20px; padding-bottom:16px; border-bottom:1px solid var(--rhf-border,#E5E7EB); }
.rh-gd-back{ display:inline-block; margin-bottom:14px; font-size:12px; color:#374151; text-decoration:none; }
.rh-gd-head .rh-gd-title{ margin:0 0 4px; font-size:22px; font-weight:600; line-height:1.25; color:#111827; }
.rh-gd-sub{ margin:0; font-size:13px; color:#6B7280; }

/* the form itself is the white rounded card (header sits above it); !important beats theme / AUI wrappers */
body form#geodirectory-add-post{
    background:#fff !important;
    border:1px solid var(--rhf-border-soft,#E5E9F0) !important;
    border-radius:12px !important;
    box-shadow:0 1px 3px rgba(15,23,42,.05) !important;
    padding:28px 24px 24px !important;
    margin-left:auto; margin-right:auto;
}
@media(max-width:767px){ body form#geodirectory-add-post{ padding:18px 16px 16px !important; border-radius:10px !important; } }

/* design: the page behind the form is light grey, only the form card is white */
body:has(#geodirectory-add-post),
body:has(#geodirectory-add-post) #content,
body:has(#geodirectory-add-post) .site-content,
body:has(#geodirectory-add-post) main,
body:has(#geodirectory-add-post) .elementor-widget-container{ background-color:#F4F5F7; }
body:has(#geodirectory-add-post) .elementor-widget-container:has(#geodirectory-add-post){ padding-top:8px; padding-bottom:40px; }

/* phone: country-code picker (intl-tel-input). MemberPress ships no flag sprite, so flags are hidden; the "+1" stays. */
body #geodirectory-add-post .iti{ width:100%; }
body #geodirectory-add-post .iti .iti__flag{ display:none; }
body #geodirectory-add-post .iti .iti__selected-flag{ padding:0 10px; border-right:1px solid var(--rhf-border,#E5E7EB); background:#fff; border-radius:6px 0 0 6px; }
body #geodirectory-add-post .iti .iti__selected-dial-code{ margin-left:0; font-size:13px; color:#111827; }
body #geodirectory-add-post .iti .iti__country-list{ z-index:30; max-width:320px; font-size:12px; }
body #geodirectory-add-post .iti .iti__country .iti__flag-box{ display:none; }


/* design has no stock "Enter Listing Details" heading and no grey help line under every field */
body #geodirectory-add-post #geodir_fieldset_details,
body #geodirectory-add-post fieldset:has(> h3:only-child):first-of-type:not(.rh-gd-section){ display:none; }
body #geodirectory-add-post .form-text:not(.text-danger):not(.geodir-field-error),
body #geodirectory-add-post small.text-muted:not(.geodir-field-error){ display:none; }

/* width: the card is as wide as the page container and the header above it (no 1100px cap) */
body form#geodirectory-add-post{ max-width:none !important; width:100% !important; margin-left:0 !important; margin-right:0 !important; }
.rh-gd-head{ max-width:none; width:100%; }
