/* Mason1 Assistant — floating chat */

.m1-chat-root {
    --m1c-navy: #071d3b;
    --m1c-navy-2: #0a2c5c;
    --m1c-blue: #1767ed;
    --m1c-ink: #08182d;
    --m1c-muted: #5d6c7f;
    --m1c-line: #d5e1ef;
    --m1c-panel: #ffffff;
    --m1c-soft: #f3f7fc;
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1080;
    font-family: "Aptos", "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

.m1-chat-launcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, #6ba7ff 0%, transparent 42%),
        linear-gradient(145deg, #0a55cc 0%, var(--m1c-navy) 58%, #0b2145 100%);
    color: #fff;
    box-shadow:
        0 14px 36px #071d3b55,
        inset 0 1px 0 #ffffff40;
    cursor: pointer;
    transition: transform .22s ease, box-shadow .22s ease;
}

.m1-chat-launcher:hover,
.m1-chat-launcher:focus-visible {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 18px 42px #071d3b66;
    outline: none;
}

.m1-chat-launcher[aria-expanded="true"] {
    transform: rotate(0deg);
}

.m1-chat-launcher svg {
    width: 28px;
    height: 28px;
}

.m1-chat-launcher-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #4d9aff88;
    animation: m1ChatPulse 2.4s ease-out infinite;
    pointer-events: none;
}

.m1-chat-launcher[aria-expanded="true"] .m1-chat-launcher-pulse {
    display: none;
}

@keyframes m1ChatPulse {
    0% { transform: scale(.92); opacity: .9; }
    100% { transform: scale(1.35); opacity: 0; }
}

.m1-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #47d69a;
    color: #042816;
    font-size: .65rem;
    font-weight: 800;
    line-height: 18px;
    box-shadow: 0 0 0 3px #fff;
}

.m1-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    display: flex;
    flex-direction: column;
    width: min(392px, calc(100vw - 1.5rem));
    height: min(560px, calc(100vh - 6rem));
    overflow: hidden;
    border: 1px solid #b8cce4;
    border-radius: 22px;
    background: var(--m1c-panel);
    box-shadow: 0 28px 70px #03112755;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
}

.m1-chat-panel.has-form {
    height: min(540px, calc(100vh - 5.5rem));
}

.m1-chat-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.m1-chat-header {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    background: linear-gradient(135deg, var(--m1c-navy) 0%, var(--m1c-navy-2) 52%, #12407a 100%);
    color: #fff;
    flex-shrink: 0;
}

.m1-chat-avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, #8fc0ff 0, transparent 45%),
        linear-gradient(160deg, #2d7cff, #0a3f8f);
    box-shadow: inset 0 1px 0 #ffffff55, 0 8px 18px #00000033;
    overflow: hidden;
}

.m1-chat-avatar svg {
    width: 22px;
    height: 22px;
}

.m1-chat-online {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border: 2px solid #0a2c5c;
    border-radius: 50%;
    background: #47d69a;
}

.m1-chat-header-copy strong {
    display: block;
    font-size: .98rem;
    font-weight: 750;
    letter-spacing: -.01em;
}

.m1-chat-header-copy span {
    display: block;
    margin-top: .15rem;
    color: #9eb6d4;
    font-size: .74rem;
}

.m1-chat-close {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: 1px solid #ffffff2e;
    border-radius: 10px;
    background: #ffffff14;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.m1-chat-close:hover {
    background: #ffffff28;
}

.m1-chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: .85rem .8rem 1rem;
    background:
        radial-gradient(circle at 100% 0%, #dce9ff66 0, transparent 40%),
        var(--m1c-soft);
    scrollbar-width: thin;
}

.m1-chat-panel.has-form .m1-chat-body {
    display: flex;
    flex-direction: column;
    padding: .55rem .65rem .65rem;
    overflow: hidden;
}

.m1-chat-form-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.m1-chat-form-toolbar {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .45rem;
    flex-shrink: 0;
}

.m1-chat-form-toolbar strong {
    color: var(--m1c-navy);
    font-size: .82rem;
    font-weight: 750;
}

.m1-chat-back {
    border: 1px solid #b7cce6;
    border-radius: 999px;
    background: #fff;
    color: #0a55cc;
    font-size: .72rem;
    font-weight: 700;
    padding: .28rem .65rem;
    cursor: pointer;
}

.m1-chat-back:hover {
    background: #eef5ff;
}

.m1-chat-form-lead {
    margin: 0 0 .55rem;
    color: var(--m1c-muted);
    font-size: .74rem;
    line-height: 1.35;
}

.m1-chat-msg {
    display: flex;
    gap: .55rem;
    margin-bottom: .9rem;
    max-width: 100%;
}

.m1-chat-msg-bot {
    align-items: flex-start;
}

.m1-chat-msg-user {
    justify-content: flex-end;
}

.m1-chat-msg-avatar {
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-top: .15rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #2d7cff, #0a3f8f);
    color: #fff;
}

.m1-chat-msg-avatar svg {
    width: 15px;
    height: 15px;
}

.m1-chat-bubble {
    max-width: 86%;
    padding: .75rem .9rem;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--m1c-ink);
}

.m1-chat-msg-bot .m1-chat-bubble {
    border: 1px solid #c9d8ea;
    border-top-left-radius: 5px;
    background: #fff;
    box-shadow: 0 8px 20px #071d3b0d;
}

.m1-chat-msg-user .m1-chat-bubble {
    border-top-right-radius: 5px;
    background: linear-gradient(145deg, #1767ed, #0a55cc);
    color: #fff;
}

.m1-chat-bubble p {
    margin: 0 0 .55rem;
}

.m1-chat-bubble p:last-child {
    margin-bottom: 0;
}

.m1-chat-choices {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    margin-top: .7rem;
}

.m1-chat-choice {
    display: block;
    width: 100%;
    padding: .7rem .85rem;
    border: 1px solid #b7cce6;
    border-radius: 12px;
    background: #f8fbff;
    color: var(--m1c-navy);
    font-size: .84rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: .18s ease;
}

.m1-chat-choice:hover,
.m1-chat-choice:focus-visible {
    border-color: #4d91ff;
    background: #eef5ff;
    outline: none;
    transform: translateX(2px);
}

.m1-chat-choice small {
    display: block;
    margin-top: .2rem;
    color: var(--m1c-muted);
    font-size: .72rem;
    font-weight: 550;
}

.m1-chat-form {
    margin-top: .35rem;
}

.m1-chat-form.m1-chat-form-compact {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: .7rem .75rem .75rem;
    border: 1px solid #c9d8ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 20px #071d3b0d;
    overflow-x: hidden;
    overflow-y: auto;
}

.m1-chat-form .m1-field {
    margin-bottom: .65rem;
}

.m1-chat-form.m1-chat-form-compact .m1-field {
    margin-bottom: .4rem;
}

.m1-chat-form label {
    display: block;
    margin-bottom: .28rem;
    color: #394b63;
    font-size: .72rem;
    font-weight: 750;
}

.m1-chat-form.m1-chat-form-compact label {
    margin-bottom: .15rem;
    font-size: .65rem;
    letter-spacing: .02em;
}

.m1-chat-form input,
.m1-chat-form select,
.m1-chat-form textarea {
    width: 100%;
    padding: .58rem .7rem;
    border: 1px solid #c9d5e3;
    border-radius: 8px;
    background: #fff;
    color: var(--m1c-ink);
    font-size: .84rem;
}

.m1-chat-form.m1-chat-form-compact input,
.m1-chat-form.m1-chat-form-compact select {
    padding: .42rem .55rem;
    border-radius: 7px;
    font-size: .78rem;
    line-height: 1.25;
}

.m1-chat-form input:focus,
.m1-chat-form select:focus,
.m1-chat-form textarea:focus {
    border-color: #0a5cdc;
    box-shadow: 0 0 0 .15rem #1d66f51f;
    outline: none;
}

.m1-chat-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
}

.m1-chat-form.m1-chat-form-compact .m1-chat-form-row {
    gap: .4rem;
}

.m1-chat-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: .25rem;
    padding: .72rem .9rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #1767ed, #0a55cc);
    color: #fff;
    font-size: .88rem;
    font-weight: 750;
    cursor: pointer;
}

.m1-chat-form.m1-chat-form-compact .m1-chat-submit {
    margin-top: auto;
    padding: .55rem .75rem;
    font-size: .8rem;
    border-radius: 10px;
}

.m1-chat-submit:hover:not(:disabled) {
    filter: brightness(1.06);
}

.m1-chat-submit:disabled {
    opacity: .65;
    cursor: wait;
}

.m1-chat-error {
    margin: .35rem 0 .55rem;
    padding: .55rem .7rem;
    border-radius: 8px;
    background: #fff1f1;
    color: #8a1f1f;
    font-size: .78rem;
}

.m1-chat-form.m1-chat-form-compact .m1-chat-error {
    margin: .2rem 0 .35rem;
    padding: .4rem .55rem;
    font-size: .72rem;
}

.m1-chat-success-note {
    margin-top: .45rem;
    color: #1a6b47;
    font-size: .8rem;
    font-weight: 650;
}

.m1-chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: .55rem .75rem;
}

.m1-chat-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7a93b0;
    animation: m1ChatDot 1.1s infinite ease-in-out;
}

.m1-chat-typing i:nth-child(2) { animation-delay: .15s; }
.m1-chat-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes m1ChatDot {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.m1-chat-footer {
    padding: .4rem .8rem .5rem;
    border-top: 1px solid var(--m1c-line);
    background: #fff;
    color: #748296;
    font-size: .64rem;
    text-align: center;
    flex-shrink: 0;
}

.m1-chat-footer button {
    border: 0;
    background: none;
    color: #0a55cc;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.m1-chat-hp {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 575.98px) {
    .m1-chat-root {
        right: .85rem;
        bottom: .85rem;
    }

    .m1-chat-panel {
        position: fixed;
        right: .65rem;
        bottom: 5.1rem;
        width: calc(100vw - 1.3rem);
        height: min(78vh, 560px);
        border-radius: 18px;
    }

    .m1-chat-panel.has-form {
        height: min(82vh, 580px);
    }

    .m1-chat-form-row {
        grid-template-columns: 1fr 1fr;
    }
}
@media (prefers-reduced-motion: reduce) {
    .m1-chat-launcher-pulse,
    .m1-chat-typing i {
        animation: none;
    }

    .m1-chat-panel,
    .m1-chat-launcher {
        transition: none;
    }
}
