/* ===== Chatbot Widget ===== */
.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
}

/* Floating Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c1792b 0%, #8f5417 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(193, 121, 43, 0.4);
    transition: all 0.3s ease;
    position: relative;
    color: white;
    font-size: 1.5rem;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(193, 121, 43, 0.5);
}

.chatbot-toggle .chatbot-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active .chatbot-icon {
    transform: rotate(180deg);
}

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.chatbot-badge.show {
    display: flex;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #241a12 0%, #2e2118 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-new-chat {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.chatbot-new-chat:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c1792b 0%, #8f5417 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chatbot-header-text h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.chatbot-header-text p {
    font-size: 0.75rem;
    opacity: 0.7;
    margin: 0;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9f7f4;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #d4c4a8;
    border-radius: 4px;
}

.chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: chatMsgIn 0.3s ease;
}

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

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-message.bot .chat-msg-avatar {
    background: linear-gradient(135deg, #c1792b, #8f5417);
    color: white;
}

.chat-message.user .chat-msg-avatar {
    background: #241a12;
    color: white;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.bot .chat-msg-bubble {
    background: white;
    color: #333;
    border: 1px solid #e8e0d4;
    border-top-right-radius: 4px;
}

.chat-message.user .chat-msg-bubble {
    background: linear-gradient(135deg, #c1792b, #d4913e);
    color: white;
    border-top-left-radius: 4px;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 8px;
    align-self: flex-start;
    max-width: 85%;
    animation: chatMsgIn 0.3s ease;
}

.chat-typing .chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c1792b, #8f5417);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-typing-dots {
    background: white;
    border: 1px solid #e8e0d4;
    border-radius: 12px;
    border-top-right-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c1792b;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick Replies */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
    background: #f9f7f4;
}

.chatbot-quick-replies:empty {
    display: none;
}

.chat-quick-btn {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #d4c4a8;
    background: white;
    color: #6b5a3e;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-quick-btn:hover {
    background: #c1792b;
    color: white;
    border-color: #c1792b;
}

/* Input Area */
.chatbot-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e8e0d4;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0d5c5;
    border-radius: 24px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
}

.chatbot-input:focus {
    border-color: #c1792b;
}

.chatbot-input::placeholder {
    color: #b0a08a;
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c1792b, #8f5417);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Welcome Message */
.chatbot-welcome {
    text-align: center;
    padding: 16px 8px 8px;
}

.chatbot-welcome h4 {
    font-size: 0.95rem;
    color: #241a12;
    margin-bottom: 4px;
}

.chatbot-welcome p {
    font-size: 0.8rem;
    color: #7a6b5c;
}

/* Powered By */
.chatbot-powered {
    text-align: center;
    padding: 6px;
    font-size: 0.65rem;
    color: #b0a08a;
    background: white;
}

/* System Message */
.chat-system-msg {
    text-align: center;
    padding: 8px 12px;
    animation: chatMsgIn 0.3s ease;
}

.chat-system-msg span {
    background: #f0e8dc;
    color: #7a6b5c;
    font-size: 0.75rem;
    padding: 4px 14px;
    border-radius: 12px;
    font-weight: 500;
}

/* Product Card in Chat */
.chat-product-card {
    background: #faf7f2;
    border: 1px solid #e8e0d4;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* Order Button */
.chat-order-btn {
    display: inline-block;
    background: linear-gradient(135deg, #c1792b, #8f5417);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.2s;
}

.chat-order-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(193, 121, 43, 0.3);
}

/* Quantity Selector */
.chat-qty-selector {
    text-align: center;
    padding: 4px 0;
}

.chat-qty-selector p {
    font-size: 0.82rem;
    color: #5a4a3a;
    margin: 4px 0;
    font-weight: 600;
}

.chat-qty-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin: 8px 0;
}

.chat-qty-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #d4c4a8;
    background: white;
    color: #5a4a3a;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-qty-btn:hover {
    border-color: #c1792b;
    background: #c1792b;
    color: white;
}

.chat-qty-hint {
    font-size: 0.72rem;
    color: #a09080;
    margin: 0;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 16px;
        right: 16px;
    }

    .chatbot-toggle {
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }

    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: 520px;
        bottom: 66px;
        right: 0;
        border-radius: 12px;
    }
}

@media (max-width: 360px) {
    .chatbot-window {
        width: calc(100vw - 24px);
        right: -8px;
    }
}
