diff --git a/assets/css/styles.css b/assets/css/styles.css index 605259a..c666001 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -1155,4 +1155,106 @@ body { color: white; box-shadow: none; border: 1px solid rgba(255, 255, 255, 0.5); -} \ No newline at end of file +} + +/* ===== Ajustes para modo nocturno (dark mode) ===== */ +@media (prefers-color-scheme: dark) { + :root { + --light-bg: #071322; + --text-primary: #e6eef1; + --text-secondary: #9ca3af; + --border-color: #163240; + } + + body { + background-color: var(--light-bg); + color: var(--text-primary); + } + + /* Encabezados y títulos */ + .content-header h1, + .card-header h5, + .sidebar-header h4, + .status-text, + .status-indicator, + .conversation-empty { + color: var(--text-primary) !important; + } + + /* Contenedores */ + .content-header, + .card, + .chat-container { + background: #071322; + color: var(--text-primary); + border-color: var(--border-color); + box-shadow: none; + } + + .card-header { + background: transparent; + border-bottom-color: rgba(255,255,255,0.04); + } + + /* Formularios y botones */ + .form-control { + background: #072033; + color: var(--text-primary); + border-color: #163240; + } + + .btn { + color: inherit; + } + + /* Sidebar */ + .sidebar { + background: linear-gradient(135deg,#08131a,#0b2221); + color: #e6eef1; + } + + .conversation-actions .btn { + background: #0b1220; + border-color: #1f2937; + color: var(--text-secondary); + } + + /* Chat específico */ + .chat-header { + background: linear-gradient(135deg, #1f5a3f 0%, #0f513e 100%); + color: #fff; + } + + .message-bubble { + color: #e6eef1; + } + + .message-incoming { + background: #0b1220; + color: #e6eef1; + box-shadow: none; + } + + .message-outgoing { + background: #0f513e; + color: #fff; + } + + .message-document, + .media-preview { + background: rgba(255,255,255,0.03); + color: var(--text-primary); + } + + .conversation-search { + background: rgba(255,255,255,0.04); + color: var(--text-primary); + } + + a, .nav-link { + color: #a6f3c9; + } + + /* Placeholders visibles */ + ::placeholder { color: #9ca3af !important; opacity: 1; } +} diff --git a/chat_window.php b/chat_window.php index 2bc4385..18b8e15 100644 --- a/chat_window.php +++ b/chat_window.php @@ -561,8 +561,16 @@ if (empty($user_id)) { const displayName = currentUser.name || 'Usuario'; const phoneNumber = currentUser.phone_number || ''; document.getElementById('userName').innerHTML = ` - ${escapeHtml(displayName)} + ${escapeHtml(displayName)} + ${phoneNumber ? `
${escapeHtml(phoneNumber)}` : ''} + `; document.getElementById('userAvatar').innerHTML = `${(currentUser.name || 'U').charAt(0).toUpperCase()}`; @@ -1112,6 +1120,55 @@ if (empty($user_id)) { showAlert('Error al cambiar estado de atención: ' + err.message, 'danger'); } } + + // ===== Edición de nombre de usuario ===== + function editUserName() { + const container = document.getElementById('editNameContainer'); + const input = document.getElementById('editNameInput'); + if (!container || !input) return; + input.value = currentUser.name || ''; + container.style.display = 'block'; + document.getElementById('editNameBtn').style.display = 'none'; + input.focus(); + } + + function cancelEditUserName() { + const container = document.getElementById('editNameContainer'); + if (!container) return; + container.style.display = 'none'; + document.getElementById('editNameBtn').style.display = 'inline-block'; + } + + async function saveUserName() { + const input = document.getElementById('editNameInput'); + const saveBtn = document.getElementById('saveNameBtn'); + if (!input || !saveBtn) return; + + const newName = input.value.trim(); + if (newName.length === 0) { + showAlert('El nombre no puede estar vacío', 'warning'); + return; + } + + saveBtn.disabled = true; + try { + const resp = await whatsappManager.apiCall('update_user.php', { body: { user_id: userId, name: newName } }); + if (resp && resp.success) { + currentUser.name = newName; + document.getElementById('userNameText').innerHTML = escapeHtml(newName); + document.getElementById('userAvatar').innerHTML = `${escapeHtml(newName.charAt(0).toUpperCase() || 'U')}`; + cancelEditUserName(); + showAlert('Nombre actualizado', 'success'); + } else { + throw new Error(resp.error || 'Error actualizando nombre'); + } + } catch (err) { + console.error('Error saving user name:', err); + showAlert('Error al actualizar nombre: ' + err.message, 'danger'); + } finally { + saveBtn.disabled = false; + } + } function showError(message) { showAlert(message, 'danger');