/* Nerdify AI Suite - Chatbot Widget Frontend Styles */

/* Chat Widget Container */
.nrfy-chat-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Widget Positioning */
.nrfy-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.nrfy-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

.nrfy-chat-widget.top-right {
    top: 20px;
    right: 20px;
}

.nrfy-chat-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.nrfy-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.nrfy-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.nrfy-chat-toggle:active {
    transform: scale(0.95);
}

.nrfy-chat-toggle svg {
    width: 24px;
    height: 24px;
    fill: white;
    transition: all 0.3s ease;
}

.nrfy-chat-toggle.open svg {
    transform: rotate(180deg);
}

/* Notification Dot */
.nrfy-chat-toggle::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ff4444;
    border-radius: 50%;
    border: 2px solid white;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.nrfy-chat-toggle.has-notification::after {
    transform: scale(1);
    animation: chatPulse 2s infinite;
}

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

/* Chat Window */
.nrfy-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nrfy-chat-widget.bottom-left .nrfy-chat-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.nrfy-chat-widget.top-right .nrfy-chat-window {
    bottom: auto;
    top: 80px;
    transform-origin: top right;
}

.nrfy-chat-widget.top-left .nrfy-chat-window {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 0;
    transform-origin: top left;
}

.nrfy-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Chat Header */
.nrfy-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.nrfy-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nrfy-chat-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Chat Messages Container */
.nrfy-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.nrfy-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.nrfy-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.nrfy-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Individual Message Bubbles */
.nrfy-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    animation: messageSlideIn 0.3s ease;
}

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

.nrfy-message.user {
    background: linear-gradient(135deg, #007cba 0%, #0073aa 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.nrfy-message.assistant {
    background: white;
    color: #333;
    align-self: flex-start;
    border: 1px solid #e1e1e1;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.nrfy-message.system {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    border-radius: 12px;
    font-size: 12px;
    font-style: italic;
    text-align: center;
    max-width: 90%;
}

.nrfy-message.welcome {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    color: #1565c0;
    align-self: center;
    text-align: center;
    font-size: 13px;
    max-width: 90%;
}

.nrfy-message.error {
    background: #ffebee;
    border: 1px solid #f48fb1;
    color: #c62828;
    align-self: center;
    text-align: center;
    font-size: 13px;
    max-width: 90%;
}

/* Streaming Message */
.nrfy-message.streaming {
    position: relative;
}

.nrfy-streaming-cursor {
    display: inline-block;
    color: #667eea;
    animation: cursorBlink 1s ease-in-out infinite;
    margin-left: 2px;
}

@keyframes cursorBlink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* Typing Indicator */
.nrfy-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border: 1px solid #e1e1e1;
    animation: messageSlideIn 0.3s ease;
}

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

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

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

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

/* Chat Input Area */
.nrfy-chat-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e1e1e1;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.nrfy-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 80px;
    min-height: 40px;
}

.nrfy-chat-input:focus {
    border-color: #007cba;
}

.nrfy-chat-input::placeholder {
    color: #999;
}

.nrfy-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007cba 0%, #0073aa 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.nrfy-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.nrfy-chat-send:active {
    transform: scale(0.95);
}

.nrfy-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.nrfy-chat-send svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Function Call Indicators */
.nrfy-function-call-indicator {
    background: #f0f4ff;
    border: 1px solid #b3d9ff;
    color: #0066cc;
    align-self: center;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12px;
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nrfy-function-call-indicator.success {
    background: #f0f8f0;
    border-color: #b3e6b3;
    color: #006600;
}

.nrfy-function-call-indicator.error {
    background: #fff0f0;
    border-color: #ffb3b3;
    color: #cc0000;
}

.nrfy-function-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Chat Widget Customization Classes */
.nrfy-chat-widget.theme-blue .nrfy-chat-toggle {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.nrfy-chat-widget.theme-green .nrfy-chat-toggle {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
}

.nrfy-chat-widget.theme-purple .nrfy-chat-toggle {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
}

.nrfy-chat-widget.theme-orange .nrfy-chat-toggle {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .nrfy-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 20px;
        right: 20px;
        left: 20px;
        transform-origin: center bottom;
    }
    
    .nrfy-chat-widget.bottom-left .nrfy-chat-window,
    .nrfy-chat-widget.top-right .nrfy-chat-window,
    .nrfy-chat-widget.top-left .nrfy-chat-window {
        right: 20px;
        left: 20px;
        transform-origin: center bottom;
    }
    
    .nrfy-chat-widget.top-right .nrfy-chat-window,
    .nrfy-chat-widget.top-left .nrfy-chat-window {
        bottom: 20px;
        top: auto;
    }
    
    .nrfy-message {
        max-width: 90%;
    }
    
    .nrfy-chat-input-container {
        padding: 12px 15px;
    }
    
    .nrfy-chat-messages {
        padding: 15px;
    }
}

/* Accessibility - Chatbot specific */
.nrfy-chat-widget [role="button"] {
    cursor: pointer;
}

.nrfy-chat-widget button:focus,
.nrfy-chat-input:focus {
    outline: 2px solid #005a87;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nrfy-chat-toggle {
        border: 2px solid;
    }
    
    .nrfy-chat-window {
        border: 2px solid;
    }
    
    .nrfy-message.user {
        border: 1px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .nrfy-chat-toggle,
    .nrfy-chat-window,
    .nrfy-message {
        animation: none;
        transition: none;
    }
    
    .nrfy-typing-dot {
        animation: none;
    }
    
    .nrfy-chat-toggle::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .nrfy-chat-widget {
        display: none;
    }
}
