/* fluXtore AI Chat Widget Styles */

.fluxtore-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Button */
.fluxtore-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.fluxtore-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.fluxtore-chat-button:active {
    transform: scale(1.05);
}

/* Chat Window */
.fluxtore-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

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

.fluxtore-chat-header-content h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
}

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

.fluxtore-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

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

.fluxtore-chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

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

.fluxtore-chat-close:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
.fluxtore-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f9fafb;
    -webkit-overflow-scrolling: touch;
}

.fluxtore-chat-message {
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.fluxtore-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
}

.fluxtore-chat-message.user .fluxtore-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.fluxtore-chat-message.ai .fluxtore-message-content,
.fluxtore-chat-message.human .fluxtore-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.fluxtore-chat-message.system .fluxtore-message-content {
    background: #fef3c7;
    color: #92400e;
    margin: 0 auto;
    text-align: center;
    font-size: 13px;
}

.fluxtore-message-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}

/* Typing Indicator */
.fluxtore-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px;
}

.fluxtore-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.fluxtore-chat-input-wrapper {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.fluxtore-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    line-height: 1.5;
}

.fluxtore-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.fluxtore-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.fluxtore-chat-send:hover {
    transform: scale(1.05);
}

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

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

/* Links in messages */
.fluxtore-message-content a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.fluxtore-chat-message.user .fluxtore-message-content a {
    color: white;
}

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

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

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

.fluxtore-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Tablet Responsive (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .fluxtore-chat-window {
        width: 360px;
        height: 550px;
    }
    
    .fluxtore-chat-button {
        width: 56px;
        height: 56px;
    }
}

/* Mobile Responsive (max 480px) */
@media (max-width: 480px) {
    .fluxtore-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .fluxtore-chat-button {
        width: 56px;
        height: 56px;
    }
    
    .fluxtore-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
        max-height: calc(100vh - 100px);
        border-radius: 12px;
    }
    
    .fluxtore-chat-header {
        padding: 16px;
    }
    
    .fluxtore-chat-header-content h3 {
        font-size: 16px;
    }
    
    .fluxtore-chat-messages {
        padding: 16px;
    }
    
    .fluxtore-message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .fluxtore-chat-input-wrapper {
        padding: 12px;
    }
    
    .fluxtore-chat-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* Small Mobile (max 360px) */
@media (max-width: 360px) {
    .fluxtore-chat-button {
        width: 52px;
        height: 52px;
    }
    
    .fluxtore-chat-header {
        padding: 14px;
    }
    
    .fluxtore-chat-messages {
        padding: 14px;
    }
    
    .fluxtore-message-content {
        max-width: 90%;
        padding: 10px 14px;
    }
}

/* Landscape Mode for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .fluxtore-chat-window {
        height: calc(100vh - 80px);
        bottom: 70px;
    }
    
    .fluxtore-chat-header {
        padding: 12px 16px;
    }
    
    .fluxtore-chat-messages {
        padding: 12px;
    }
    
    .fluxtore-chat-input-wrapper {
        padding: 10px;
    }
}

/* iPad and Tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    .fluxtore-chat-window {
        width: 400px;
        height: 650px;
    }
}

/* Prevent text selection on button */
.fluxtore-chat-button,
.fluxtore-chat-close,
.fluxtore-chat-send {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Touch improvements */
.fluxtore-chat-button,
.fluxtore-chat-close,
.fluxtore-chat-send,
.fluxtore-chat-input {
    touch-action: manipulation;
}

/* Safe area for iOS devices with notch */
@supports (padding: max(0px)) {
    .fluxtore-chat-widget {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }
    
    @media (max-width: 480px) {
        .fluxtore-chat-widget {
            bottom: max(10px, env(safe-area-inset-bottom));
            right: max(10px, env(safe-area-inset-right));
        }
    }
}
