* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f0f2f5; }

.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; gap: 60px;
    flex-wrap: wrap;
}
.login-left { max-width: 440px; }
.logo-text { color: #1877f2; font-size: 56px; font-weight: 700; letter-spacing: -1px; }
.logo-desc { font-size: 24px; color: #1c1e21; margin-top: 10px; line-height: 1.3; }
.login-box {
    background: #fff; border-radius: 8px; padding: 20px; width: 396px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.1);
}
.login-box input, .register-box input {
    width: 100%; padding: 14px 16px; font-size: 17px; border: 1px solid #dddfe2;
    border-radius: 6px; margin-bottom: 12px; outline: none;
}
.login-box input:focus, .register-box input:focus { border-color: #1877f2; box-shadow: 0 0 0 2px #e7f3ff; }
.login-box button, .register-box button {
    width: 100%; padding: 12px; font-size: 18px; font-weight: 600; color: #fff;
    background: #1877f2; border: none; border-radius: 6px; cursor: pointer;
}
.login-box button:hover, .register-box button:hover { background: #166fe5; }
.login-box button:disabled, .register-box button:disabled { background: #9cbaf0; cursor: not-allowed; }
.login-divider { display: flex; align-items: center; margin: 16px 0; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: #dadde1; }
.login-divider span { padding: 0 16px; color: #606770; font-size: 13px; }
.register-btn {
    display: block; text-align: center; padding: 12px 16px; font-size: 17px; font-weight: 600;
    color: #fff; background: #42b72a; border-radius: 6px; text-decoration: none;
}
.register-btn:hover { background: #36a420; }

.register-wrap {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.register-box {
    background: #fff; border-radius: 8px; padding: 24px; width: 432px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.1); text-align: center;
}
.register-box h1 { color: #1877f2; font-size: 36px; margin-bottom: 4px; }
.register-box p { color: #606770; font-size: 15px; margin-bottom: 16px; }
.login-link { margin-top: 16px; font-size: 14px; }
.login-link a { color: #1877f2; text-decoration: none; }
.login-link a:hover { text-decoration: underline; }
.error-msg { color: #c00; font-size: 14px; margin-bottom: 12px; display: none; }
.error-msg:not(:empty) { display: block; }
.success-msg { color: #42b72a; font-size: 14px; margin-bottom: 12px; display: none; }
.success-msg:not(:empty) { display: block; }

.chat-app { display: flex; height: 100vh; max-height: 100vh; overflow: hidden; }
.chat-sidebar {
    width: 350px; min-width: 350px; background: #fff; border-right: 1px solid #e4e6eb;
    display: flex; flex-direction: column;
}
.chat-sidebar-header {
    padding: 14px 16px; border-bottom: 1px solid #e4e6eb; background: #fff;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.csh-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.csh-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: #1877f2;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 16px; flex-shrink: 0; overflow: hidden;
}
.csh-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.csh-info { min-width: 0; }
.csh-name { font-size: 14px; font-weight: 600; color: #1c1e21; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.csh-id { font-size: 11px; color: #606770; }
.csh-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.csh-actions a {
    color: #606770; text-decoration: none; font-size: 13px; font-weight: 500;
}
.csh-actions a:hover { text-decoration: underline; }
.cashback-bar {
    padding: 10px 16px; background: linear-gradient(135deg, #1877f2, #42b72a);
    display: flex; align-items: center; gap: 8px; font-size: 14px;
}
.cashback-label { color: rgba(255,255,255,0.8); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.cashback-amount { color: #fff; font-weight: 700; font-size: 18px; flex: 1; text-align: right; }
.cashback-currency { color: rgba(255,255,255,0.8); font-size: 12px; }
.chat-search { padding: 12px 16px; border-bottom: 1px solid #e4e6eb; }
.chat-search input {
    width: 100%; padding: 10px 14px; border: 1px solid #dddfe2; border-radius: 20px;
    font-size: 14px; outline: none; background: #f0f2f5;
}
.chat-search input:focus { border-color: #1877f2; background: #fff; }
.search-results {
    max-height: 200px; overflow-y: auto; border-bottom: 1px solid #e4e6eb;
}
.search-result-item {
    padding: 10px 16px; cursor: pointer; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #f0f2f5;
}
.search-result-item:hover { background: #f0f2f5; }
.search-result-item .sri-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: #1877f2;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0; overflow: hidden;
}
.search-result-item .sri-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-result-item .sri-avatar span { display: block; }
.search-result-item .sri-info { flex: 1; }
.search-result-item .sri-name { font-size: 14px; font-weight: 600; color: #1c1e21; }
.search-result-item .sri-id { font-size: 12px; color: #606770; }

.chat-list { flex: 1; overflow-y: auto; }
.chat-list-item {
    padding: 12px 16px; cursor: pointer; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid #f0f2f5; position: relative;
}
.chat-list-item:hover { background: #f0f2f5; }
.chat-list-item.active { background: #e7f3ff; }
.chat-list-item .cli-avatar {
    width: 48px; height: 48px; border-radius: 50%; background: #1877f2;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 18px; flex-shrink: 0; overflow: hidden;
}
.chat-list-item .cli-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-list-item .cli-avatar span { display: block; }
.chat-list-item .cli-info { flex: 1; min-width: 0; }
.chat-list-item .cli-name { font-size: 15px; font-weight: 600; color: #1c1e21; }
.chat-list-item .cli-preview { font-size: 13px; color: #606770; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item .cli-meta { text-align: right; flex-shrink: 0; }
.chat-list-item .cli-time { font-size: 11px; color: #606770; }
.chat-list-item .cli-unread {
    background: #1877f2; color: #fff; border-radius: 50%; width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
    margin-top: 4px; margin-left: auto;
}

.chat-main { flex: 1; display: flex; flex-direction: column; background: #fff; }
.chat-main-header {
    padding: 14px 20px; border-bottom: 1px solid #e4e6eb; background: #fff;
    display: flex; align-items: center; gap: 12px;
}
.mobile-back { display: none; }
.mobile-back {
    background: none; border: none; font-size: 24px; cursor: pointer;
    padding: 0 8px 0 0; color: #1877f2;
}
.chat-main-header .cmh-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: #1877f2;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 16px; flex-shrink: 0; overflow: hidden;
}
.chat-main-header .cmh-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-main-header .cmh-info { flex: 1; }
.chat-main-header .cmh-name { font-size: 16px; font-weight: 600; color: #1c1e21; }
.chat-main-header .cmh-id { font-size: 13px; color: #606770; }
.no-chat-selected {
    flex: 1; display: flex; align-items: center; justify-content: center;
    flex-direction: column; color: #606770;
}
.no-chat-selected h3 { font-size: 20px; margin-bottom: 8px; }
.no-chat-selected p { font-size: 14px; }

.messages-area {
    flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column;
    gap: 4px; background: #f0f2f5;
}
.message-bubble {
    max-width: 70%; padding: 8px 14px; border-radius: 18px; font-size: 15px;
    line-height: 1.4; word-wrap: break-word; position: relative;
}
.message-bubble.sent {
    align-self: flex-end; background: #1877f2; color: #fff;
    border-bottom-right-radius: 4px;
}
.message-bubble.received {
    align-self: flex-start; background: #e4e6eb; color: #1c1e21;
    border-bottom-left-radius: 4px;
}
.message-bubble .msg-time {
    font-size: 11px; margin-top: 4px; display: flex; align-items: center;
    justify-content: flex-end; gap: 4px;
}
.message-bubble.sent .msg-time { color: rgba(255,255,255,0.7); }
.message-bubble.received .msg-time { color: #606770; }
.message-bubble .msg-check {
    font-size: 14px;
}
.message-bubble.sent .msg-check { color: rgba(255,255,255,0.7); }
.message-bubble.sent .msg-check.read { color: #fff; }
.message-bubble .msg-text { white-space: pre-wrap; }

.chat-input-area {
    padding: 12px 16px; border-top: 1px solid #e4e6eb; background: #fff;
    display: flex; gap: 8px; align-items: center;
}
.chat-input-area input {
    flex: 1; padding: 12px 16px; border: 1px solid #dddfe2; border-radius: 20px;
    font-size: 15px; outline: none;
}
.chat-input-area input:focus { border-color: #1877f2; }
.chat-input-area button {
    width: 44px; height: 44px; border-radius: 50%; border: none; background: #1877f2;
    color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.chat-input-area button:hover { background: #166fe5; }
.chat-input-area button:disabled { background: #9cbaf0; cursor: not-allowed; }

.settings-btn-wrap { text-align: center; padding-top: 8px; }
.settings-btn {
    background: none; border: 1px solid #dddfe2; border-radius: 50%; width: 36px; height: 36px;
    font-size: 18px; cursor: pointer; color: #606770; display: inline-flex; align-items: center;
    justify-content: center; transition: background 0.2s;
}
.settings-btn:hover { background: #f0f2f5; }

/* ===== Profile Modal ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 999;
}
.profile-modal {
    background: #fff; border-radius: 12px; width: 420px; max-width: 90vw; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 4px 24px rgba(0,0,0,0.2); position: relative;
}
.profile-modal-close {
    position: absolute; top: 12px; right: 16px; z-index: 10;
    background: rgba(0,0,0,0.4); color: #fff; border: none; border-radius: 50%;
    width: 32px; height: 32px; font-size: 22px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.profile-modal-close:hover { background: rgba(0,0,0,0.6); }

.profile-cover {
    height: 160px; background: linear-gradient(135deg, #1877f2, #42b72a);
    border-radius: 12px 12px 0 0; position: relative; width: 100%;
}
.profile-cover-img {
    width: 100%; height: 100%; background-size: cover; background-position: center;
    display: none;
}
.profile-info-wrap {
    position: absolute; bottom: -40px; left: 24px; display: flex; align-items: flex-end; gap: 14px;
}
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%; background: #1877f2;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 32px; flex-shrink: 0; overflow: hidden;
    border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar span { display: block; }
.profile-info-text { padding-bottom: 8px; }
.profile-name { font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.profile-id { font-size: 13px; color: rgba(255,255,255,0.9); text-shadow: 0 1px 3px rgba(0,0,0,0.4); }

.profile-body { padding: 56px 24px 24px; }
.profile-section { margin-bottom: 24px; }
.profile-section-title {
    font-size: 14px; font-weight: 600; color: #606770; margin-bottom: 12px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.profile-upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bg-preview-wrap { margin-top: 12px; }
.bg-preview-wrap img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; border: 1px solid #e4e6eb; }
.file-label {
    display: inline-block; padding: 8px 16px; background: #f0f2f5; border: 1px solid #dddfe2;
    border-radius: 6px; font-size: 14px; cursor: pointer; color: #1c1e21;
}
.file-label:hover { background: #e4e6eb; }
.file-label input { display: none; }
.btn-sm { padding: 8px 16px; font-size: 13px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary { background: #1877f2; color: #fff; }
.btn-primary:hover { background: #166fe5; }
.btn-primary:disabled { background: #9cbaf0; cursor: not-allowed; }
.btn-danger { background: #e41e3f; color: #fff; }
.btn-danger:hover { background: #c91b37; }
.settings-status { font-size: 13px; margin-top: 6px; }

.img-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none; background: none;
    color: #606770; font-size: 20px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; transition: background 0.2s;
}
.img-btn:hover { background: #f0f2f5; }

.message-bubble .msg-image { margin: -8px -14px 4px; }
.message-bubble .msg-image img {
    width: 100%; max-width: 300px; max-height: 300px; object-fit: contain; display: block;
    border-radius: 12px; cursor: pointer; background: #000;
}
.message-bubble.sent .msg-image img { border-bottom-right-radius: 0; }
.message-bubble.received .msg-image img { border-bottom-left-radius: 0; }
.message-bubble .msg-image + .msg-text { margin-top: 4px; }

.cashback-cell { font-weight: 700; color: #1877f2; }

.chat-delete-btn {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: #606770; padding: 6px; border-radius: 50%; line-height: 1;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background 0.2s;
}
.chat-delete-btn:hover { background: #f0f2f5; color: #e41e3f; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
    animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.delete-chat-modal {
    background: #fff; border-radius: 20px; width: 420px; max-width: 90vw;
    padding: 32px 28px 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center; animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.dcm-icon-wrap {
    width: 72px; height: 72px; background: #fef2f2; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; position: relative;
}
.dcm-icon-wrap::before {
    content: ''; position: absolute; inset: -4px; border-radius: 50%;
    background: linear-gradient(135deg, #fca5a5, #ef4444); opacity: 0.15;
}
.dcm-icon { font-size: 32px; }

.delete-chat-modal h3 {
    font-size: 22px; font-weight: 700; color: #1f2937; margin: 0 0 6px;
}
.dcm-desc {
    font-size: 14px; color: #6b7280; line-height: 1.5; margin: 0 0 20px;
}

.dcm-user-info {
    display: flex; align-items: center; gap: 12px;
    background: #f9fafb; border: 1px solid #f3f4f6;
    padding: 12px 16px; border-radius: 14px; margin-bottom: 20px; text-align: left;
}
.dcm-user-avatar {
    width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}
.dcm-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dcm-user-details { flex: 1; }
.dcm-user-name { font-size: 15px; font-weight: 600; color: #1f2937; }
.dcm-user-id { font-size: 13px; color: #9ca3af; margin-top: 2px; }
.dcm-user-id strong { color: #3b82f6; }

.dcm-divider { height: 1px; background: #e5e7eb; margin: 0 0 16px; }

.dcm-checkbox {
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
    user-select: none; margin-bottom: 24px;
}
.dcm-checkbox input { display: none; }
.dcm-checkbox-mark {
    width: 22px; height: 22px; border: 2px solid #d1d5db; border-radius: 6px;
    position: relative; transition: all 0.2s; flex-shrink: 0;
    background: #fff;
}
.dcm-checkbox input:checked + .dcm-checkbox-mark {
    background: #ef4444; border-color: #ef4444;
}
.dcm-checkbox-mark::after {
    content: ''; position: absolute; display: none;
    left: 6px; top: 2px; width: 6px; height: 10px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.dcm-checkbox input:checked + .dcm-checkbox-mark::after { display: block; }
.dcm-checkbox-label { font-size: 14px; color: #374151; font-weight: 500; }

.dcm-actions { display: flex; gap: 12px; }
.dcm-btn {
    flex: 1; padding: 12px 20px; border: none; border-radius: 12px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.dcm-btn:active { transform: scale(0.97); }
.dcm-btn-cancel { background: #f3f4f6; color: #4b5563; }
.dcm-btn-cancel:hover { background: #e5e7eb; }
.dcm-btn-danger { background: #ef4444; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,0.25); }
.dcm-btn-danger:hover { background: #dc2626; box-shadow: 0 6px 16px rgba(239,68,68,0.35); }
.dcm-btn-danger:disabled { background: #fca5a5; box-shadow: none; cursor: not-allowed; }

.login-settings-btn {
    position: fixed; bottom: 20px; right: 20px; z-index: 100;
    background: #fff; border: 1px solid #dddfe2; border-radius: 50%; width: 44px; height: 44px;
    font-size: 22px; cursor: pointer; color: #606770; display: flex; align-items: center;
    justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.login-settings-btn:hover { background: #f0f2f5; }

@media (max-width: 768px) {
    .login-wrap { gap: 20px; padding: 20px; }
    .login-left { text-align: center; }
    .logo-text { font-size: 36px; }
    .logo-desc { font-size: 18px; }
    .login-box, .register-box { width: 100%; max-width: 396px; }
    .chat-sidebar { width: 100%; min-width: 350px; }
    .chat-main { display: none; min-width: 350px; }
    .chat-main.show { display: flex; width: 100%; }
    .chat-sidebar.hide { display: none; }
    .mobile-back { display: block !important; }
}

