/* ── FloorAmigo Chat Widget ─────────────────────────────────────────────────
   Floating chat bubble + slide-up panel.
   Green: #f37b22 (matches --green in css_client.css)
   -------------------------------------------------------------------------- */

/* ── Container ── */
#fa-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: #1a1a1a;
    box-sizing: border-box;
}

#fa-chat-widget *,
#fa-chat-widget *::before,
#fa-chat-widget *::after {
    box-sizing: inherit;
}

#fa-chat-widget.is-on-demand #fa-chat-fab,
#fa-chat-widget.is-on-demand #fa-chat-minimized-note {
    display: none;
}

#fa-chat-widget.is-on-demand {
    right: 24px;
    bottom: 24px;
    width: 0;
    height: 0;
}

#fa-chat-widget.is-on-demand #fa-chat-panel {
    bottom: 0;
}

/* ── FAB (floating action button) ── */
#fa-chat-fab {
    min-width: 144px;
    height: 46px;
    border-radius: 999px;
    background: #fff;
    color: #f37b22;
    border: 2px solid #f37b22;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 18px;
    box-shadow: 0 6px 20px rgba(17, 27, 52, .16);
    transition: transform .18s ease, box-shadow .18s ease, background .15s ease, color .15s ease, border-color .15s ease;
    position: relative;
    outline: none;
    font: 800 15px/1.1 inherit;
    white-space: nowrap;
}

#fa-chat-fab:hover {
    background: #fff7ed;
    border-color: #cf5f12;
    color: #cf5f12;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(17, 27, 52, .2);
}

#fa-chat-fab:active {
    transform: translateY(0) scale(.98);
}

#fa-chat-fab svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity .15s;
    flex: 0 0 auto;
}

.fa-chat-fab-label {
    display: inline-block;
}

/* Badge showing unread dot */
#fa-chat-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #e53935;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

#fa-chat-badge.is-visible {
    display: block;
}

#fa-chat-minimized-note {
    display: none;
}

#fa-chat-minimized-note.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
}

/* ── Panel ── */
#fa-chat-panel {
    position: absolute;
    bottom: 58px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.85) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
}

#fa-chat-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Panel header ── */
#fa-chat-header {
    background: #f37b22;
    color: #fff;
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#fa-chat-header svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    flex-shrink: 0;
}

#fa-chat-header-text {
    flex: 1;
}

#fa-chat-header-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .01em;
}

#fa-chat-header-sub {
    font-size: 12px;
    opacity: .88;
    margin-top: 1px;
}

/* ── Close (X) button ── */
#fa-chat-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    transition: background .15s;
    padding: 0;
    outline: none;
}

#fa-chat-close:hover {
    background: rgba(255,255,255,.3);
}

#fa-chat-close svg {
    width: 16px;
    height: 16px;
    fill: #fff;
    display: block;
}

/* ── Sent timestamp ── */
.fa-chat-timestamp {
    font-size: 11px;
    color: #aaa;
    margin-top: 10px;
    text-align: center;
}

/* ── Panel body ── */
#fa-chat-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* ── Screen: phone capture ── */
#fa-chat-screen-phone {
    display: none;
}

#fa-chat-screen-phone.is-active {
    display: block;
}

.fa-chat-prompt {
    font-size: 14px;
    color: #444;
    margin-bottom: 12px;
}

.fa-chat-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.fa-chat-email-label {
    margin-top: 10px;
}

.fa-chat-input {
    width: 100%;
    border: 1.5px solid #ccc;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 15px;
    outline: none;
    transition: border-color .15s;
    color: #1a1a1a;
    background: #fafafa;
}

.fa-chat-input:focus {
    border-color: #f37b22;
    background: #fff;
}

.fa-chat-input::placeholder,
.fa-chat-textarea::placeholder {
    color: #a8b0bc;
    opacity: 1;
    font-weight: 400;
}

.fa-chat-input.is-error {
    border-color: #e53935;
}

.fa-chat-error {
    font-size: 12px;
    color: #e53935;
    margin-top: 4px;
    display: none;
}

.fa-chat-error.is-visible {
    display: block;
}

.fa-chat-btn-primary {
    width: 100%;
    margin-top: 14px;
    padding: 11px;
    background: #f37b22;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.fa-chat-btn-primary:hover {
    background: #cf5f12;
}

.fa-chat-btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Screen: question chips ── */
#fa-chat-screen-chips {
    display: none;
}

#fa-chat-screen-chips.is-active {
    display: block;
}

.fa-chat-chips-intro {
    font-size: 14px;
    color: #444;
    margin-bottom: 12px;
}

.fa-chat-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.fa-chat-chip {
    background: #f1f8f1;
    border: 1.5px solid #f37b22;
    color: #2e7d32;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background .14s, color .14s;
    line-height: 1.35;
}

.fa-chat-chip:hover {
    background: #f37b22;
    color: #fff;
}

.fa-chat-chips-divider {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin: 4px 0 10px;
}

.fa-chat-thread {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding-right: 2px;
}

.fa-chat-bubble {
    max-width: 84%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.fa-chat-bubble.is-customer {
    align-self: flex-end;
    background: #f37b22;
    color: #fff;
    border-bottom-right-radius: 5px;
}

.fa-chat-bubble.is-team {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1f2937;
    border-bottom-left-radius: 5px;
}

.fa-chat-textarea {
    width: 100%;
    border: 1.5px solid #ccc;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    overflow: hidden;
    transition: border-color .15s;
    color: #1a1a1a;
    background: #fafafa;
    min-height: 68px;
}

.fa-chat-textarea:focus {
    border-color: #f37b22;
    background: #fff;
}

/* ── Screen: sending / pending ── */
#fa-chat-screen-pending {
    display: none;
    text-align: center;
    padding: 8px 0;
}

#fa-chat-screen-pending.is-active {
    display: block;
}

@keyframes fa-spin {
    to { transform: rotate(360deg); }
}

/* Inline spinner inside send button while POST is in-flight */
.fa-chat-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fa-spin .65s linear infinite;
    vertical-align: middle;
    margin-right: 7px;
}

.fa-chat-pending-msg {
    font-size: 14px;
    color: #555;
}

.fa-chat-pending-sub {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
}

/* ── Screen: replied ── */
#fa-chat-screen-replied {
    display: none;
    text-align: center;
    padding: 8px 0;
}

#fa-chat-screen-replied.is-active {
    display: block;
}

.fa-chat-replied-icon {
    width: 48px;
    height: 48px;
    background: #e8f5e9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px auto 14px;
}

.fa-chat-replied-icon svg {
    width: 26px;
    height: 26px;
    fill: #f37b22;
}

.fa-chat-replied-msg {
    font-size: 15px;
    font-weight: 700;
    color: #2e7d32;
    margin-bottom: 6px;
}

.fa-chat-replied-sub {
    font-size: 13px;
    color: #555;
}

/* ── Screen: error ── */
#fa-chat-screen-error {
    display: none;
    text-align: center;
    padding: 8px 0;
}

#fa-chat-screen-error.is-active {
    display: block;
}

.fa-chat-error-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.fa-chat-error-msg {
    font-size: 14px;
    color: #c62828;
    margin-bottom: 12px;
}

.fa-chat-btn-secondary {
    padding: 9px 20px;
    background: #fff;
    color: #f37b22;
    border: 2px solid #f37b22;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.fa-chat-btn-secondary:hover {
    background: #f37b22;
    color: #fff;
}

/* ── Mobile adjustments ── */
@media (max-width: 700px) {
    #fa-chat-minimized-note {
        display: none;
    }
}

@media (max-width: 400px) {
    #fa-chat-panel {
        width: calc(100vw - 24px);
        right: -12px;
        bottom: 58px;
    }

    #fa-chat-widget {
        bottom: 16px;
        right: 16px;
    }
}
