/* ==========================================
   SARA AI CHAT WIDGET — Public Pages
   ========================================== */

/* FAB (Floating Action Button) */
.sara-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sara-color, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(139, 92, 246, .4);
    z-index: 10000;
    transition: transform .3s, box-shadow .3s;
}
.sara-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(139, 92, 246, .5);
}
.sara-fab.left { right: auto; left: 24px; }
.sara-fab .sara-fab-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}
.sara-fab .sara-fab-content .sara-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}
.sara-fab .sara-fab-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--sara-color, #8b5cf6);
    opacity: .4;
    animation: saraPulse 2s infinite;
}
@keyframes saraPulse {
    0% { transform: scale(1); opacity: .4; }
    70% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}
.sara-fab.active .sara-fab-pulse { display: none; }

/* Widget Container */
.sara-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #1a1a2e;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,.4);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(.95);
    pointer-events: none;
    transition: opacity .3s, transform .3s;
}
.sara-widget.left { right: auto; left: 24px; }
.sara-widget.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.sara-widget-header {
    background: var(--sara-color, #8b5cf6);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.sara-widget-header .sara-h-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    overflow: hidden;
}
.sara-widget-header .sara-h-avatar .sara-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.sara-widget-header .sara-h-info { flex: 1; }
.sara-widget-header .sara-h-info strong { color: #fff; font-size: 15px; }
.sara-widget-header .sara-h-info .sara-h-status {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,.7);
    margin-top: 2px;
}
.sara-widget-header .sara-h-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}
.sara-widget-header .sara-h-close:hover { color: #fff; }

/* Messages */
.sara-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    min-height: 200px;
    background: #0f0f23;
}
.sara-widget-body::-webkit-scrollbar { width: 4px; }
.sara-widget-body::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.sara-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: saraFadeIn .3s ease;
}
@keyframes saraFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.sara-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.sara-msg .s-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--sara-color, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    color: #fff;
    overflow: hidden;
}
.sara-msg .s-avatar .sara-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.sara-msg.user .s-avatar {
    background: #2d2d44;
}
.sara-msg .s-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #e0e0e0;
}
.sara-msg.bot .s-bubble {
    background: #1e1e3a;
    border-bottom-left-radius: 4px;
}
.sara-msg.user .s-bubble {
    background: var(--sara-color, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sara-msg .s-bubble strong { color: #fff; }
.sara-msg .s-time {
    display: block;
    font-size: 10px;
    color: #666;
    margin-top: 4px;
}

/* Typing indicator */
.sara-typing .typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.sara-typing .typing-dots span {
    width: 7px;
    height: 7px;
    background: #888;
    border-radius: 50%;
    animation: saraDot 1.4s infinite ease-in-out both;
}
.sara-typing .typing-dots span:nth-child(2) { animation-delay: .2s; }
.sara-typing .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes saraDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Quick Actions */
.sara-quick-actions {
    padding: 8px 16px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #0f0f23;
    border-top: 1px solid #1e1e3a;
}
.sara-quick-actions button {
    background: #1e1e3a;
    border: 1px solid #2d2d44;
    color: #ccc;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 11px;
    cursor: pointer;
    transition: .2s;
    white-space: nowrap;
}
.sara-quick-actions button:hover {
    background: var(--sara-color, #8b5cf6);
    color: #fff;
    border-color: var(--sara-color, #8b5cf6);
}

/* Input */
.sara-widget-input {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    background: #1a1a2e;
    border-top: 1px solid #2d2d44;
}
.sara-widget-input input {
    flex: 1;
    background: #0f0f23;
    border: 1px solid #2d2d44;
    color: #e0e0e0;
    padding: 10px 14px;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
    transition: border .2s;
}
.sara-widget-input input:focus {
    border-color: var(--sara-color, #8b5cf6);
}
.sara-widget-input input::placeholder { color: #666; }
.sara-widget-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sara-color, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
    flex-shrink: 0;
}
.sara-widget-input button:hover { opacity: .85; }

/* Powered by */
.sara-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #444;
    background: #1a1a2e;
}

/* Responsive */
@media (max-width: 480px) {
    .sara-widget {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        bottom: 80px;
        max-height: 70vh;
    }
    .sara-fab { bottom: 16px; right: 16px; width: 54px; height: 54px; font-size: 22px; }
    .sara-fab.left { left: 16px; right: auto; }
}
