/* ================================================
   Pishjoy Chat System Styles
   ================================================ */

/* Chat Container - Two Panel Layout */
#chat-container {
    display: flex;
    height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

/* Left Sidebar - Conversation List */
.chat-sidebar {
    width: 320px;
    min-width: 320px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.chat-sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
}

.chat-sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.chat-search-box {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.chat-search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    background: #fff;
    height: auto !important;
    margin-bottom: 0 !important;
}

.chat-search-box input:focus {
    border-color: #4a90d9;
}

#conversation-list {
    flex: 1;
    overflow-y: auto;
}

/* Conversation Item */
.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.conversation-item:hover {
    background: #f0f0f0;
}

.conversation-item.active {
    background: #e8f0fe;
}

.conversation-item.has-unread .conv-name {
    font-weight: 700;
}

.conversation-item.has-unread .conv-preview {
    font-weight: 600;
    color: #333;
}

.conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
    background: #eee;
}

.conv-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.conv-name {
    font-size: 14px;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.conv-time {
    font-size: 11px;
    color: #999;
    float: right;
}

.conv-preview {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    display: block;
}

.conv-badge {
    background: #4a90d9;
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Right Panel - Message Thread */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

#thread-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

#thread-recipient-name {
    flex: 1;
}

#chat-back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    padding: 4px 8px;
    color: #4a90d9;
}

#message-thread {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
    background: #f9f9f9;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    margin-bottom: 10px;
    align-items: flex-end;
}

.chat-message.msg-mine {
    justify-content: flex-end;
}

.chat-message.msg-theirs {
    justify-content: flex-start;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    object-fit: cover;
    background: #eee;
}

.msg-bubble {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.msg-mine .msg-bubble {
    background: #4a90d9;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-theirs .msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.msg-text {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.msg-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
}

.msg-mine .msg-time {
    text-align: right;
    color: rgba(255,255,255,0.8);
}

.msg-theirs .msg-time {
    color: #999;
}

/* Typing Indicator */
#typing-indicator {
    padding: 5px 20px;
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 15px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
    position: relative;
}

.chat-input-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

.chat-input-area textarea {
    width: 100%;
    padding: 10px 38px 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    outline: none;
    height: auto;
    max-height: 80px;
    line-height: 1.4;
    font-family: inherit;
    box-sizing: border-box;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-input-area textarea::-webkit-scrollbar {
    display: none;
}

/* Character Counter */
.char-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    padding: 2px 14px 0;
    line-height: 1;
}

.char-counter.warning {
    color: #e67e22;
    font-weight: 600;
}

.char-counter.over-limit {
    color: #e74c3c;
    font-weight: 700;
}

.chat-input-area textarea:focus {
    border-color: #4a90d9;
}

/* Emoji Picker */
.emoji-toggle-btn {
    position: absolute;
    right: 12px;
    top: 11px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    color: #aaa;
    line-height: 1;
    transition: color 0.15s;
    z-index: 2;
}

.emoji-toggle-btn:hover {
    color: #666;
}

#emoji-picker-container {
    display: none;
    position: absolute;
    bottom: 4%;
    right: 1%;
    z-index: 100;
}

#emoji-picker-container.active {
    display: block;
}

#send-btn {
    margin-bottom: 15px;
}

.chat-input-area #send-btn {
    margin-left: 5px;
    padding: 0px 23px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    min-width: 60px;
    background: #4a90d9;
    color: #fff;
    border: none;
    transition: background 0.15s;
    height: 38px;
}

.chat-input-area #send-btn:hover {
    background: #3a7bc8;
}

.chat-input-area #send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-input-area #message-input{
    margin-bottom: 0px !important;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 15px;
}

/* Loading */
.chat-loading {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* No conversations state */
.chat-no-conversations {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* Date separator */
.chat-date-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
}

.chat-date-separator span {
    background: #f9f9f9;
    padding: 0 10px;
    font-size: 11px;
    color: #999;
    position: relative;
    z-index: 1;
}

.chat-date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e0e0e0;
}

/* Header badge for messages */
#chat-header-badge,
.chat-unread-badge {
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    padding: 0px 4px;
    font-size: 10px;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
    line-height: 14px;
    display: inline-block;
    font-style: normal;
    position: absolute;
    top: 2px;
    right: -2px;
}

/* Messages header icon hover */
.mn-messages:hover svg {
    stroke: #fff;
}


/* Delete conversation button */
.conv-delete-btn {
    display: none;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
    flex-shrink: 0;
}

.conversation-item:hover .conv-delete-btn {
    display: block;
}

.conv-delete-btn:hover {
    color: #e74c3c;
}

/* Delete Confirmation Modal */
.chat-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.chat-modal-overlay.active {
    display: flex;
}

.chat-modal {
    background: #fff;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.chat-modal-body {
    padding: 24px 24px 16px;
}

.chat-modal-body p {
    margin: 0 0 8px;
    font-size: 15px;
    color: #333;
    font-weight: 600;
}

.chat-modal-body .chat-modal-warning {
    font-size: 13px;
    color: #888;
    font-weight: 400;
}

.chat-modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 24px 20px;
    gap: 10px;
}

.chat-modal-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.chat-modal-btn-cancel {
    background: #f0f0f0;
    color: #333;
}

.chat-modal-btn-cancel:hover {
    background: #e0e0e0;
}

.chat-modal-btn-delete {
    background: #e74c3c;
    color: #fff;
}

.chat-modal-btn-delete:hover {
    background: #c0392b;
}

/* Profile Links in Chat */
.conv-avatar-link {
    flex-shrink: 0;
    display: block;
    margin-right: 12px;
}

.conv-avatar-link .conv-avatar {
    margin-right: 0;
}

.thread-profile-link {
    color: #333;
    text-decoration: none;
}

.thread-profile-link:hover {
    color: #4a90d9;
    text-decoration: underline;
}

.msg-avatar-link {
    flex-shrink: 0;
    display: block;
    margin-right: 8px;
}

.msg-avatar-link .msg-avatar {
    margin-right: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #chat-container {
        flex-direction: column;
        height: calc(100vh - 80px);
        border: none;
        border-radius: 0;
    }

    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        height: 100%;
    }

    .chat-main {
        display: none;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        background: #fff;
        flex-direction: column;
        overflow: hidden;
    }

    .chat-main.active-mobile {
        display: flex;
    }

    #message-thread {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .chat-input-area {
        flex-shrink: 0;
    }

    .emoji-toggle-btn {
        display: none;
    }

    #send-btn {
        margin-bottom: 11px;
    }

    #chat-back-btn {
        display: inline-block;
    }

    .msg-bubble {
        max-width: 80%;
    }

    #chat-container {
        position: relative;
    }
}

@media (max-width: 480px) {
    .chat-sidebar-header {
        padding: 10px 15px;
    }

    .chat-sidebar-header h2 {
        font-size: 16px;
    }

    #thread-header {
        padding: 10px 15px;
        font-size: 14px;
    }

    #message-thread {
        padding: 10px 12px;
    }

    .chat-input-area {
        padding: 8px 10px;
    }

    .chat-input-area textarea {
        font-size: 13px;
        padding: 8px 12px;
    }

    .chat-input-area #send-btn {
        padding: 5px 15px;
        font-size: 13px;
        margin-bottom: 11px;
    }
}

/* Profile Sidebar - User Control Flex Layout */
.usersection .user-control .relation {
    min-width: 0;
    flex: 1;
}

.usersection .user-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

/* Profile Sidebar - Message Button */
.usersection .user-control .chat-message-btn {
    display: block;
    border: 1px solid #426f9c;
    color: #fff !important;
    text-shadow: 0 -1px 0 #406b97;
    box-shadow: 0 1px 0 #ededed;
    background: #528bc3;
    padding: 0 10px;
    width: 100%;
    height: 28px;
    line-height: 28px;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    cursor: pointer;
}

.usersection .user-control .chat-message-btn:hover {
    background: #4a7fb5;
    text-decoration: none;
}

