/**
 * Floating Chat Widget CSS
 * Production-ready styling for site-wide AI support chat
 */

/* Chat Widget Container */
.floating-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px; /* Positioned bottom-right where it belongs */
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    pointer-events: none; /* container does not accept events by default */
}

/* Re-enable pointer events for interactive parts */
.floating-chat-widget .chat-toggle-btn,
.floating-chat-widget .floating-chat-window.open {
    pointer-events: auto;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #39ff14, #00ffff);
    border: none;
    color: #000;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(57, 255, 20, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(57, 255, 20, 0.5);
}

.chat-toggle-btn.chat-open {
    background: linear-gradient(135deg, #ff4444, #ff6666);
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.3);
}

.chat-toggle-btn.chat-open:hover {
    box-shadow: 0 6px 30px rgba(255, 68, 68, 0.5);
}

/* Notification Badge */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: pulse 2s infinite;
}

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

/* Chat Window */
.floating-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
    border: 2px solid #39ff14;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: none; /* closed by default */
    pointer-events: none; /* do not intercept clicks when closed */
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.floating-chat-window.open {
    display: flex;
    pointer-events: auto; /* interactive only when open */
    animation: slideUp 0.3s ease-out;
}

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

/* Chat Header */
.floating-chat-header {
    background: linear-gradient(135deg, #39ff14, #00ffff);
    color: #000;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.floating-chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

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

.floating-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff00;
    animation: pulse 2s infinite;
}

.floating-chat-close {
    background: none;
    border: none;
    color: #000;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.floating-chat-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Chat Messages Area */
.floating-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.floating-chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.floating-chat-messages::-webkit-scrollbar-thumb {
    background: #39ff14;
    border-radius: 3px;
}

/* Message Styles */
.floating-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

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

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

.floating-message.bot .floating-message-avatar {
    background: linear-gradient(135deg, #39ff14, #00ffff);
    color: #000;
}

.floating-message.user .floating-message-avatar {
    background: linear-gradient(135deg, #666, #888);
    color: #fff;
}

.floating-message-content {
    flex: 1;
}

.floating-message-text {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.floating-message.bot .floating-message-text {
    background: rgba(57, 255, 20, 0.1);
    border: 1px solid rgba(57, 255, 20, 0.3);
}

.floating-message.user .floating-message-text {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.floating-message-time {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    text-align: right;
}

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

/* Error Message */
.floating-message.error .floating-message-text {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    color: #ff6666;
}

/* Typing Indicator */
.floating-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(57, 255, 20, 0.1);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 16px;
    color: #39ff14;
    font-size: 14px;
    max-width: 85%;
}

.floating-typing-dots {
    display: flex;
    gap: 4px;
}

.floating-typing-dot {
    width: 6px;
    height: 6px;
    background: #39ff14;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.floating-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.floating-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input Area */
.floating-chat-input-area {
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(57, 255, 20, 0.3);
}

.floating-chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.floating-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 20px;
    padding: 12px 16px;
    color: #e0e0e0;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.floating-chat-input:focus {
    outline: none;
    border-color: #39ff14;
    box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.2);
}

.floating-chat-input::placeholder {
    color: #888;
}

.floating-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #39ff14, #00ffff);
    border: none;
    color: #000;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.floating-chat-send-btn:hover {
    transform: scale(1.1);
}

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

.floating-chat-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: #888;
}

.floating-char-count {
    color: #666;
}

.floating-char-count.warning {
    color: #ff9900;
}

.floating-char-count.error {
    color: #ff4444;
}

.floating-service-badge {
    background: rgba(57, 255, 20, 0.2);
    color: #39ff14;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .floating-chat-widget {
        bottom: 10px;
        right: 10px; /* stay bottom-right on mobile */
    }
    
    .floating-chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        position: fixed; /* Full screen overlay */
        border-radius: 0; /* Remove border radius for full screen */
        border: none; /* Remove border for full screen */
    }
    
    .chat-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Hide the toggle button when chat is open on mobile for full screen experience */
    .chat-toggle-btn.chat-open {
        display: none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .floating-chat-widget * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .floating-chat-window {
        border-width: 3px;
    }
    
    .floating-message-text {
        border-width: 2px;
    }
}
