/* ============================================
   CodeNeutronAI Chat Widget Styles
   ============================================ */

.chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    isolation: isolate;
}

.chat-widget-container * {
    box-sizing: border-box;
}

/* Hide any inherited spinners/loaders */
.chat-window .preloader,
.chat-window .loader,
.chat-window .spinner {
    display: none !important;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #00d4ff 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.chat-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.5);
}

.chat-toggle-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s ease;
}

.chat-toggle-btn.active svg.chat-icon {
    transform: rotate(90deg) scale(0);
}

.chat-toggle-btn svg.close-icon {
    position: absolute;
    transform: rotate(-90deg) scale(0);
}

.chat-toggle-btn.active svg.close-icon {
    transform: rotate(0) scale(1);
}

/* Pulse animation for attention */
.chat-toggle-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    opacity: 0;
    animation: pulse-ring 2s infinite;
    z-index: -1;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.4); opacity: 0; }
}

.chat-toggle-btn.active::after {
    animation: none;
    opacity: 0;
}

/* Notification badge */
.chat-notification {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    border: 2px solid #0a0a0f;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: linear-gradient(180deg, #12121a 0%, #0a0a0f 100%);
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 
                0 0 60px rgba(99, 102, 241, 0.1);
    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);
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.1) 100%);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #12121a;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h4 {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.chat-header-info p {
    color: #22c55e;
    font-size: 12px;
    margin: 0;
}

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

.chat-minimize-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.chat-minimize-btn svg {
    width: 16px;
    height: 16px;
    fill: #9ca3af;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

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

@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.bot {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message.bot .message-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.chat-message.user .message-avatar {
    background: linear-gradient(135deg, #00d4ff 0%, #6366f1 100%);
}

.message-avatar svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.message-content a {
    color: #00d4ff;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.chat-message.bot .message-content {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #8b5cf6;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Chat loading state */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* Quick Actions */
.chat-quick-actions {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-action-btn {
    padding: 8px 14px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    color: #a5b4fc;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-action-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: #6366f1;
    color: white;
}

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

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 4px 4px 4px 16px;
    transition: all 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 14px;
    padding: 10px 0;
}

.chat-input::placeholder {
    color: #6b7280;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

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

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Powered by */
.chat-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 10px;
    color: #4b5563;
}

.chat-powered-by a {
    color: #6366f1;
    text-decoration: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 16px;
        right: 16px;
    }
    
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 76px;
        right: -8px;
        border-radius: 16px;
    }
    
    .chat-toggle-btn {
        width: 56px;
        height: 56px;
    }
    
    .chat-toggle-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* Welcome message animation */
.welcome-message {
    text-align: center;
    padding: 20px;
}

.welcome-message h3 {
    color: #ffffff;
    font-size: 18px;
    margin: 0 0 8px 0;
}

.welcome-message p {
    color: #9ca3af;
    font-size: 13px;
    margin: 0;
}
