/* Chat System Styles */
.chat-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.chat-sidebar.active {
    right: 0;
}

.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.chat-overlay.active {
    display: block;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

.chat-close:hover {
    color: #333;
}

.chat-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-user-details {
    flex: 1;
}

.chat-user-details h4 {
    margin: 0 0 5px 0;
    font-size: 18px;
}

.chat-user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background: #4CAF50;
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: #ccc;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.no-messages {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-messages i {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ccc;
}

.no-messages p {
    margin: 10px 0;
}

.loading-messages {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.loading-messages i {
    font-size: 24px;
    margin-bottom: 10px;
}

.message-container {
    margin-bottom: 15px;
    display: flex;
}

.message-container.sent {
    justify-content: flex-end;
}

.message-container.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message-bubble.sent {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 5px;
}

.message-bubble.received {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 5px;
}

.message-content {
    margin-bottom: 5px;
    line-height: 1.4;
}

.message-time {
    font-size: 12px;
    opacity: 0.8;
    text-align: right;
}

.message-bubble.received .message-time {
    color: #666;
}

.message-bubble.sent .message-time {
    color: rgba(255,255,255,0.8);
}

.date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.date-separator span {
    background: #f0f0f0;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    color: #666;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #eee;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.chat-input-container {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
}

#chatInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    min-height: 44px;
}

#chatInput:focus {
    outline: none;
    border-color: #007bff;
}

.chat-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.chat-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.send-btn {
    background: #007bff;
    color: white;
}

.send-btn:hover {
    background: #0056b3;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* File Upload Modal */
.file-upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    align-items: center;
    justify-content: center;
}

.file-upload-modal.active {
    display: flex;
}

.file-upload-modal .modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.file-preview-icon {
    width: 60px;
    height: 60px;
    background: #007bff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.file-preview-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    word-break: break-all;
}

.file-preview-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.file-upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Message files */
.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
    margin: 10px 0;
}

.message-bubble.sent .message-file {
    background: rgba(255,255,255,0.2);
}

.file-icon {
    font-size: 24px;
    color: #666;
}

.message-bubble.sent .file-icon {
    color: rgba(255,255,255,0.8);
}

.file-info {
    flex: 1;
}

.file-info h5 {
    margin: 0 0 5px 0;
    font-size: 14px;
    word-break: break-all;
}

.file-info p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.message-bubble.sent .file-info p {
    color: rgba(255,255,255,0.8);
}

.file-download {
    color: #666;
    padding: 5px;
}

.message-bubble.sent .file-download {
    color: rgba(255,255,255,0.8);
}

.file-download:hover {
    color: #007bff;
}

.message-read {
    font-size: 11px;
    margin-top: 5px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 3px;
}

.btn-retry {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

.btn-retry:hover {
    background: #0056b3;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}