/* =========================================================
   "Schedule a Demo" popup (partials/demo-popup.blade.php)
   Every size, colour and offset below is taken from the Billgenix popup
   Figma frame (818 x 536). Desktop matches it 1:1; tablet/mobile reflow.
   ========================================================= */

html.demo-popup-open,
html.demo-popup-open body {
    overflow: hidden;
}

.demo-popup {
    position: fixed;
    inset: 0;
    /* Above the third-party chat widget (z-index 2000000000). */
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: "DM Sans", sans-serif;
}

.demo-popup[hidden] {
    display: none;
}

.demo-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 20, 20, 0.62);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.demo-popup.is-visible .demo-popup-backdrop {
    opacity: 1;
}

/* Frame: BG gradient + line pattern (exported from the Figma layers). */
.demo-popup-dialog {
    position: relative;
    display: grid;
    grid-template-columns: 297px minmax(0, 1fr);
    width: 100%;
    max-width: 818px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
    background: #1c2828 url("./images/popup/demo-popup-bg.svg") center / 100% 100% no-repeat;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(40px) scale(0.92);
}

/* ---------- In / out animation ----------
   In:  backdrop fades, dialog springs up, photo slides from the left, header from
        the right, then fields and button rise one after another.
   Out: everything shrinks and fades down together (faster, so it never blocks). */
.demo-popup.is-visible .demo-popup-dialog {
    opacity: 1;
    transform: none;
    transition: opacity 0.35s ease, transform 0.6s cubic-bezier(0.22, 1.25, 0.36, 1);
}

/* Children start hidden only while the popup is closed (not while it animates out). */
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-media,
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-header,
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-field,
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-submit {
    opacity: 0;
}

.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-media { transform: translateX(-28px); }
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-header { transform: translateX(28px); }
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-field,
.demo-popup:not(.is-visible):not(.is-closing) .demo-popup-submit { transform: translateY(14px); }

/* Staggered entrance; "is-entering" is removed once it finishes so hover/press stay snappy. */
.demo-popup.is-entering .demo-popup-media,
.demo-popup.is-entering .demo-popup-header,
.demo-popup.is-entering .demo-popup-field,
.demo-popup.is-entering .demo-popup-submit {
    transition: opacity 0.45s ease var(--dp-delay, 0s), transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) var(--dp-delay, 0s);
}

.demo-popup.is-entering .demo-popup-media { --dp-delay: 0.12s; }
.demo-popup.is-entering .demo-popup-header { --dp-delay: 0.18s; }
.demo-popup.is-entering .demo-popup-field:nth-child(1) { --dp-delay: 0.26s; }
.demo-popup.is-entering .demo-popup-field:nth-child(2) { --dp-delay: 0.30s; }
.demo-popup.is-entering .demo-popup-field:nth-child(3) { --dp-delay: 0.34s; }
.demo-popup.is-entering .demo-popup-field:nth-child(4) { --dp-delay: 0.38s; }
.demo-popup.is-entering .demo-popup-field:nth-child(5) { --dp-delay: 0.42s; }
.demo-popup.is-entering .demo-popup-field:nth-child(6) { --dp-delay: 0.46s; }
.demo-popup.is-entering .demo-popup-field:nth-child(7) { --dp-delay: 0.50s; }
.demo-popup.is-entering .demo-popup-submit { --dp-delay: 0.56s; }

.demo-popup.is-closing .demo-popup-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.demo-popup.is-closing .demo-popup-dialog {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.55, 0, 0.75, 0.3);
}

/* Left column: photo (top-right radius 50) + logo bar (top-right radius 33). */
.demo-popup-media {
    position: relative;
    overflow: hidden;
    border-top-right-radius: 50px;
}

.demo-popup-media > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.demo-popup-brand {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 66px;
    background: linear-gradient(270deg, #0f7072 0%, #031515 58.17%, #000000 100%);
    border-top-right-radius: 33px;
}

.demo-popup-brand img {
    position: absolute;
    top: 12px;
    left: 69px;
    display: block;
    width: 159px;
    height: 42px;
}

/* Right column */
.demo-popup-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-left: 21px;
    color: #ffffff;
    /* Scroll container on short screens; header stays pinned at the top. */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.demo-popup-header {
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
    height: 66px;
    background: linear-gradient(90deg, #0f7072 0%, #031515 58.17%, #000000 100%);
    border-bottom-left-radius: 24px;
}

.demo-popup-header h2 {
    position: absolute;
    top: 22.7px;
    left: 24px;
    margin: 0;
    color: #d9d9d9;
    font-size: 24px;
    font-weight: 900;
    line-height: 0.8814;
    letter-spacing: -0.09em;
    white-space: nowrap;
}

.demo-popup-close {
    position: absolute;
    top: 17px;
    right: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: #ffffff;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.demo-popup-close:hover,
.demo-popup-close:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.demo-popup-close svg {
    width: 12px;
    height: 11.3px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.11;
    stroke-linecap: round;
}

/* Form: 477px wide, two 224px columns 29px apart. */
.demo-popup-form {
    width: 100%;
    max-width: 500px;
    padding: 42px 23px 49px 0;
}

.demo-popup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 29.4px;
    row-gap: 13.3px;
}

.demo-popup-field-full {
    grid-column: 1 / -1;
    margin-top: 3.4px;
}

.demo-popup-field label {
    display: block;
    height: 14px;
    margin-bottom: 9.8px;
    color: #ffffff;
    font-size: 12.47px;
    font-weight: 700;
    line-height: 14px;
}

.demo-popup-field input,
.demo-popup-field select,
.demo-popup-field textarea {
    display: block;
    width: 100%;
    height: 38.5px;
    padding: 0 14.7px;
    color: #1d1d1d;
    background: #ffffff;
    border: 1.92px solid #009a9a;
    border-radius: 8.63px;
    font-family: inherit;
    font-size: 11.2px;
    font-weight: 400;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.demo-popup-field textarea {
    height: 61.6px;
    padding: 12px 11.9px;
    font-size: 10.55px;
    line-height: 1.3;
    resize: vertical;
}

.demo-popup-field input::placeholder,
.demo-popup-field textarea::placeholder {
    color: #9e9e9e;
    opacity: 1;
}

.demo-popup-field input:focus,
.demo-popup-field select:focus,
.demo-popup-field textarea:focus {
    border-color: #ff4b1b;
    box-shadow: 0 0 0 3px rgba(255, 75, 27, 0.18);
}

.demo-popup-field input.is-invalid {
    border-color: #ff6b6b;
}

.demo-popup-phone {
    position: relative;
}

.demo-popup-phone svg {
    position: absolute;
    top: 50%;
    left: 14.5px;
    width: 20px;
    height: 13px;
    transform: translateY(-50%);
    pointer-events: none;
}

.demo-popup-phone input {
    padding-left: 45.5px;
}

.demo-popup-select {
    position: relative;
}

.demo-popup-select::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 13px;
    border-top: 3.5px solid #9e9e9e;
    border-right: 3.5px solid transparent;
    border-left: 3.5px solid transparent;
    transform: translateY(-50%);
    pointer-events: none;
}

.demo-popup-select select {
    padding-left: 16.3px;
    padding-right: 30px;
    color: #535353;
    font-size: 10.55px;
    font-weight: 600;
    appearance: none;
    cursor: pointer;
}

.demo-popup-error {
    display: block;
    margin-top: 4px;
    color: #ffd2c4;
    font-size: 11px;
    line-height: 1.2;
}

.demo-popup-error:empty {
    display: none;
}

.demo-popup-status {
    margin-top: 14px;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 12.5px;
    line-height: 1.4;
}

.demo-popup-status.is-success {
    color: #ffffff;
    background: rgba(0, 154, 154, 0.35);
    border: 1px solid #5fe0d6;
}

.demo-popup-status.is-error {
    color: #ffffff;
    background: rgba(255, 75, 27, 0.25);
    border: 1px solid #ff6b45;
}

.demo-popup-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2.8px;
    width: 100%;
    height: 42px;
    margin-top: 20.7px;
    color: #ffffff;
    background: linear-gradient(180deg, #f46f4b 0%, #ff4b1b 100%);
    border: 0.7px solid #000000;
    border-radius: 32.9px;
    font-family: inherit;
    font-size: 12.6px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.demo-popup-submit span {
    padding-right: 4px;
}

.demo-popup-submit:hover {
    filter: brightness(1.06);
}

.demo-popup-submit:active {
    transform: translateY(1px);
}

.demo-popup-submit:disabled {
    opacity: 0.75;
    cursor: wait;
}

.demo-popup-submit svg {
    width: 14px;
    height: 10px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Tablet: drop the photo, header spans the full width. */
@media (max-width: 860px) {
    .demo-popup-dialog {
        grid-template-columns: minmax(0, 1fr);
        max-width: 560px;
        background-size: cover;
    }

    .demo-popup-media {
        display: none;
    }

    .demo-popup-panel {
        padding-left: 0;
    }

    .demo-popup-header {
        border-bottom-left-radius: 0;
    }

    .demo-popup-form {
        max-width: none;
        padding: 30px 23px 32px;
    }
}

/* Mobile: single column, larger tap targets (16px inputs avoid iOS zoom). */
@media (max-width: 575px) {
    .demo-popup {
        padding: 12px;
    }

    .demo-popup-dialog,
    .demo-popup-panel {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
    }

    .demo-popup-header {
        height: 56px;
    }

    .demo-popup-header h2 {
        top: 18px;
        left: 18px;
        font-size: 22px;
    }

    .demo-popup-close {
        top: 13px;
        right: 10px;
    }

    .demo-popup-form {
        padding: 20px 16px 22px;
    }

    .demo-popup-grid {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 12px;
    }

    .demo-popup-field-full {
        margin-top: 0;
    }

    .demo-popup-field input,
    .demo-popup-field select {
        height: 42px;
        font-size: 16px;
    }

    .demo-popup-field textarea {
        font-size: 16px;
    }

    .demo-popup-select select {
        font-size: 14px;
    }

    .demo-popup-submit {
        height: 46px;
        font-size: 14px;
    }
}

/* Respect reduced-motion: simple fade only, no movement. */
@media (prefers-reduced-motion: reduce) {
    .demo-popup .demo-popup-dialog,
    .demo-popup .demo-popup-media,
    .demo-popup .demo-popup-header,
    .demo-popup .demo-popup-field,
    .demo-popup .demo-popup-submit {
        transform: none !important;
        transition-duration: 0.2s !important;
        transition-delay: 0s !important;
    }
}
