/* ============================================================
   ff-agent.css — FindFyre help chat widget
   ============================================================ */

.ffa {
    --ffa-bottom: 22px;
    --ffa-right: 22px;
    --ffa-pink: #e0336b;
    --ffa-wine: #a3154a;
    --ffa-flame: #f8f6f8;
    --ffa-offwhite: #f8f6f8;
    --ffa-black: #07070b;
    --ffa-grad: linear-gradient(135deg, #e0336b, #a3154a);
    --ffa-glow: 0 0 36px rgba(224, 51, 107, 0.30), 0 12px 32px rgba(0, 0, 0, 0.35);
    --ffa-ease: cubic-bezier(0.25, 1, 0.5, 1);
    font-family: "Inter", var(--font-family-base, system-ui, sans-serif);
    -webkit-text-size-adjust: 100%;
}

@media (max-width: 768px) {
    .ffa {
        --ffa-bottom: calc(var(--fp-bottom-nav-height, 52px) + 16px);
        --ffa-right: 16px;
    }
}

.ffa-mark {
    display: grid;
    place-items: center;
    line-height: 0;
}

.ffa-help-flame {
    display: block;
    height: 34px;
    width: auto;
}

.ffa-fab {
    position: fixed;
    right: var(--ffa-right);
    bottom: var(--ffa-bottom);
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: var(--ffa-grad);
    color: var(--ffa-flame);
    box-shadow: var(--ffa-glow);
    cursor: pointer;
    z-index: 130;
    overflow: visible;
    display: grid;
    place-items: center;
    transform-origin: 50% 50%;
    transition: transform 220ms var(--ffa-ease), box-shadow 220ms var(--ffa-ease), opacity 200ms ease;
}

.ffa-help-q {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ffa-offwhite);
    border: 2px solid var(--ffa-black);
    color: var(--ffa-wine);
    font-family: "Poppins", sans-serif;
    font-weight: 800;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.ffa.is-open .ffa-fab,
.ffa.is-open .ffa-fab:hover,
.ffa.is-open .ffa-fab:focus-visible {
    transform: scale(0.45);
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
}

.ffa-fab:hover,
.ffa-fab:focus-visible {
    transform: translateY(-2px);
}

.ffa-fab-badge {
    display: none;
}

.ffa-panel {
    position: fixed;
    right: var(--ffa-right);
    bottom: var(--ffa-bottom);
    width: min(380px, calc(100vw - 40px));
    height: min(560px, calc(100dvh - 48px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    background: var(--bg-card, #111622);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    z-index: 120;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(0, 18px, 0) scale(0.92);
    transform-origin: 100% 100%;
    transition:
        opacity 0.28s var(--ffa-ease),
        transform 0.32s var(--ffa-ease),
        visibility 0s linear 0.32s;
}

.ffa.is-open .ffa-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
    transition:
        opacity 0.28s var(--ffa-ease),
        transform 0.32s var(--ffa-ease),
        visibility 0s linear 0s;
}

body.fp-light .ffa-panel {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
}

.ffa-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    background: var(--bg-elevated, #151b29);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.07));
}

body.fp-light .ffa-head {
    background: #ffffff;
}

.ffa-head-av {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--ffa-grad);
    color: var(--ffa-flame);
    box-shadow: 0 0 18px rgba(224, 51, 107, 0.22);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: visible;
}

.ffa-head-av .ffa-help-flame {
    height: 23px;
}

.ffa-head-av .ffa-help-q {
    top: -4px;
    right: -4px;
    width: 15px;
    height: 15px;
    font-size: 8px;
    border-color: #15161f;
}

body.fp-light .ffa-head-av .ffa-help-q {
    border-color: #ffffff;
}

.ffa-head-meta {
    flex: 1;
    min-width: 0;
}

.ffa-head-name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary, #f8fafc);
}

.ffa-head-status {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted, #7f889a);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ffa-online {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3dce6a;
    flex-shrink: 0;
}

.ffa-iconbtn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary, #c7cedd);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.ffa-iconbtn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

body.fp-light .ffa-iconbtn:hover {
    background: rgba(10, 48, 73, 0.06);
}

.ffa-log {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ffa-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    flex-shrink: 0;
}

.ffa-row--agent { align-self: flex-start; }
.ffa-row--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ffa-bubble-av {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--ffa-grad);
    color: var(--ffa-flame);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ffa-bubble-av .ffa-help-flame {
    height: 16px;
}

.ffa-bubble {
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-primary, #f8fafc);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ffa-row--agent .ffa-bubble {
    background: var(--bg-card-soft, #151b29);
    border-bottom-left-radius: 6px;
}

.ffa-row--user .ffa-bubble {
    background: #e0336b;
    color: #fff;
    border-bottom-right-radius: 6px;
}

body.fp-light .ffa-row--agent .ffa-bubble {
    background: #f4f5f7;
    color: #0f1117;
}

.ffa-bubble a {
    color: #ff7eb3;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.fp-light .ffa-bubble a { color: #c9457c; }
.ffa-row--user .ffa-bubble a { color: #fff; }

.ffa-bubble p { margin: 0 0 8px; }
.ffa-bubble p:last-child { margin: 0; }

.ffa-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    min-width: 46px;
    padding-top: 12px;
    padding-bottom: 12px;
}

.ffa-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e0548d;
    animation: ffa-bounce 1.1s infinite ease-in-out;
}
.ffa-typing span:nth-child(2) { animation-delay: 0.15s; }
.ffa-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ffa-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.ffa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-card, #111622);
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.07));
    position: relative;
    z-index: 2;
}

.ffa-chips:empty {
    display: none;
    padding: 0;
    border: 0;
}

body.fp-light .ffa-chips {
    background: #ffffff;
}

.ffa-chip {
    border: 1px solid rgba(224, 84, 141, 0.35);
    background: transparent;
    color: var(--text-primary);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 34px;
}

.ffa-chip:hover {
    background: rgba(224, 84, 141, 0.12);
    border-color: #e0548d;
}

.ffa-compose {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.07));
    background: var(--bg-elevated, #111622);
}

body.fp-light .ffa-compose { background: #fff; }

.ffa-compose input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.1));
    background: var(--bg-card-soft, #151b29);
    color: var(--text-primary);
    padding: 0 12px;
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

body.fp-light .ffa-compose input {
    background: #f7f8f9;
    border-color: rgba(0, 0, 0, 0.1);
}

.ffa-compose input:focus {
    border-color: #e0548d;
}

.ffa-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #e0336b, #a3154a);
    color: #f8f6f8;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ffa-send:hover { filter: brightness(1.08); }

@media (max-width: 768px) {
    .ffa-fab {
        width: 60px;
        height: 60px;
    }

    .ffa-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: var(--ffa-bottom);
        height: calc(100dvh - var(--ffa-bottom) - 12px);
        max-height: none;
        border-radius: 16px;
        transform: translate3d(0, 24px, 0);
        transform-origin: 50% 100%;
    }

    .ffa.is-open .ffa-panel {
        transform: translate3d(0, 0, 0);
    }

    body.ffa-open {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ffa-fab,
    .ffa-panel,
    .ffa.is-open .ffa-panel {
        transition: opacity 0.15s ease, visibility 0.15s ease;
        transform: none;
    }

    .ffa.is-open .ffa-fab,
    .ffa.is-open .ffa-fab:hover,
    .ffa.is-open .ffa-fab:focus-visible {
        transform: none;
    }
}
