/* Roof Dispatch AI — website assistant */
.rda-chat-launcher {
    position: fixed;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.65rem;
    font-family: 'Inter', system-ui, sans-serif;
}
.rda-chat-open-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 1.15rem;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, #D4A843, #B8902E);
    color: #0A0A0A;
    font-family: 'Big Shoulders Display', Impact, sans-serif;
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(212,168,67,0.4);
    transition: transform 0.25s, box-shadow 0.25s;
    z-index: 1;
}
.rda-chat-open-btn::before,
.rda-chat-open-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    pointer-events: none;
    z-index: -1;
}
.rda-chat-open-btn::before {
    box-shadow: 0 0 0 0 rgba(212,168,67,0.45);
    animation: rdaBtnPulse 2.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.rda-chat-open-btn::after {
    inset: -3px;
    border: 1px solid rgba(212,168,67,0.35);
    opacity: 0.6;
    animation: rdaBtnRing 2.8s ease-out infinite;
}
@keyframes rdaBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212,168,67,0.42); }
    50% { box-shadow: 0 0 0 12px rgba(212,168,67,0); }
}
@keyframes rdaBtnRing {
    0% { transform: scale(1); opacity: 0.55; }
    70%, 100% { transform: scale(1.22); opacity: 0; }
}
.rda-chat-open-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(212,168,67,0.5);
}
.rda-chat-open-btn svg { flex-shrink: 0; }
.rda-chat-open-label-short { display: none; }
.rda-chat-open-label-full { display: inline; }
.rda-chat-panel {
    width: min(100vw - 1.5rem, 32rem);
    max-height: min(80vh, 42rem);
    border-radius: 1.15rem;
    border: 1px solid rgba(212,168,67,0.28);
    background: linear-gradient(165deg, #141414, #0A0A0A);
    box-shadow: 0 24px 64px rgba(0,0,0,0.65);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}
.rda-chat-panel.open {
    display: flex;
    animation: rdaChatIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rdaChatIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.rda-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.95rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(212,168,67,0.06);
    flex-shrink: 0;
    position: relative;
}
.rda-chat-mobile-handle {
    display: none;
}
.rda-chat-head-info strong {
    display: block;
    font-family: 'Big Shoulders Display', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
}
.rda-chat-head-info span {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
}
.rda-chat-close {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: rgba(255,255,255,0.55);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.rda-chat-close:hover { color: #D4A843; border-color: rgba(212,168,67,0.35); }

/* Body: left suggestions + main conversation */
.rda-chat-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.rda-chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
}
.rda-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.rda-chat-msg {
    max-width: 94%;
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
}
.rda-chat-msg.user {
    align-self: flex-end;
    background: rgba(212,168,67,0.18);
    border: 1px solid rgba(212,168,67,0.28);
    color: #fff;
}
.rda-chat-msg.assistant {
    align-self: flex-start;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.85);
}
.rda-chat-msg.assistant .rda-md-body > *:first-child { margin-top: 0; }
.rda-chat-msg.assistant .rda-md-body > *:last-child { margin-bottom: 0; }
.rda-chat-md-h1 {
    font-family: 'Big Shoulders Display', Impact, sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    margin: 0.65rem 0 0.4rem;
    line-height: 1.2;
}
.rda-chat-md-h2 {
    font-family: 'Big Shoulders Display', Impact, sans-serif;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gold-light, #FFE599);
    margin: 0.55rem 0 0.35rem;
    line-height: 1.25;
}
.rda-chat-md-h3 {
    font-family: 'Big Shoulders Display', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.78);
    margin: 0.45rem 0 0.25rem;
}
.rda-chat-md-p {
    margin: 0.35rem 0;
    line-height: 1.6;
}
.rda-chat-md-ul {
    margin: 0.4rem 0 0.5rem;
    padding-left: 1.1rem;
    list-style: none;
}
.rda-chat-md-ul li {
    position: relative;
    margin: 0.28rem 0;
    padding-left: 0.15rem;
    line-height: 1.55;
}
.rda-chat-md-ul li::before {
    content: '◆';
    position: absolute;
    left: -1rem;
    color: var(--gold, #D4A843);
    font-size: 0.45rem;
    top: 0.45em;
}
.rda-chat-msg.assistant strong {
    color: #fff;
    font-weight: 700;
}
.rda-chat-md-label {
    color: var(--gold-light, #FFE599);
    font-weight: 700;
}
.rda-chat-msg.assistant em {
    color: rgba(255,255,255,0.72);
    font-style: italic;
}
.rda-chat-msg.assistant a {
    color: #D4A843;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
}
.rda-chat-msg.typing {
    color: rgba(255,255,255,0.45);
    font-style: italic;
}
.rda-chat-starters {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 7.5rem;
    flex-shrink: 0;
    padding: 0.75rem 0.55rem;
    border-right: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.22);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.rda-chat-starters::before {
    content: 'Try';
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    margin-bottom: 0.15rem;
    padding-left: 0.15rem;
}
.rda-chat-starter {
    padding: 0.5rem 0.55rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(212,168,67,0.22);
    background: rgba(212,168,67,0.05);
    color: rgba(255,255,255,0.62);
    font-size: 0.65rem;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-family: inherit;
    text-align: left;
    width: 100%;
}
.rda-chat-starter:hover {
    background: rgba(212,168,67,0.14);
    color: #D4A843;
    border-color: rgba(212,168,67,0.35);
}

/* Collapse sidebar after conversation starts — more room for answers */
.rda-chat-panel.rda-chat-starters-collapsed .rda-chat-starters {
    width: 0;
    padding: 0;
    border: none;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}
.rda-chat-form {
    display: flex;
    gap: 0.55rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.35);
    flex-shrink: 0;
}
.rda-chat-input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.85rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 0.92rem;
    font-family: inherit;
    resize: none;
    line-height: 1.45;
    max-height: 6rem;
}
.rda-chat-input:focus {
    outline: none;
    border-color: rgba(212,168,67,0.4);
}
.rda-chat-send {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 0.65rem;
    background: #D4A843;
    color: #0A0A0A;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.rda-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }
.rda-chat-foot {
    padding: 0.4rem 1rem 0.75rem;
    font-size: 0.62rem;
    color: rgba(255,255,255,0.28);
    text-align: center;
    flex-shrink: 0;
}
.rda-chat-foot a { color: #D4A843; }

/* Scroll invite overlay */
.rda-chat-invite {
    position: fixed;
    inset: 0;
    z-index: 9995;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(0,0,0,0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s;
}
.rda-chat-invite.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.rda-chat-invite-card {
    position: relative;
    width: min(100%, 22rem);
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(212,168,67,0.35);
    background: linear-gradient(165deg, rgba(212,168,67,0.12), rgba(10,10,10,0.98));
    box-shadow: 0 32px 80px rgba(0,0,0,0.65), 0 0 0 1px rgba(212,168,67,0.08) inset;
    text-align: center;
    animation: rdaInvitePop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rdaInvitePop {
    from { opacity: 0; transform: scale(0.9) translateY(16px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.rda-chat-invite-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.35);
    color: rgba(255,255,255,0.55);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.rda-chat-invite-close:hover { color: #D4A843; border-color: rgba(212,168,67,0.4); }
.rda-chat-invite-icon {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(212,168,67,0.15);
    border: 1px solid rgba(212,168,67,0.35);
    animation: rdaInviteFloat 3s ease-in-out infinite;
}
@keyframes rdaInviteFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
.rda-chat-invite-card h3 {
    font-family: 'Big Shoulders Display', Impact, sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    margin-bottom: 0.5rem;
}
.rda-chat-invite-card p {
    font-size: 0.88rem;
    line-height: 1.65;
    color: rgba(255,255,255,0.62);
    margin-bottom: 1.15rem;
}
.rda-chat-invite-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.8rem 1.35rem;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, #D4A843, #B8902E);
    color: #0A0A0A;
    font-family: 'Big Shoulders Display', sans-serif;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(212,168,67,0.35);
    transition: transform 0.2s;
}
.rda-chat-invite-open:hover { transform: translateY(-2px); }

@media (max-width: 640px) {
    body.rda-chat-active {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    .rda-chat-launcher {
        bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
        right: max(0.85rem, env(safe-area-inset-right, 0px));
        left: auto;
        align-items: flex-end;
    }

    .rda-chat-launcher.rda-chat-panel-open .rda-chat-open-btn {
        display: none;
    }

    .rda-chat-panel {
        position: fixed;
        inset: 0;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: none;
        height: 100dvh;
        border-radius: 0;
        border: none;
        z-index: 9999;
        transform-origin: center center;
        box-shadow: none;
    }

    .rda-chat-panel.open {
        animation: rdaChatMobileIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    }

    @keyframes rdaChatMobileIn {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .rda-chat-head {
        display: grid;
        grid-template-areas:
            "handle handle"
            "info close";
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 0 0.75rem;
        padding: 0.65rem 1rem 0.85rem;
        padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
        background: linear-gradient(180deg, rgba(212,168,67,0.1), rgba(10,10,10,0.98));
    }

    .rda-chat-mobile-handle {
        display: block;
        grid-area: handle;
        width: 2.5rem;
        height: 0.22rem;
        margin: 0.15rem auto 0.65rem;
        border-radius: 9999px;
        background: rgba(255,255,255,0.22);
    }

    .rda-chat-head-info {
        grid-area: info;
        text-align: left;
    }

    .rda-chat-head-info strong {
        font-size: 1.05rem;
    }

    .rda-chat-head-info span {
        font-size: 0.78rem;
    }

    .rda-chat-close {
        grid-area: close;
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.35rem;
    }

    .rda-chat-body {
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    .rda-chat-messages {
        padding: 1rem 1.1rem;
        gap: 0.9rem;
    }

    .rda-chat-msg {
        max-width: 92%;
        font-size: 0.95rem;
        line-height: 1.62;
        padding: 0.9rem 1rem;
    }

    .rda-chat-md-h1 { font-size: 1.2rem; }
    .rda-chat-md-h2 { font-size: 1.05rem; }
    .rda-chat-md-h3 { font-size: 0.95rem; }

    .rda-chat-starters {
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
        padding: 0.65rem 0.85rem;
        gap: 0.45rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .rda-chat-starters::-webkit-scrollbar { display: none; }

    .rda-chat-starters::before {
        display: none;
    }

    .rda-chat-starter {
        flex: 0 0 auto;
        width: auto;
        max-width: 13rem;
        white-space: normal;
        font-size: 0.72rem;
        border-radius: 9999px;
        padding: 0.5rem 0.85rem;
    }

    .rda-chat-panel.rda-chat-starters-collapsed .rda-chat-starters {
        display: none;
    }

    .rda-chat-form {
        padding: 0.75rem 0.85rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
        background: rgba(8,8,8,0.98);
        border-top: 1px solid rgba(212,168,67,0.15);
        gap: 0.6rem;
    }

    .rda-chat-panel.rda-chat-keyboard-open .rda-chat-foot {
        display: none;
    }

    .rda-chat-panel.rda-chat-keyboard-open .rda-chat-form {
        padding-bottom: 0.65rem;
        box-shadow: 0 -8px 24px rgba(0,0,0,0.45);
    }

    .rda-chat-input {
        font-size: 16px; /* prevents iOS zoom */
        padding: 0.75rem 0.9rem;
        min-height: 2.75rem;
    }

    .rda-chat-send {
        width: 2.85rem;
        height: 2.85rem;
    }

    .rda-chat-foot {
        font-size: 0.65rem;
        padding: 0.45rem 0.85rem 0.65rem;
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
    }

    .rda-chat-open-btn {
        padding: 0.85rem 1.1rem;
        font-size: 0.72rem;
    }

    .rda-chat-open-label-short { display: none; }
    .rda-chat-open-label-full { display: inline; }

    @media (max-width: 380px) {
        .rda-chat-open-label-full { display: none; }
        .rda-chat-open-label-short { display: inline; }
    }
}

@media (prefers-reduced-motion: reduce) {
    .rda-chat-open-btn::before,
    .rda-chat-open-btn::after,
    .rda-chat-invite-icon { animation: none; }
    .rda-chat-panel.open,
    .rda-chat-invite-card { animation: none; }
}
