/* Floating Chat Button */
.chat-float-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #5B8DEE 0%, #A855F7 100%);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(91, 141, 238, 0.5), 0 0 40px rgba(91, 141, 238, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: pulse 2s ease-in-out infinite;
    will-change: transform;
}

.chat-float-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(91, 141, 238, 0.7), 0 0 60px rgba(91, 141, 238, 0.5);
}

.chat-float-button:active {
    transform: scale(0.95);
}

.chat-float-button svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.chat-float-button.active {
    background: linear-gradient(135deg, #A855F7 0%, #5B8DEE 100%);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid #0a0a0a;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-badge.show {
    opacity: 1;
    transform: scale(1);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(91, 141, 238, 0.5), 0 0 40px rgba(91, 141, 238, 0.3);
    }
    50% {
        box-shadow: 0 4px 30px rgba(91, 141, 238, 0.7), 0 0 60px rgba(91, 141, 238, 0.5);
    }
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: rgba(24, 24, 24, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(91, 141, 238, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
    will-change: opacity, transform;
}

.chat-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #5B8DEE 0%, #A855F7 100%);
    padding: 1.2rem 1.5rem;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-header-text h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.2rem;
}

.chat-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #46d369;
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(10, 10, 10, 0.5);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(91, 141, 238, 0.5);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 141, 238, 0.7);
}

/* Message Bubble */
.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
}

.message.other {
    align-self: flex-start;
}

.message-header {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 0.3rem;
    padding: 0 0.5rem;
    font-weight: 600;
}

.message.user .message-header {
    text-align: right;
}

.message-bubble {
    padding: 0.8rem 1rem;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #5B8DEE 0%, #A855F7 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(91, 141, 238, 0.3);
}

.message.other .message-bubble {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.3rem;
}

.message-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: right;
}

.message.other .message-time {
    color: rgba(255, 255, 255, 0.5);
}

/* System Message */
.message.system {
    align-self: center;
    max-width: 90%;
}

.message.system .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    color: #999;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    text-align: center;
    padding: 2rem;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #999;
}

.empty-state p {
    font-size: 0.9rem;
    color: #666;
}

/* Chat Input */
.chat-input-container {
    padding: 1rem 1.5rem;
    background: rgba(18, 18, 18, 0.95);
    border-radius: 0 0 16px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 0.8rem 1.2rem;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 42px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(91, 141, 238, 0.5);
    box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, #5B8DEE 0%, #A855F7 100%);
    border: none;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(91, 141, 238, 0.3);
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(91, 141, 238, 0.5);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-float-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chat-float-button svg {
        width: 24px;
        height: 24px;
    }

    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-height: 100vh;
    }

    .chat-window.active {
        bottom: 0;
    }

    .chat-header {
        border-radius: 0;
        padding: 1rem 1.2rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-container {
        padding: 0.8rem 1rem;
        border-radius: 0;
    }

    .message {
        max-width: 85%;
    }
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
