/* css/chat.css */
.chat-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.chat-header {
    padding: 12px 15px;
    background-color: #F76F20; /* Brand Orange */
    color: white;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
}

.chat-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f9f9f9;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Conversation List */
.chat-search-bar {
    padding: 10px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    position: relative;
}

#chat-user-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.chat-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chat-search-item {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.chat-search-item:hover {
    background-color: #f5f5f5;
}

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

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.2s;
}

.conversation-item:hover {
    background-color: #f5f5f5;
}

.conversation-item.unread {
    background-color: #fff8f5;
}

.conversation-item.unread .conversation-name {
    font-weight: bold;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
}

.conversation-info {
    flex: 1;
    min-width: 0; /* For truncation */
}

.conversation-header-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conversation-name {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 11px;
    color: #999;
}

.conversation-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background-color: #F76F20;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* Active Chat */
.chat-conversation-header {
    padding: 10px 15px;
    background-color: #fff;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.back-btn {
    background: none;
    border: none;
    font-size: 18px;
    margin-right: 10px;
    cursor: pointer;
    color: #666;
    padding: 0 5px;
}

#message-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message.sent {
    align-self: flex-end;
    background-color: #e3f2fd; /* Light Blue */
    color: #0d47a1;
    border-bottom-right-radius: 2px;
}

.message.received {
    align-self: flex-start;
    background-color: #fff;
    color: #333;
    border: 1px solid #eee;
    border-bottom-left-radius: 2px;
}

.message a {
    color: inherit;
    text-decoration: underline;
}

.message-time {
    font-size: 10px;
    color: rgba(0,0,0,0.5);
    margin-top: 4px;
    text-align: right;
    display: block;
}

#chat-form {
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

#chat-input:focus {
    border-color: #F76F20;
}

#chat-send-btn {
    background-color: #F76F20;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

#chat-send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.chat-placeholder {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-popup {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}
