:root {
    --fc-primary: #1565c0;
    --fc-primary-dark: #0d47a1;
    --fc-primary-light: #e3f2fd;
    --fc-bg: #ffffff;
    --fc-bg-msg: #f5f5f5;
    --fc-text: #212121;
    --fc-text-light: #757575;
    --fc-border: #e0e0e0;
    --fc-radius: 16px;
    --fc-shadow: 0 8px 32px rgba(0,0,0,0.15);
    --fc-user-bg: #1565c0;
    --fc-user-text: #fff;
    --fc-bot-bg: #f5f5f5;
    --fc-bot-text: #212121;
    --fc-online: #4caf50;
}

#felora-chat-wrap {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    font-family: Vazirmatn, Tahoma, Arial, sans-serif;
    direction: rtl;
}

#felora-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--fc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fc-shadow);
    transition: transform 0.2s, background 0.2s;
}
#felora-chat-toggle:hover {
    background: var(--fc-primary-dark);
    transform: scale(1.08);
}

#felora-chat-box {
    position: absolute;
    bottom: 76px;
    left: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--fc-bg);
    border-radius: var(--fc-radius);
    box-shadow: var(--fc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fcSlideUp 0.25s ease-out;
}

@keyframes fcSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#felora-chat-header {
    background: var(--fc-primary);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#felora-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
#felora-chat-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--fc-online);
    flex-shrink: 0;
}
#felora-chat-header-title {
    font-size: 15px;
    font-weight: 700;
}
#felora-chat-minimize {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
}
#felora-chat-minimize:hover { opacity: 1; }

/* Messages */
#felora-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#felora-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#felora-chat-messages::-webkit-scrollbar-thumb {
    background: var(--fc-border);
    border-radius: 2px;
}

.fc-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}
.fc-msg-user {
    align-self: flex-start;
    background: var(--fc-user-bg);
    color: var(--fc-user-text);
    border-bottom-right-radius: 4px;
}
.fc-msg-assistant,
.fc-msg-operator {
    align-self: flex-end;
    background: var(--fc-bot-bg);
    color: var(--fc-bot-text);
    border-bottom-left-radius: 4px;
}
.fc-msg-operator {
    border: 1px solid var(--fc-primary-light);
}
.fc-msg-system {
    align-self: center;
    background: #fff3e0;
    color: #e65100;
    font-size: 12px;
    border-radius: 8px;
    padding: 6px 12px;
    text-align: center;
}

.fc-msg a {
    color: inherit;
    text-decoration: underline;
}

/* Typing indicator */
.fc-typing {
    align-self: flex-end;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--fc-bot-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.fc-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fc-text-light);
    animation: fcBounce 1.4s infinite;
}
.fc-typing span:nth-child(2) { animation-delay: 0.2s; }
.fc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fcBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Operator banner */
#felora-chat-operator-banner {
    background: #fff3e0;
    color: #e65100;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    flex-shrink: 0;
}

/* Input */
#felora-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    padding: 10px 14px;
    border-top: 1px solid var(--fc-border);
    gap: 8px;
    flex-shrink: 0;
}
#felora-chat-input {
    flex: 1;
    border: 1px solid var(--fc-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}
#felora-chat-input:focus {
    border-color: var(--fc-primary);
}
#felora-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#felora-chat-send:hover {
    background: var(--fc-primary-dark);
}
#felora-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
#felora-chat-footer {
    padding: 6px 14px 10px;
    text-align: center;
    flex-shrink: 0;
}
#felora-chat-transfer-btn {
    background: none;
    border: 1px solid var(--fc-border);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 12px;
    font-family: inherit;
    color: var(--fc-text-light);
    cursor: pointer;
    transition: all 0.2s;
}
#felora-chat-transfer-btn:hover {
    border-color: var(--fc-primary);
    color: var(--fc-primary);
}

/* Mobile */
@media (max-width: 480px) {
    #felora-chat-wrap {
        bottom: 12px;
        left: 12px;
    }
    #felora-chat-box {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        bottom: 72px;
    }
    #felora-chat-toggle {
        width: 52px;
        height: 52px;
    }
}
