/* Chat container and layout */
.chat-container {
    position: fixed;
    bottom: 0;
    right: 340px;
    z-index: 1002;
    display: flex;
    flex-direction: row-reverse;
    gap: 20px;
    pointer-events: none;
    padding: 0 20px;
    max-width: calc(100vw - 360px); /* Account for user list width */
    overflow-x: auto;
}

.chat-container > * {
    pointer-events: auto;
}

.chat-container .chat-log.hover {
    border: 2px dashed blue;
    background-color: #f0f0f0;
}

.chat-container .wx_chat_icons {
    display: grid;
}

.chat-container .chat-img {
    width: 70%;
}

/* Chat box styles */
.chat-box {
    position: relative;
    width: 300px;
    height: 400px;
    background: #fff;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    margin-right: 20px;
    pointer-events: auto;
    flex-shrink: 0; /* Prevent chat boxes from shrinking */
}

.chat-box.active {
    display: flex;
    z-index: 1002;
}

.chat-box.minimized {
    height: 45px; /* Height of the header */
}

.chat-box.minimized .messages-container,
.chat-box.minimized .chat-input-container {
    display: none;
}

.chat-box:first-child {
    margin-right: 0;
}

.chat-box, 
.chat-box * {
    pointer-events: auto;
}

/* Chat message styles */
.chat-message {
    max-width: 70%;
    margin: 1px;
    padding: 3px 0px;
    border-radius: 15px;
    position: relative;
    clear: both;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 90%;
}

.chat-message.sent {
    float: right;
    color: #333;
    margin-left: 20%;
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-message.received {
    float: left;
    color: #333;
    margin-right: 20%;
    margin-right: auto;
}

.chat-message.highlighted {
    animation: highlight-message 2s ease;
}

/* Message content styling */
.message-content {
    word-wrap: break-word;
    padding: 0 4px;
    position: relative;
}

.message-content::before {
    display: none;
}

/* Message metadata */
.message-meta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
    color: #95a5a6;
}


/* Reply functionality */
.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
}

/* Add hover state to show message actions */
.chat-message:hover .message-actions {
    opacity: 1;
}

.sent .message-actions {
    left: -30px;
}

.received .message-actions {
    right: -30px;
}

/* Reply button */
.btn-reply {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #6c757d;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: #f8f9fa;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-reply:hover {
    background: #e9ecef;
    color: #495057;
    transform: scale(1.1);
}

/* Chat input container */
.chat-input-container {
    padding: 10px;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0;
}

/* Reply preview */
.reply-preview {
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #6c757d;
    font-size: 0.9em;
}

.reply-text {
    color: #495057;
    font-size: 0.9em;
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-left: 8px;
    border-left: 2px solid #17a2b8;
}

/* Replied message in chat */
.replied-message {
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #666;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.replied-message:hover {
    background: rgba(0,0,0,0.05);
}

.replied-message .reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #2196f3;
    font-size: 0.85em;
    margin-bottom: 4px;
}

.replied-message .reply-header i {
    font-size: 12px;
}

.replied-message .reply-text {
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 18px;
    border-left: 2px solid #2196f3;
}

/* Sent message with reply styling */
.chat-message.sent .replied-message {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 6px;
}

.chat-message.sent .replied-message .reply-header {
    color: #333;
}

.chat-message.sent .replied-message .reply-text {
    color: #333;
    border-left-color: #2196f3;
    opacity: 0.8;
}
.message-content{
    border-radius: 12px;
    padding: 8px;
}
.chat-message.sent .message-content {
    background: #d3e7fd;
    border-bottom-right-radius: 3px;
}
.chat-message.received .message-content {
    background: #f0f0f0;
    border-bottom-left-radius: 3px;
}

/* Chat header */
.chat-header {
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 45px;
    flex-shrink: 0;
}

.chat-header .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Enable text truncation */
}

.chat-header .user-picture {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-header .user-name {
    font-weight: 500;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}

.chat-header .user-status {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.chat-header .user-status .fa-circle {
    font-size: 8px;
}

.chat-header .chat-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-direction: row;
    flex-wrap: nowrap;
}

.chat-header .btn-audio-call,
.chat-header .btn-video-call,
.chat-header .btn-minimize,
.chat-header .btn-close {
    padding: 4px;
    border: none;
    background: none;
    color: #95a5a6;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.chat-header .btn-close:hover { color: #e74c3c; }
.chat-header .btn-audio-call:hover { color: #28a745; }
.chat-header .btn-video-call:hover { color: #2196f3; }
.chat-header .btn-minimize:hover { color: #2c3e50; }

/* Chat body */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Messages container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100% - 90px); /* Account for header and input */
    min-height: 0; /* Enable proper flexbox scrolling */
}

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

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

.messages-container::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #ced4da;
}

/* Chat footer */
.chat-footer {
    padding: 10px;
    border-top: 1px solid #eee;
    min-height: 60px;
    flex-shrink: 0;
    background: white;
}

.chat-footer .input-group {
    display: flex;
    gap: 5px;
}

/* Input wrapper */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 4px 8px;
    position: relative;
}

.input-wrapper.has-content .btn-send {
    display: flex;
}

.input-wrapper.has-content .btn-voice {
    display: none;
}

/* Chat input */
.chat-input {
    resize: none;
    flex: 1;
    border: none;
    background: none;
    padding: 8px;
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    outline: none;
    margin: 0;
    width: auto !important;
    padding: 10px;
    height: 100% !important;
    max-width: 72%;
}

.message-status {
    display: inline-block;
    margin-left: 4px;
    font-size: 12px;
}

.message-status .fa-check {
    color: #95a5a6;
}

.message-status .fa-check-double {
    color: #95a5a6;
}

.message-status .text-primary {
    color: #3498db !important;
}

/* Button styles */
.btn-icon {
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: #495057;
}

.btn-voice,
.btn-send {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.btn-voice:hover,
.btn-send:hover {
    background: rgba(0,0,0,0.05);
    color: #333;
}

.btn-send {
    color: #0084ff;
    display: none;
}

/* User list container */
#user-list-container {
    position: fixed;
    right: 20px;
    bottom: 0;
    width: 300px;
    max-height: 80vh;
    background: #fff;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
}

#user-list-container.active {
    display: flex;
}

/* User list header */
#user-list-header {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-list-title {
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
    margin: 0;
}

/* User list */
#user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #fff;
}

#user-list::-webkit-scrollbar {
    width: 6px;
}

#user-list::-webkit-scrollbar-track {
    background: transparent;
}

#user-list::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

#user-list::-webkit-scrollbar-thumb:hover {
    background: #ced4da;
}

/* User search */
.chat_users_search-wrapper {
    padding: 10px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.chat_users_search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.chat_users_search:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33,150,243,0.1);
}

/* User item */
.winix-user {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* User avatar */
.user-avatar {
    position: relative;
    margin: 0;
    width: 40px;
    height: 40px;
}

.user-picture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* User status */
.user_status {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

.user_status .fa-circle {
    font-size: 8px;
}

.user_status .fa-circle.text-success {
    color: #28a745 !important;
}

.user_status .fa-circle.text-muted {
    color: #95a5a6 !important;
    opacity: 0.7;
}

/* User info */
.user-info {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}

.user-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #95a5a6;
}

/* Badge */
.badge-container {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.badge {
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 500;
    min-width: 18px;
    text-align: center;
    background: #17a2b8;
    color: white;
    border-radius: 10px;
}

/* Time display */
time {
    font-size: 0.85em;
    color: #6c757d;
}

.chat-last-access-user {
    font-size: 11px;
    color: #95a5a6;
    white-space: nowrap;
    margin-left: auto;
}

/* Close button */
#chat-box-close-btn {
    cursor: pointer;
    padding: 4px 8px;
    color: #95a5a6;
    transition: color 0.2s;
    font-size: 16px;
    border-radius: 4px;
}

#chat-box-close-btn:hover {
    color: #e74c3c;
    background: rgba(0,0,0,0.05);
}

/* Voice recording styles */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 20px;
    color: #dc3545;
    animation: pulse 1.5s infinite;
}

.recording-indicator span {
    font-size: 14px;
    color: #666;
}

.recording-indicator .btn-stop-recording {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.recording-indicator .btn-stop-recording:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* Audio message styling */
.audio-message {
    margin: 4px 0;
    width: 240px;
    max-width: 100%;
}

.audio-message audio {
    width: 100%;
    height: 36px;
    border-radius: 18px;
}

.audio-message audio::-webkit-media-controls-panel {
    background: #f8f9fa;
}

.sent .audio-message audio::-webkit-media-controls-panel {
    background: rgba(255,255,255,0.1);
}

.audio-message audio::-webkit-media-controls-current-time-display,
.audio-message audio::-webkit-media-controls-time-remaining-display {
    color: #666;
}

.sent .audio-message audio::-webkit-media-controls-current-time-display,
.sent .audio-message audio::-webkit-media-controls-time-remaining-display {
    color: rgba(255,255,255,0.9);
}

/* Call container */
#call-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    display: none;
}

/* Floating call controls */
.floating-call-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    padding: 10px;
    z-index: 1999;
    display: none;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 220px;
}

.floating-call-controls.active {
    display: flex;
}

.floating-call-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.floating-call-title {
    color: white;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.floating-call-title .call-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #28a745;
}

.floating-call-title .call-status.audio-only {
    background: #17a2b8;
}

.floating-call-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.floating-call-buttons button {
    padding: 8px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
}

.floating-call-buttons button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.floating-call-buttons button.active {
    background: #2196f3;
}

.floating-call-buttons button.muted {
    background: #dc3545;
}

.floating-call-buttons button.end-call {
    background: #dc3545;
    grid-column: span 2;
}

.floating-call-buttons button.end-call:hover {
    background: #c82333;
}

.floating-call-duration {
    color: white;
    font-size: 12px;
    text-align: center;
    margin-top: 8px;
}

/* Font Awesome icons */
.fa {
    font: normal normal normal 14px/1 FontAwesome;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

.fa-smile:before { content: "\f118"; }
.fa-microphone:before { content: "\f130"; }
.fa-paper-plane:before { content: "\f1d8"; }
.fa-phone:before { content: "\f095"; }
.fa-video:before { content: "\f03d"; }
.fa-minus:before { content: "\f068"; }
.fa-times:before { content: "\f00d"; }

.chat-actions .fa {
    font-size: 14px;
}

.btn-audio-call .fa-phone {
    transform: rotate(90deg);
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes highlight-message {
    0% { background-color: rgba(33, 150, 243, 0.2); }
    100% { background-color: inherit; }
}

/* Emoji picker styles */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px;
    z-index: 1000;
    margin-bottom: 8px;
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    cursor: pointer;
    font-size: 20px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

/* Button styles */
.btn-emoji {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.btn-emoji:hover {
    color: #495057;
    background-color: rgba(0,0,0,0.05);
}

/* Input wrapper adjustments */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 4px 8px;
}

/* Scrollbar styles for emoji picker */
.emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-picker::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.emoji-picker::-webkit-scrollbar-thumb:hover {
    background: #ced4da;
}

/* Call notification */
.call-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 300px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 2001;
    overflow: hidden;
    animation: slide-in 0.3s ease;
}

/* Calling notification (outgoing call) */
.call-notification.calling {
    background: #f8f9fa;
    border-left: 4px solid #17a2b8;
}

.call-notification.calling .call-type {
    color: #17a2b8;
    animation: pulse 1.5s infinite;
}

.call-notification.calling .btn-end-call {
    background: #dc3545;
    color: white;
    width: 100%;
}

.call-notification.calling .btn-end-call:hover {
    background: #c82333;
}

.call-notification-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.caller-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.caller-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.caller-details {
    flex: 1;
}

.caller-name {
    font-weight: 500;
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 4px;
}

.call-type {
    font-size: 13px;
    color: #6c757d;
}

.call-notification-actions {
    display: flex;
    padding: 10px;
    gap: 10px;
}

.call-notification-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-accept-call {
    background: #28a745;
    color: white;
}

.btn-accept-call:hover {
    background: #218838;
}

.btn-reject-call {
    background: #dc3545;
    color: white;
}

.btn-reject-call:hover {
    background: #c82333;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Highlight dropzone when dragging files over it */
.chat-container.drag-over {
    border: 2px dashed #2196f3;
    background-color: rgba(33, 150, 243, 0.1);
}

/* Confirmation message for file upload */
.upload-confirmation {
    background-color: #dff0d8;
    color: #3c763d;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Voice Preview Container and Controls */
.voice-preview-container {
    width: 100%;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 5px;
}

.voice-preview-container audio {
    width: 100%;
    height: 40px;
    margin-bottom: 10px;
}

.voice-preview-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.btn-send-voice, .btn-cancel-voice {
    flex: 1;
    border: none;
    padding: 8px 0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-send-voice {
    background-color: #28a745;
    color: white;
}

.btn-send-voice:hover {
    background-color: #218838;
}

.btn-cancel-voice {
    background-color: #dc3545;
    color: white;
}

.btn-cancel-voice:hover {
    background-color: #c82333;
}

/* Typing indicator styles */
.status-text.typing {
    color: #2196f3;
    font-style: italic;
    font-size: 12px;
    display: inline-block;
    animation: typing-pulse 1.4s infinite;
}

@keyframes typing-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}