/* ===== CHAT SYSTEM STYLES ===== */
* {
    box-sizing: border-box;
}

/* Chat Container */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    z-index: 10000;
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-container.active {
    transform: translateY(0);
    opacity: 1;
}

.chat-container.minimized {
    height: 60px;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.8s;
}

.chat-header:hover::before {
    left: 100%;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-status {
    font-size: 12px;
    opacity: 0.8;
    margin: 0;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 14px;
}

.chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Chat Messages */
.chat-messages {
    height: 320px;
    overflow-y: auto;
    padding: 15px;
    background: linear-gradient(to bottom, #f8f9fa, #ffffff);
    position: relative;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #667eea, #764ba2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #5a6fd8, #6a4190);
}

/* Message Styles */
.message {
    margin-bottom: 15px;
    animation: messageSlide 0.3s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes messageSlide {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    display: flex;
    justify-content: flex-end;
}

.message.received {
    display: flex;
    justify-content: flex-start;
}

.message.system {
    display: flex;
    justify-content: center;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.message-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 4px;
}

.message.system .message-bubble {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
    border-radius: 12px;
    padding: 8px 12px;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

/* File Messages */
.file-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-top: 5px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.file-size {
    font-size: 12px;
    opacity: 0.7;
}

/* Image Messages */
.image-message {
    margin-top: 8px;
}

.image-message img {
    max-width: 100%;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.image-message img:hover {
    transform: scale(1.02);
}

/* Reactions */
.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.reaction {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.reaction:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.reaction.user-reacted {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    font-size: 13px;
    color: #666;
    font-style: italic;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typingDots 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDots {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Input */
.chat-input-area {
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
}

.chat-input::placeholder {
    color: #999;
    font-style: italic;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 16px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-file-btn {
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 50%;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 16px;
}

.chat-file-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
}

.file-input {
    display: none;
}

/* Chat Toggle Button */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 
        0 8px 25px rgba(102, 126, 234, 0.4),
        0 0 0 0 rgba(102, 126, 234, 0.4);
    transition: all 0.4s ease;
    z-index: 9999;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 
            0 8px 25px rgba(102, 126, 234, 0.4),
            0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 
            0 8px 25px rgba(102, 126, 234, 0.4),
            0 0 0 15px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 
            0 8px 25px rgba(102, 126, 234, 0.4),
            0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
    animation: none;
}

.chat-toggle.hidden {
    transform: scale(0);
    opacity: 0;
}

/* Unread Badge */
.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: bounce 1s ease-in-out infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

/* Quick Responses */
.quick-responses {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.quick-response {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 12px;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-response:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

/* Connection Status */
.connection-status {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1001;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background: rgba(46, 213, 115, 0.9);
    color: white;
}

.connection-status.disconnected {
    background: rgba(255, 71, 87, 0.9);
    color: white;
}

.connection-status.connecting {
    background: rgba(255, 193, 7, 0.9);
    color: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
    }
    
    .chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }
    
    .chat-messages {
        height: calc(100vh - 180px);
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: rgba(30, 30, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-messages {
        background: linear-gradient(to bottom, #1a1a1a, #2d2d2d);
    }
    
    .message.received .message-bubble {
        background: rgba(60, 60, 60, 0.9);
        color: #e0e0e0;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-input {
        background: rgba(60, 60, 60, 0.9);
        color: #e0e0e0;
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .chat-input::placeholder {
        color: #888;
    }
    
    .chat-input-area {
        background: rgba(30, 30, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* Loading Animation */
.loading-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: loadingDots 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDots {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Smooth Transitions */
* {
    transition: all 0.3s ease;
}