/* FAQ Chat Widget - widget.css */

/* Scoped reset — block theme overrides on all widget elements */
#fcw-root *,
#fcw-root *::before,
#fcw-root *::after {
    box-sizing: border-box;
}
#fcw-root button {
    text-transform: none !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    font-family: inherit !important;
    -webkit-font-smoothing: auto;
}

/* FAB Button — position and shape only; colors set inline by JS */
#fcw-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    z-index: 9999;
    outline: none;
    overflow: hidden;
    padding: 0;
}

/* Popup */
#fcw-popup {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
}
#fcw-root[dir="rtl"] #fcw-popup, [dir="rtl"] #fcw-popup {
    right: auto;
    left: 24px;
}
#fcw-popup.fcw-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
#fcw-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #fff;
    flex-shrink: 0;
}
[dir="rtl"] #fcw-header,
#fcw-root[dir="rtl"] #fcw-header {
    flex-direction: row-reverse;
    text-align: right;
    direction: ltr;
}
.fcw-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}
.fcw-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fcw-header-info {
    flex: 1;
    min-width: 0;
}
#fcw-root[dir="rtl"] .fcw-header-info, [dir="rtl"] .fcw-header-info {
    text-align: right;
}
.fcw-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fcw-online {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 3px;
}
#fcw-root[dir="rtl"] .fcw-online, [dir="rtl"] .fcw-online {
    flex-direction: row;
}
.fcw-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}
#fcw-close {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    margin: 0;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.55);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
}
#fcw-close:hover {
    background: rgba(255,255,255,0.38);
}
#fcw-close svg {
    width: 12px;
    height: 12px;
    display: block;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    flex-shrink: 0;
    pointer-events: none;
}

/* Messages area */
#fcw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#fcw-messages::-webkit-scrollbar {
    width: 4px;
}
#fcw-messages::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 4px;
}

/* Bubbles */
.fcw-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.fcw-bubble-row.fcw-bot {
    justify-content: flex-start;
}
.fcw-bubble-row.fcw-user {
    justify-content: flex-end;
}
#fcw-root[dir="rtl"] .fcw-bubble-row.fcw-bot, [dir="rtl"] .fcw-bubble-row.fcw-bot {
    flex-direction: row-reverse;
    justify-content: flex-end;
}
#fcw-root[dir="rtl"] .fcw-bubble-row.fcw-user, [dir="rtl"] .fcw-bubble-row.fcw-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.fcw-bubble-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e8f5e9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.fcw-bubble-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fcw-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.fcw-bubble-row.fcw-bot .fcw-bubble {
    background: #f1f3f4;
    color: #222;
    border-bottom-left-radius: 4px;
}
#fcw-root[dir="rtl"] .fcw-bubble-row.fcw-bot .fcw-bubble, [dir="rtl"] .fcw-bubble-row.fcw-bot .fcw-bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}
.fcw-bubble-row.fcw-user .fcw-bubble {
    color: #fff;
    border-bottom-right-radius: 4px;
}
#fcw-root[dir="rtl"] .fcw-bubble-row.fcw-user .fcw-bubble, [dir="rtl"] .fcw-bubble-row.fcw-user .fcw-bubble {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

/* Rich text inside bubble */
.fcw-bubble p { margin: 0 0 6px; }
.fcw-bubble p:last-child { margin-bottom: 0; }
.fcw-bubble ul, .fcw-bubble ol { margin: 6px 0 0 18px; padding: 0; }
[dir="rtl"] .fcw-bubble ul, [dir="rtl"] .fcw-bubble ol,
#fcw-root[dir="rtl"] .fcw-bubble ul, #fcw-root[dir="rtl"] .fcw-bubble ol { margin-right: 18px; margin-left: 0; }
.fcw-bubble a { color: inherit; text-decoration: underline; }

/* FAQ question buttons */
.fcw-faq-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.fcw-faq-btn {
    background: #fff;
    border: 2px solid;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
    text-transform: none !important;
    font-family: inherit !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
}
#fcw-root[dir="rtl"] .fcw-faq-btn, [dir="rtl"] .fcw-faq-btn {
    text-align: right;
}
.fcw-faq-btn:hover {
    filter: brightness(0.94);
}

/* Follow-up buttons (Yes/No) */
.fcw-followup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
#fcw-root[dir="rtl"] .fcw-followup-buttons, [dir="rtl"] .fcw-followup-buttons {
    flex-direction: row-reverse;
}
.fcw-followup-btn {
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 13px;
    cursor: pointer;
    border: 2px solid;
    background: #fff;
    transition: background 0.15s, color 0.15s;
    text-transform: none !important;
    font-family: inherit !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
}
.fcw-followup-btn:hover {
    filter: brightness(0.94);
}

/* Typing indicator */
.fcw-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f1f3f4;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
#fcw-root[dir="rtl"] .fcw-typing, [dir="rtl"] .fcw-typing {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}
.fcw-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    animation: fcw-bounce 1.2s infinite;
}
.fcw-typing span:nth-child(2) { animation-delay: 0.2s; }
.fcw-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes fcw-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* Responsive */
@media (max-width: 400px) {
    #fcw-popup {
        width: calc(100vw - 16px);
        right: 8px;
    }
    #fcw-root[dir="rtl"] #fcw-popup, [dir="rtl"] #fcw-popup {
        left: 8px;
        right: auto;
    }
    #fcw-fab {
        right: 12px;
        bottom: 12px;
    }
    #fcw-root[dir="rtl"] #fcw-fab, [dir="rtl"] #fcw-fab {
        left: 12px;
        right: auto;
    }
}
