/* Chat-specific styles */
.chat-list-sidebar {
    height: calc(100vh - 200px);
    overflow-y: auto;
}

.chat-container {
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8fafc;
    transition: all 0.3s ease;
}

.chat-input-container {
    border-top: 1px solid #e5e7eb;
    padding: 20px;
    background-color: white;
}

.chat-message {
    margin-bottom: 16px;
    max-width: 70%;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-message.user {
    margin-left: auto;
}

.chat-message.manager {
    margin-right: auto;
}

.chat-message.user .chat-message-content {
    background-color: #3b82f6;
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
}

.chat-message.manager .chat-message-content {
    background-color: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-message.user .chat-message-time {
    text-align: right;
    justify-content: flex-end;
}

.chat-message.manager .chat-message-time {
    text-align: left;
    justify-content: flex-start;
}

/* Chat list item */
.chat-list-item {
    transition: all 0.2s ease;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    border-left: 4px solid transparent;
}

.chat-list-item:hover {
    background-color: #f9fafb;
    transform: translateX(2px);
}

.chat-list-item.active {
    background-color: #eff6ff;
    border-left-color: #3b82f6;
}

.chat-user-name {
    font-weight: 500;
    color: #111827;
    font-size: 14px;
    transition: color 0.2s ease;
}

.chat-user-username {
    font-size: 12px;
    color: #6b7280;
    transition: color 0.2s ease;
}

.chat-last-message {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.chat-time {
    font-size: 11px;
    color: #9ca3af;
    transition: color 0.2s ease;
}

.chat-unread-count {
    background-color: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 500;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease-out;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    margin-right: 4px;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingAnimation {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Emoji picker */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    width: 240px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 100;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.emoji-picker.active {
    display: grid;
}

.emoji-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji-btn:hover {
    background-color: #f3f4f6;
    transform: scale(1.1);
}

/* Message textarea */
#message-input {
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    font-family: inherit;
    padding-top: 11px;
    padding-bottom: 11px;
    transition: all 0.2s ease;
}

#message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Online status */
.status-dot.online {
    background-color: #10b981;
    animation: pulse 1.5s infinite;
}

.status-dot.offline {
    background-color: #9ca3af;
}

/* Message sending animation */
.message-sending {
    opacity: 0.7;
}

.message-sent .chat-message-content::after {
    content: '✓';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    color: #10b981;
    opacity: 0;
    animation: checkmark 0.3s ease-out forwards;
    animation-delay: 0.5s;
}

@keyframes checkmark {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading animation for messages */
.chat-message.loading .chat-message-content {
    position: relative;
    overflow: hidden;
}

.chat-message.loading .chat-message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.chat-list-sidebar::-webkit-scrollbar {
    width: 4px;
}

.chat-list-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-list-sidebar::-webkit-scrollbar-thumb {
    background: #d1d1d1;
    border-radius: 2px;
}

.chat-list-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Responsive design */
@media (max-width: 1024px) {
    .chat-container {
        height: calc(100vh - 150px);
    }
    
    .chat-list-sidebar {
        height: calc(100vh - 150px);
    }
}

@media (max-width: 768px) {
    .chat-message {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 200px;
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Smooth transitions */
.chat-message-content {
    transition: all 0.3s ease;
}

.chat-message-content:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* New message highlight */
@keyframes highlightMessage {
    0% {
        background-color: rgba(254, 243, 199, 0.5);
    }
    100% {
        background-color: transparent;
    }
}

.chat-message.new {
    animation: highlightMessage 2s ease-out;
}

/* Avatar animation */
.chat-list-item .relative div:first-child {
    transition: all 0.3s ease;
}

.chat-list-item:hover .relative div:first-child {
    transform: scale(1.05);
}

/* Message status icons */
.chat-message-time i {
    transition: all 0.2s ease;
}

.chat-message-time i:hover {
    transform: scale(1.2);
}