/* Global finance chat widget (FAB + modal panel) */

.site-chat-widget {
    position: fixed;
    right: max(28px, env(safe-area-inset-right));
    bottom: max(28px, env(safe-area-inset-bottom));
    z-index: 1200;
}

.site-chat-widget__fab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 16px 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 138, 22, 0.82) 0%, rgba(249, 115, 22, 0.82) 100%);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(249, 115, 22, 0.42);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(.2, .8, .2, 1), box-shadow 0.3s, background 0.3s, border-color 0.3s;
    animation: chat-fab-fade 0.5s ease both, chat-fab-float 3.6s ease-in-out 0.5s infinite;
}

.site-chat-widget__fab::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5);
    animation: chat-fab-pulse 2.6s ease-out 1s infinite;
    pointer-events: none;
}

.site-chat-widget__fab:hover {
    transform: translateY(-3px) scale(1.04);
    border-color: rgba(255, 255, 255, 0.45);
    background: linear-gradient(135deg, rgba(255, 138, 22, 0.96) 0%, rgba(249, 115, 22, 0.96) 100%);
    box-shadow: 0 18px 38px rgba(249, 115, 22, 0.55);
}

.site-chat-widget__fab:active {
    transform: translateY(-1px) scale(1.01);
}

@keyframes chat-fab-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes chat-fab-float {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -5px; }
}

@keyframes chat-fab-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5); opacity: 0.85; }
    70%  { box-shadow: 0 0 0 18px rgba(249, 115, 22, 0); opacity: 0; }
    100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .site-chat-widget__fab,
    .site-chat-widget__fab::before {
        animation: none !important;
    }
}

.site-chat-widget__fab-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    font-size: 1rem;
    line-height: 1;
}

.site-chat-widget__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1199;
    display: none;
}

.site-chat-widget__panel {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: min(420px, calc(100vw - 32px));
    max-height: min(720px, calc(100vh - 32px));
    flex-direction: column;
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    backdrop-filter: blur(16px) saturate(1.15);
    border: 1px solid color-mix(in srgb, var(--primary, #ff8a16) 14%, var(--border));
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    overflow: hidden;
    z-index: 1201;
    display: none;
}

.site-chat-widget__panel[hidden],
.site-chat-widget__backdrop[hidden] {
    display: none !important;
}

.site-chat-widget.is-open .site-chat-widget__panel {
    display: flex !important;
}

.site-chat-widget.is-open .site-chat-widget__backdrop {
    display: block !important;
}

.site-chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary, #ff8a16) 10%, var(--surface)) 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border);
}

.site-chat-widget__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 800;
}

.site-chat-widget__close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface-alt) 60%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--text-muted);
    font-size: 1.375rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.2s;
}

.site-chat-widget__close:hover {
    background: var(--border);
    color: var(--text);
    transform: rotate(90deg);
}

.site-chat-widget__body {
    padding: 12px 14px 14px;
    overflow: auto;
}

.site-chat-widget.is-open .site-chat-widget__fab {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
}

body.site-chat-open {
    overflow: hidden;
}

.home-chat--widget {
    min-height: 0;
    gap: 10px;
}

.home-chat--widget .home-chat__head > div:first-child {
    display: none;
}

.home-chat--widget .home-chat__head {
    justify-content: stretch;
    padding-bottom: 0;
    border-bottom: none;
}

.home-chat--widget .home-chat__city {
    max-width: none;
    width: 100%;
}

.home-chat--widget .home-chat__messages {
    min-height: 140px;
    max-height: min(42vh, 320px);
}

@media (max-width: 640px) {
    .site-chat-widget {
        right: max(20px, env(safe-area-inset-right));
        bottom: max(20px, env(safe-area-inset-bottom));
    }

    .site-chat-widget__panel {
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 18px 18px 0 0;
    }

    body.has-site-chat .site-chat-widget.is-open .site-chat-widget__panel {
        bottom: 0;
    }

    .site-chat-widget__fab-label {
        display: none;
    }

    .site-chat-widget__fab {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
    }
}

/* Dark theme */
:root[data-theme="dark"] .site-chat-widget__panel {
    background: var(--surface);
    border-color: var(--border);
}

:root[data-theme="dark"] .site-chat-widget__header {
    background: linear-gradient(135deg, var(--surface-alt) 0%, var(--surface) 100%);
    border-bottom-color: var(--border);
}

:root[data-theme="dark"] .site-chat-widget__title {
    color: var(--text);
}

:root[data-theme="dark"] .site-chat-widget__close {
    background: var(--surface);
    color: var(--text-muted);
}

:root[data-theme="dark"] .site-chat-widget__close:hover {
    background: var(--surface-alt);
    color: var(--text);
}
