/* ==========================================================================
   OneStone FormBuilder — Modern Fill Page (fill-modern.css)
   Scope: everything under body.fill-modern (public + authenticated fill).
   Loads AFTER vendor/formTheme/form.css; legacy theme hooks (body.theme-1..10,
   .newform-*, .bg-back) keep working — this sheet restyles the core experience
   and neutralizes only what breaks on mobile. Mobile-first (390px baseline).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens + legacy theme accent map
   -------------------------------------------------------------------------- */
body.fill-modern {
    --fm-accent: #584ED2;
    --fm-accent-soft: rgba(88, 78, 210, 0.12);
    --fm-gradient: linear-gradient(90deg, #584ED2, #24C6E3, #EC367E);
    --fm-ink: #14142B;
    --fm-muted: #6E7191;
    --fm-border: #E2E2EE;
    --fm-bg: #F7F7FB;
    --fm-card: #FFFFFF;
    --fm-danger: #EC367E;
    --fm-radius: 12px;
    /* keep legacy var used by the live step circles working */
    --os-primary: var(--fm-accent);
}

/* Map legacy theme_color choices to the accent (palette from form.css) */
body.fill-modern.theme-1  { --fm-accent: #0CAF60; --fm-accent-soft: rgba(12,175,96,.12); }
body.fill-modern.theme-2  { --fm-accent: #584ED2; --fm-accent-soft: rgba(88,78,210,.12); }
body.fill-modern.theme-3  { --fm-accent: #6FD943; --fm-accent-soft: rgba(111,217,67,.12); }
body.fill-modern.theme-4  { --fm-accent: #145388; --fm-accent-soft: rgba(20,83,136,.12); }
body.fill-modern.theme-5  { --fm-accent: #B9406B; --fm-accent-soft: rgba(185,64,107,.12); }
body.fill-modern.theme-6  { --fm-accent: #008ECC; --fm-accent-soft: rgba(0,142,204,.12); }
body.fill-modern.theme-7  { --fm-accent: #922C88; --fm-accent-soft: rgba(146,44,136,.12); }
body.fill-modern.theme-8  { --fm-accent: #C0A145; --fm-accent-soft: rgba(192,161,69,.12); }
body.fill-modern.theme-9  { --fm-accent: #48494B; --fm-accent-soft: rgba(72,73,75,.12); }
body.fill-modern.theme-10 { --fm-accent: #0C7785; --fm-accent-soft: rgba(12,119,133,.12); }

/* --------------------------------------------------------------------------
   2. Page + container + card
   -------------------------------------------------------------------------- */
body.fill-modern {
    background-color: var(--fm-bg);
    color: var(--fm-ink);
    -webkit-font-smoothing: antialiased;
}

/* faint brand wash at the very top of the page */
body.fill-modern:not(.bg-back)::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--fm-gradient);
    z-index: 10;
    pointer-events: none;
}

body.fill-modern .section-body > .row,
body.fill-modern .section-body .mx-0.mt-5.row {
    margin-top: 1.25rem !important;
}

/* center column: full width on phones, capped card on desktop */
body.fill-modern .section-body .mx-auto.col-md-7 {
    width: 100%;
    max-width: 640px;
    padding-left: 12px;
    padding-right: 12px;
}

body.fill-modern .card {
    background: var(--fm-card);
    border: 1px solid var(--fm-border);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(20, 20, 43, 0.06);
    overflow: hidden;
}

body.fill-modern .card .card-body,
body.fill-modern .card .form-card-body {
    padding: 20px;
}

/* --------------------------------------------------------------------------
   3. Header: logo + serif title + gradient underline
   -------------------------------------------------------------------------- */
body.fill-modern .gallery.gallery-md {
    margin: 18px 0 6px;
}

body.fill-modern .gallery.gallery-md img.gallery-item,
body.fill-modern .gallery.gallery-md img#app-dark-logo {
    max-height: 56px;
    width: auto !important;
    height: auto;
    max-width: 70vw;
    object-fit: contain;
    float: none;
}

body.fill-modern .card .card-header {
    background: transparent !important;
    border-bottom: 0;
    padding: 26px 20px 0;
}

body.fill-modern .card .card-header h5 {
    font-family: Fraunces, 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--fm-ink) !important;
    text-align: center;
    margin: 0;
    position: relative;
    padding-bottom: 18px;
}

/* gradient underline (top:auto defeats a legacy h5::after { top:-5px } rule) */
body.fill-modern .card .card-header h5::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    bottom: 0;
    width: 64px;
    height: 4px;
    border-radius: 4px;
    background: var(--fm-gradient);
}

/* --------------------------------------------------------------------------
   4. Inputs, labels, focus, validation
   -------------------------------------------------------------------------- */
body.fill-modern .form-group {
    margin-bottom: 18px;
}

body.fill-modern .form-label,
body.fill-modern label {
    display: inline-block;   /* keeps the sibling required "*" on the same line */
    font-size: 14px;
    font-weight: 600;
    color: var(--fm-ink);
    margin-bottom: 6px;
}

/* required star is a SIBLING span after the label in the markup */
body.fill-modern label + span.text-danger {
    display: inline;
    margin-left: 2px;
    font-weight: 700;
}

body.fill-modern .form-control,
body.fill-modern .form-select {
    min-height: 48px;
    font-size: 16px;            /* prevents iOS auto-zoom */
    color: var(--fm-ink);
    background-color: #fff;
    border: 1.5px solid var(--fm-border);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

body.fill-modern textarea.form-control {
    min-height: 120px;
}

body.fill-modern .form-control:focus,
body.fill-modern .form-select:focus {
    border-color: var(--fm-accent);
    box-shadow: 0 0 0 3px var(--fm-accent-soft);
    outline: none;
}

body.fill-modern .form-control::placeholder {
    color: #A6A8BD;
}

/* required mark */
body.fill-modern label .text-danger,
body.fill-modern label span[style*="color"] {
    color: var(--fm-danger) !important;
}

/* validation */
body.fill-modern .form-control.is-invalid,
body.fill-modern .form-select.is-invalid,
body.fill-modern .is-invalid {
    border-color: var(--fm-danger) !important;
    box-shadow: 0 0 0 3px rgba(236, 54, 126, 0.12) !important;
}

body.fill-modern .form-control.is-valid,
body.fill-modern .is-valid {
    border-color: #0CAF60;
}

body.fill-modern .error-message,
body.fill-modern .invalid-feedback {
    color: var(--fm-danger);
    font-size: 13px;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

/* select2 / choices harmonization */
body.fill-modern .select2-container .select2-selection--single,
body.fill-modern .choices__inner {
    min-height: 48px;
    border: 1.5px solid var(--fm-border);
    border-radius: 10px;
    font-size: 16px;
}

/* --------------------------------------------------------------------------
   5. Checkbox / radio — tappable card rows + mobile stacking
   -------------------------------------------------------------------------- */
body.fill-modern .form-check {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1.5px solid var(--fm-border);
    border-radius: 10px;
    padding: 12px 14px 12px 42px;
    margin-bottom: 8px;
    min-height: 48px;
    transition: border-color .15s ease, background-color .15s ease;
}

body.fill-modern .form-check .form-check-input {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--fm-accent);
    border: 1.5px solid var(--fm-border);
    flex-shrink: 0;
}

body.fill-modern .form-check .form-check-input:checked {
    background-color: var(--fm-accent);
    border-color: var(--fm-accent);
}

body.fill-modern .form-check:has(input:checked) {
    border-color: var(--fm-accent);
    background-color: var(--fm-accent-soft);
}

body.fill-modern .form-check label,
body.fill-modern .form-check .form-check-label {
    margin: 0;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    width: 100%;
}

/* make the whole row tappable */
body.fill-modern .form-check .form-check-input {
    cursor: pointer;
}

/* the hardcoded inline col-4 checkbox grid + designer col-6/col-4 stack on phones.
   Also applied for ANY touch device up to 1100px (pointer: coarse) — this covers
   phones stuck in "Desktop site" mode, landscape phones and small tablets, where
   the viewport reports wide but the screen is physically small. */
@media (max-width: 575.98px), ((pointer: coarse) and (max-width: 1100px)) {
    body.fill-modern .form-check.form-check-inline.col-4,
    body.fill-modern .form-check.form-check-inline {
        width: 100%;
        margin-right: 0;
        display: flex;
    }
    body.fill-modern .tab .row > .col-6,
    body.fill-modern .tab .row > .col-4 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    body.fill-modern .formcustomer {
        width: 100% !important;
    }
    /* keep the card filling the screen instead of a small centered island */
    body.fill-modern .section-body .mx-auto.col-md-7 {
        width: 100%;
        max-width: 640px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* --------------------------------------------------------------------------
   6. Special fields
   -------------------------------------------------------------------------- */
/* signature */
body.fill-modern canvas.signaturePad {
    width: 100% !important;
    height: 180px !important;
    border: 1.5px dashed var(--fm-border);
    border-radius: 10px;
    background: #fff;
    touch-action: none;
}

/* selfie webcam + result */
body.fill-modern #my_camera,
body.fill-modern .camera_screen {
    width: 100% !important;
    max-width: 420px;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
}
body.fill-modern #my_camera video,
body.fill-modern .camera_screen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}
body.fill-modern #results img,
body.fill-modern .selfie_result img {
    width: 100% !important;
    max-width: 420px;
    height: auto !important;
    border-radius: 10px;
}

/* video recorder */
body.fill-modern #web-cam-container,
body.fill-modern video#web-cam-container {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    background: #14142B;
    object-fit: cover;
}

/* map */
body.fill-modern #map {
    width: 100%;
    height: 280px;
    border-radius: 10px;
    border: 1.5px solid var(--fm-border);
}
body.fill-modern #pac-input {
    min-height: 44px;
    border-radius: 8px;
    border: 1.5px solid var(--fm-border);
    padding: 8px 12px;
    font-size: 15px;
    margin: 8px 0;
    max-width: 100%;
}

/* file input — dashed drop area look on the native control */
body.fill-modern input[type="file"].form-control,
body.fill-modern input[type="file"] {
    width: 100%;
    min-height: 56px;
    padding: 14px;
    border: 2px dashed var(--fm-border);
    border-radius: 10px;
    background: #FAFAFE;
    font-size: 14px;
    color: var(--fm-muted);
    position: static;          /* neutralize form.css absolute hack */
    opacity: 1;
    cursor: pointer;
}
body.fill-modern input[type="file"]::file-selector-button {
    border: 0;
    border-radius: 8px;
    background: var(--fm-accent);
    color: #fff;
    padding: 8px 14px;
    margin-right: 12px;
    font-size: 14px;
    cursor: pointer;
}
body.fill-modern .dropzone {
    border: 2px dashed var(--fm-border);
    border-radius: 10px;
    background: #FAFAFE;
    min-height: 120px;
}
/* neutralize the 110px absolute-positioned legacy file hack if present */
body.fill-modern .file-select-set,
body.fill-modern .file-select-set input[type=file] {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    opacity: 1 !important;
}
body.fill-modern .file-select-set .file-opc {
    display: none;
}

/* star rating */
body.fill-modern .starRating,
body.fill-modern .rateyo {
    margin: 4px 0 2px;
}

/* phone / intl-tel + the success whatsapp picker */
body.fill-modern .intl-tel-input {
    display: flex;
    width: 100%;
}
body.fill-modern .intl-tel-input .form-control {
    flex: 1 1 auto;
}
body.fill-modern select#country_code {
    max-width: 120px !important;
    min-width: 96px;
}

/* number spinners hidden (existing behavior kept) */

/* --------------------------------------------------------------------------
   7. Progress — "Step n of N" + gradient bar; refine the numbered circles
   -------------------------------------------------------------------------- */
body.fill-modern .fm-progress {
    margin: 4px 0 18px;
}
body.fill-modern .fm-progress .fm-progress-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--fm-muted);
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: 0.02em;
}
body.fill-modern .fm-progress .fm-progress-track {
    height: 6px;
    border-radius: 6px;
    background: var(--fm-border);
    overflow: hidden;
}
body.fill-modern .fm-progress .fm-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    background: var(--fm-gradient);
    transition: width .35s ease;
}
/* hide progress UI for single-page forms (JS sets data attr) */
body.fill-modern .fm-progress[data-steps="1"] {
    display: none;
}

/* numbered circles: keep on tablets/desktop, hide on small phones (bar carries it) */
@media (max-width: 575.98px) {
    body.fill-modern .extra_style {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   8. Navigation buttons — sticky bottom bar on phones
   -------------------------------------------------------------------------- */
body.fill-modern .over-auto {
    margin-top: 20px;
}

body.fill-modern #nextBtn,
body.fill-modern #prevBtn {
    min-height: 48px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 600;
    padding: 10px 26px;
    border: 0;
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease;
}

body.fill-modern #nextBtn {
    background: var(--fm-accent) !important;
    color: #fff !important;
    margin-left: auto;          /* stays right when prevBtn is display:none */
    box-shadow: 0 4px 14px var(--fm-accent-soft);
}
body.fill-modern #nextBtn:hover:not(:disabled) {
    background: var(--fm-gradient) !important;
    transform: translateY(-1px);
}
body.fill-modern #nextBtn:disabled,
body.fill-modern #nextBtn.btn-loading {
    opacity: .65;
    cursor: not-allowed;
}

body.fill-modern #prevBtn {
    background: transparent !important;
    color: var(--fm-muted) !important;
    border: 1.5px solid var(--fm-border) !important;
}
body.fill-modern #prevBtn:hover:not(:disabled) {
    border-color: var(--fm-accent) !important;
    color: var(--fm-accent) !important;
}

@media (max-width: 575.98px) {
    body.fill-modern .over-auto {
        position: sticky;
        bottom: 0;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(6px);
        border-top: 1px solid var(--fm-border);
        margin: 20px -20px 0;          /* bleed to card edge */
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
        z-index: 20;
    }
    body.fill-modern #nextBtn {
        flex: 1 1 auto;
    }
    body.fill-modern #prevBtn {
        flex: 0 0 auto;
    }
}

/* --------------------------------------------------------------------------
   9. Success screen (post-submit email/WhatsApp card)
   -------------------------------------------------------------------------- */
body.fill-modern .fm-success-icon {
    width: 64px;
    height: 64px;
    margin: 8px auto 14px;
    border-radius: 50%;
    background: var(--fm-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

/* --------------------------------------------------------------------------
   9b. "Made with" site footer under the card (free-plan forms)
   -------------------------------------------------------------------------- */
body.fill-modern .fm-site-footer {
    text-align: center;
    font-size: 13px;
    color: var(--fm-muted);
    margin: 16px auto 28px;
    padding: 0 12px;
    max-width: 640px;
    line-height: 1.6;
}
body.fill-modern .fm-site-footer a {
    color: var(--fm-accent);
    font-weight: 600;
    text-decoration: none;
}
body.fill-modern .fm-site-footer a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   10. Legacy layout-theme cohabitation + desktop
   -------------------------------------------------------------------------- */
/* theme3 background image stays; keep the card readable on top */
body.fill-modern.bg-back .card {
    background: rgba(255, 255, 255, 0.96);
}

/* decorative newform shapes can collide with the card on phones — soften */
@media (max-width: 575.98px) {
    body.fill-modern .section-body.newform-3::before,
    body.fill-modern .section-body.newform-3::after,
    body.fill-modern .section-body.circle::before,
    body.fill-modern .section-body.circle::after,
    body.fill-modern .section-body.circle-custom::before,
    body.fill-modern .section-body.circle-custom::after {
        display: none;
    }
}

/* colored card-header themes (newform-1/-4/-5): title must stay legible */
body.fill-modern .section-body[class*="newform"] .card .card-header h5 {
    color: var(--fm-ink) !important;
}

/* circle themes keep their colored oval behind the title — use white text */
body.fill-modern .section-body.circle .card .card-header h5,
body.fill-modern .section-body.circle-custom .card .card-header h5 {
    color: #fff !important;
}

@media (min-width: 768px) {
    body.fill-modern .card .card-body,
    body.fill-modern .card .form-card-body {
        padding: 40px;
    }
    body.fill-modern .card .card-header {
        padding: 40px 40px 0;
    }
    body.fill-modern .card .card-header h5 {
        font-size: 36px;
    }
    body.fill-modern .section-body .mx-auto.col-md-7 {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Touch device reporting a wide viewport ("Desktop site" mode on a phone):
   the browser scales the whole layout down, so bump sizes to stay readable. */
@media (pointer: coarse) and (min-width: 768px) and (max-width: 1100px) {
    body.fill-modern .form-control,
    body.fill-modern .form-select {
        min-height: 56px;
        font-size: 19px;
    }
    body.fill-modern .form-label,
    body.fill-modern label {
        font-size: 17px;
    }
    body.fill-modern .form-check {
        min-height: 56px;
        padding-top: 16px;
        padding-bottom: 16px;
    }
    body.fill-modern .form-check label,
    body.fill-modern .form-check .form-check-label {
        font-size: 18px;
    }
    body.fill-modern #nextBtn,
    body.fill-modern #prevBtn {
        min-height: 56px;
        font-size: 19px;
    }
    body.fill-modern .fm-progress .fm-progress-label {
        font-size: 16px;
    }
}
