/* Chat Widget Styles */
:root {
    --chat-primary: #4f46e5;
    --chat-primary-dark: #4338ca;
    --chat-secondary: #6b7280;
    --chat-success: #10b981;
    --chat-bg: #ffffff;
    --chat-bg-dark: #1f2937;
    --chat-text: #1f2937;
    --chat-text-light: #6b7280;
    --chat-border: #e5e7eb;
    --chat-user-bg: #4f46e5;
    --chat-user-text: #ffffff;
    --chat-assistant-bg: #f3f4f6;
    --chat-assistant-text: #1f2937;
    --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chat-radius: 16px;
    --chat-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 48px rgba(79, 70, 229, 0.4);
}

.chat-toggle.active {
    transform: rotate(90deg);
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: var(--chat-transition);
}

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

.chat-window.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    z-index: 10000;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-weight: 600;
    font-size: 16px;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-success);
    animation: pulse 2s infinite;
}

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

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

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

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 30px 20px;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px;
}

.chat-welcome h4 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--chat-text);
}

.chat-welcome p {
    margin: 0 0 20px;
    color: var(--chat-text-light);
    font-size: 14px;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-action-btn {
    padding: 12px 16px;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    background: white;
    color: var(--chat-text);
    font-size: 14px;
    cursor: pointer;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.quick-action-btn:hover {
    border-color: var(--chat-primary);
    background: #f5f3ff;
    color: var(--chat-primary);
}

.quick-action-btn i {
    color: var(--chat-primary);
}

/* Message Bubbles */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

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

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
}

.chat-message.user .message-avatar {
    background: var(--chat-secondary);
    color: white;
}

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

.chat-message.user .message-content {
    background: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-bottom-right-radius: 4px;
}

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

.message-time {
    font-size: 11px;
    color: var(--chat-text-light);
    margin-top: 4px;
    text-align: right;
}

.chat-message.user .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 0 20px 16px;
}

.typing-indicator.active {
    display: flex;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-assistant-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

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

.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 typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Container */
.chat-input-container {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--chat-border);
    background: white;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: var(--chat-transition);
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Powered By */
.chat-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--chat-text-light);
    background: #fafafa;
}

/* End Chat Modal */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.chat-modal.open {
    display: flex;
}

.chat-modal-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-modal-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fef2f2;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px;
}

.chat-modal-content h4 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--chat-text);
}

.chat-modal-content p {
    margin: 0 0 24px;
    color: var(--chat-text-light);
    font-size: 14px;
}

.chat-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.chat-modal-actions .btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--chat-transition);
    border: none;
}

.chat-modal-actions .btn-secondary {
    background: var(--chat-border);
    color: var(--chat-text);
}

.chat-modal-actions .btn-secondary:hover {
    background: #d1d5db;
}

.chat-modal-actions .btn-danger {
    background: #ef4444;
    color: white;
}

.chat-modal-actions .btn-danger:hover {
    background: #dc2626;
}

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

    .chat-toggle {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chat-window.open {
        transform: none;
    }

    .quick-actions {
        gap: 6px;
    }

    .quick-action-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Scrollbar Styles */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-secondary);
}

/* Hide welcome when has messages */
.chat-messages.has-messages .chat-welcome {
    display: none;
}
