/* =============================================
   FSP Chat — Widget CSS v1.0.0
   Injetado no frontend do site (visitante).
   ============================================= */

#fsp-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Botão flutuante ─────────────────────────── */
#fsp-chat-fab {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--fsp-chat-color, #4f46e5);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform .2s, box-shadow .2s;
    outline: none;
}
#fsp-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(0,0,0,.28);
}
#fsp-chat-fab.fsp-fab--right { right: 24px; }
#fsp-chat-fab.fsp-fab--left  { left: 24px; }

#fsp-chat-fab svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity .2s, transform .2s;
}
#fsp-chat-fab .fsp-fab-icon-open  { opacity: 1; position: absolute; }
#fsp-chat-fab .fsp-fab-icon-close { opacity: 0; position: absolute; transform: rotate(-90deg); }
#fsp-chat-fab.fsp-fab--open .fsp-fab-icon-open  { opacity: 0; transform: rotate(90deg); }
#fsp-chat-fab.fsp-fab--open .fsp-fab-icon-close { opacity: 1; transform: rotate(0); }

/* Badge de não lidas no FAB */
#fsp-chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
    border: 2px solid #fff;
    display: none;
}

/* ── Janela do chat ──────────────────────────── */
#fsp-chat-window {
    position: fixed;
    bottom: 90px;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: opacity .2s, transform .2s;
    opacity: 0;
    transform: translateY(10px) scale(.97);
}
#fsp-chat-window.fsp-window--right { right: 24px; }
#fsp-chat-window.fsp-window--left  { left: 24px; }
#fsp-chat-window.fsp-window--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────── */
#fsp-chat-header {
    padding: 14px 16px;
    background: var(--fsp-chat-color, #4f46e5);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.fsp-chat-header-logo {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.18);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fsp-chat-header-logo svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.fsp-chat-header-info { flex: 1; min-width: 0; }
.fsp-chat-header-name {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fsp-chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: rgba(255,255,255,.8);
    margin-top: 2px;
}
.fsp-chat-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    animation: fsp-widget-pulse 2s infinite;
}
@keyframes fsp-widget-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}

/* ── Mensagens ───────────────────────────────── */
#fsp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
    scroll-behavior: smooth;
}
#fsp-chat-messages::-webkit-scrollbar { width: 3px; }
#fsp-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.fsp-w-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: fsp-w-msg-in .18s ease;
}
@keyframes fsp-w-msg-in {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fsp-w-msg--in  { align-self: flex-start; }
.fsp-w-msg--out { align-self: flex-end; }

.fsp-w-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.fsp-w-msg--in .fsp-w-bubble {
    background: #fff;
    color: #1f2937 !important;
    border: 1px solid #e5e7eb;
    border-radius: 0 14px 14px 14px;
}
.fsp-w-msg--out .fsp-w-bubble {
    background: var(--fsp-chat-color, #4f46e5);
    color: #fff !important;
    border-radius: 14px 0 14px 14px;
}
.fsp-w-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 3px;
}
.fsp-w-msg--out .fsp-w-time { text-align: right; }

/* ── Produto no widget ───────────────────────── */
.fsp-w-product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    width: 190px;
    margin-top: 4px;
}
.fsp-w-product-img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
    background: #f3f4f6;
}
.fsp-w-product-img-placeholder {
    width: 100%;
    height: 90px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fsp-w-product-img-placeholder svg {
    width: 28px;
    height: 28px;
    stroke: #9ca3af;
    fill: none;
}
.fsp-w-product-body { padding: 8px 10px; }
.fsp-w-product-name { font-size: 12px; font-weight: 700; color: #1f2937; line-height: 1.3; }
.fsp-w-product-price { font-size: 14px; font-weight: 700; color: var(--fsp-chat-color, #4f46e5); margin: 4px 0 8px; }
.fsp-w-product-btn {
    display: block;
    width: 100%;
    padding: 7px;
    background: var(--fsp-chat-color, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
}
.fsp-w-product-btn:hover { opacity: .9; }

/* ── Typing indicator ────────────────────────── */
.fsp-w-typing .fsp-w-bubble {
    padding: 10px 14px;
}
.fsp-w-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.fsp-w-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: fsp-w-typing 1.2s infinite;
}
.fsp-w-typing-dot:nth-child(2) { animation-delay: .2s; }
.fsp-w-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes fsp-w-typing {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%            { opacity: 1;  transform: translateY(-3px); }
}

/* ── Formulário inicial ──────────────────────── */
#fsp-chat-form-wrap {
    padding: 14px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}
#fsp-chat-form-wrap input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    margin-bottom: 6px;
    font-family: inherit;
    color: #1f2937;
}
#fsp-chat-form-wrap input:focus {
    border-color: var(--fsp-chat-color, #4f46e5);
}
#fsp-chat-form-start-btn {
    width: 100%;
    padding: 9px;
    background: var(--fsp-chat-color, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
#fsp-chat-form-start-btn:hover { opacity: .9; }

/* ── Barra de input ──────────────────────────── */
#fsp-chat-input-bar {
    padding: 10px 12px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}
#fsp-chat-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 90px;
    color: #1f2937;
    transition: border-color .15s;
    line-height: 1.4;
}
#fsp-chat-input:focus {
    border-color: var(--fsp-chat-color, #4f46e5);
}
#fsp-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--fsp-chat-color, #4f46e5);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s, transform .15s;
    outline: none;
}
#fsp-chat-send-btn:hover { opacity: .88; transform: scale(1.05); }
#fsp-chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Powered by ──────────────────────────────── */
#fsp-chat-powered {
    text-align: center;
    font-size: 10px;
    color: #9ca3af;
    padding: 5px 0 7px;
    flex-shrink: 0;
    background: #fff;
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 480px) {
    #fsp-chat-window {
        width: calc(100vw - 20px);
        right: 10px !important;
        left: 10px !important;
        bottom: 80px;
        max-height: 70vh;
    }
    #fsp-chat-fab.fsp-fab--right { right: 16px; }
    #fsp-chat-fab.fsp-fab--left  { left: 16px; }
}
