/**
 * Fenzy AI Chatbot Widget Styles
 * Matches the Fenzy dark theme design
 */

/* Widget Container */
.fenzy-chatbot {
    --chat-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --chat-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --chat-bg: #0d1117;
    --chat-card-bg: #161b22;
    --chat-border: rgba(255, 255, 255, 0.1);
    --chat-text: #e6edf3;
    --chat-text-muted: #8b949e;
    --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

.fenzy-chatbot.rtl {
    right: auto;
    left: 24px;
    direction: rtl;
}

/* Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chat-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.5);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
}

.chatbot-toggle .chat-icon {
    opacity: 1;
    transform: scale(1);
}

.chatbot-toggle .close-icon {
    position: absolute;
    opacity: 0;
    transform: scale(0) rotate(-90deg);
}

.fenzy-chatbot.open .chatbot-toggle .chat-icon {
    opacity: 0;
    transform: scale(0) rotate(90deg);
}

.fenzy-chatbot.open .chatbot-toggle .close-icon {
    opacity: 1;
    transform: scale(1) rotate(0);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Container */
.chatbot-container {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    border: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fenzy-chatbot.rtl .chatbot-container {
    right: auto;
    left: 0;
}

.fenzy-chatbot.open .chatbot-container {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    padding: 16px 20px;
    background: var(--chat-card-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar svg {
    width: 26px;
    height: 26px;
    color: white;
}

.header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-text);
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--chat-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.minimize-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--chat-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.minimize-btn svg {
    width: 18px;
    height: 18px;
    color: var(--chat-text-muted);
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

/* Messages */
.message {
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant,
.message.error {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 6px;
}

.fenzy-chatbot.rtl .message.user .message-content {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 6px;
}

.message.assistant .message-content {
    background: var(--chat-card-bg);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 6px;
}

.fenzy-chatbot.rtl .message.assistant .message-content {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 6px;
}

.message.error .message-content {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-bottom-left-radius: 6px;
}

.message-content a {
    color: #818cf8;
    text-decoration: underline;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content strong {
    font-weight: 600;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.suggestion-btn {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    color: var(--chat-text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.suggestion-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-text-muted);
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.chatbot-input {
    padding: 16px 20px;
    background: var(--chat-card-bg);
    border-top: 1px solid var(--chat-border);
}

.chatbot-input form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chatbot-input input {
    flex: 1;
    padding: 12px 16px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    color: var(--chat-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input input::placeholder {
    color: var(--chat-text-muted);
}

.chatbot-input input:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-input button:active {
    transform: scale(0.95);
}

.chatbot-input button svg {
    width: 20px;
    height: 20px;
    color: white;
}

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

    .fenzy-chatbot.rtl {
        left: 16px;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .chatbot-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 72px;
        right: -8px;
        border-radius: 16px;
    }

    .fenzy-chatbot.rtl .chatbot-container {
        left: -8px;
    }

    .chatbot-header {
        padding: 14px 16px;
    }

    .avatar {
        width: 40px;
        height: 40px;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .chatbot-input {
        padding: 12px 16px;
    }

    .chatbot-input input {
        padding: 10px 14px;
    }

    .chatbot-input button {
        width: 40px;
        height: 40px;
    }
}

/* Animations for widget entry */
@media (prefers-reduced-motion: reduce) {
    .fenzy-chatbot,
    .fenzy-chatbot *,
    .message {
        animation: none !important;
        transition: none !important;
    }
}

/* Print styles - hide chatbot */
@media print {
    .fenzy-chatbot {
        display: none !important;
    }
}
