Fuente de plantilla: form_whatsapp.html

<!-- Contenedor del formulario --> <div id="wa-form-container" class="hidden"> <div class="wa-header"> <span>CONTACTO POR WHATSAPP</span> </div> <form id="wa-form" method="POST" action="{% url 'send_field_contact_crminbox' %}"> {% csrf_token %} <!-- Mensaje informativo --> <div style="background: #e8f5e9; border-left: 4px solid #25D366; padding: 12px 16px; margin-bottom: 16px; border-radius: 4px; font-size: 13px; color: #2e7d32;"> <strong>ℹ️ Importante:</strong> Por favor, utiliza el mismo número de teléfono con el que te vas a contactar por WhatsApp. Este número será utilizado para iniciar la conversación. </div> <!-- Campo de país --> <div style="position: relative; margin-bottom: 0;"> <input type="text" id="country-display" class="formsCRMInbox" placeholder="Busca y selecciona tu país" required autocomplete="off"> <input type="hidden" name="country" id="country" value="{{ request.user.perfilusuario.empresa.pais|default:'' }}"> <div id="country-dropdown" class=""></div> </div> <!-- Campo de teléfono --> <div style="display: flex; margin-bottom: 0;"> <input type="tel" name="phone_number" id="phone_number" class="formsCRMInbox" placeholder="Escribe tu teléfono" required value="{{ request.user.perfilusuario.telefono|default:'' }}"> </div> <!-- Campo de nombre --> <div style="display: flex; margin-bottom: 0;"> <input type="text" name="first_name" id="first_name" class="formsCRMInbox" placeholder="Escribe tu nombre" required value="{{ request.user.first_name|default:request.user.username }}"> </div> <!-- Campo de email --> <div style="display: flex; margin-bottom: 0;"> <input type="email" name="email" id="email" class="formsCRMInbox" placeholder="Escribe tu email" required value="{{ request.user.email|default:'' }}"> </div> <!-- Campo de mensaje --> <div style="display: flex; margin-bottom: 0;"> <textarea id="wa-message" name="wa-message" class="formsCRMInbox" placeholder="Escribe tu mensaje" required cols="40" rows="10"></textarea> </div> <!-- Botón de envío --> <button id="sendMessageCrmInbox" type="submit">ENVIAR</button> </form> </div> <style> /* Formulario de WhatsApp */ #wa-form-container { position: fixed; bottom: 100px; right: 20px; width: 360px; max-width: calc(100vw - 40px); background: #ffffff; border-radius: 16px; padding: 0; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1); font-family: 'Lato', sans-serif; z-index: 9998; overflow: hidden; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); animation: slideUp 0.4s ease-out; } @keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } #wa-form-container:hover { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15); } .wa-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; padding: 1.25rem 1.5rem; color: #ffffff; background: linear-gradient(135deg, #128C7E 0%, #075E54 100%); font-family: 'Lato', sans-serif; font-size: 16px; letter-spacing: 0.5px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .wa-header span { display: flex; align-items: center; gap: 8px; } .wa-header span::before { content: ""; display: inline-block; width: 30px; height: 30px; background-image: url('/static/img/crminbox_icon.svg'); background-size: contain; background-repeat: no-repeat; background-position: center; } .wa-header button { background: transparent; border: none; font-size: 24px; cursor: pointer; color: #ffffff; transition: transform 0.2s ease; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; } .wa-header button:hover { background: rgba(255, 255, 255, 0.1); transform: rotate(90deg); } #wa-form { padding: 1.5rem; } .formsCRMInbox { display: block; width: 100%; padding: 12px 16px; margin-bottom: 14px; border-radius: 8px; border: 2px solid #e8e8e8; font-family: 'Lato', sans-serif; font-size: 14px; transition: all 0.3s ease; background: #fafafa; outline: none; box-sizing: border-box; } .formsCRMInbox:focus { border-color: #25D366; background: #ffffff; box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1); transform: translateY(-1px); } .formsCRMInbox::placeholder { color: #999; font-weight: 300; } /* Validación visual para todos los campos */ .formsCRMInbox.field-valid { border-color: #27ae60 !important; background: #f0fdf4 !important; } .formsCRMInbox.field-invalid { border-color: #e74c3c !important; background: #fff5f5 !important; } /* Iconos de validación (checkmark y x) */ .formsCRMInbox.field-valid { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2327ae60' viewBox='0 0 16 16'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; } .formsCRMInbox.field-invalid { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23e74c3c' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; } /* Estilos especiales para el campo de país */ #country-display { cursor: pointer; position: relative; } #country-display:focus { cursor: text; } /* Dropdown customizado de países */ #country-dropdown { position: absolute; top: 100%; left: 0; right: 0; max-height: 200px; overflow-y: auto; background: white; border: 2px solid #25D366; border-top: none; border-radius: 0 0 8px 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); z-index: 1000; display: none; margin-top: -2px; } #country-dropdown.show { display: block; } .country-option { padding: 10px 16px; cursor: pointer; transition: background 0.2s ease; font-family: 'Lato', sans-serif; font-size: 14px; border-bottom: 1px solid #f0f0f0; } .country-option:last-child { border-bottom: none; } .country-option:hover { background: #f0fdf4; } .country-option.selected { background: #e8f5e9; font-weight: 600; } .country-option.no-results { color: #999; text-align: center; cursor: default; } .country-option.no-results:hover { background: white; } /* Scrollbar personalizado para dropdown */ #country-dropdown::-webkit-scrollbar { width: 8px; } #country-dropdown::-webkit-scrollbar-track { background: #f1f1f1; } #country-dropdown::-webkit-scrollbar-thumb { background: #25D366; border-radius: 4px; } #country-dropdown::-webkit-scrollbar-thumb:hover { background: #128C7E; } textarea.formsCRMInbox { resize: vertical; min-height: 100px; max-height: 200px; font-family: 'Lato', sans-serif; } #sendMessageCrmInbox { background: linear-gradient(135deg, #25D366 0%, #128C7E 100%); color: white; padding: 14px 20px; width: 100%; border: none; border-radius: 8px; margin-top: 0.5rem; cursor: pointer; font-family: 'Lato', sans-serif; font-size: 15px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3); position: relative; overflow: hidden; } #sendMessageCrmInbox::before { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.3); transform: translate(-50%, -50%); transition: width 0.6s, height 0.6s; } #sendMessageCrmInbox:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); } #sendMessageCrmInbox:hover::before { width: 300px; height: 300px; } #sendMessageCrmInbox:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3); } .wa-privacidad { margin-top: 12px; font-size: 12px; color: #666; text-align: center; } .wa-privacidad a { color: #128C7E; text-decoration: underline; margin-left: 4px; transition: color 0.2s ease; } .wa-privacidad a:hover { color: #25D366; } .hidden { display: none !important; } /* Responsive Design */ @media (max-width: 768px) { #wa-form-container { width: calc(100vw - 32px); right: 16px; bottom: 90px; max-height: calc(100vh - 120px); overflow-y: auto; } #country-dropdown { max-height: 150px; } .country-option { padding: 8px 12px; font-size: 13px; } .wa-header { padding: 1rem 1.25rem; font-size: 14px; } .wa-header span::before { font-size: 18px; } #wa-form { padding: 1.25rem; } .formsCRMInbox { padding: 10px 14px; font-size: 14px; margin-bottom: 12px; } #sendMessageCrmInbox { padding: 12px 18px; font-size: 14px; } } @media (max-width: 480px) { #wa-form-container { width: calc(100vw - 20px); right: 10px; bottom: 80px; border-radius: 12px; } .wa-header { padding: 0.875rem 1rem; font-size: 13px; } #wa-form { padding: 1rem; } .formsCRMInbox { padding: 10px 12px; font-size: 13px; margin-bottom: 10px; } textarea.formsCRMInbox { min-height: 80px; } #sendMessageCrmInbox { padding: 12px 16px; font-size: 13px; } } /* Landscape mode for mobile */ @media (max-height: 600px) and (orientation: landscape) { #wa-form-container { bottom: 10px; max-height: calc(100vh - 30px); overflow-y: auto; } textarea.formsCRMInbox { min-height: 60px; max-height: 100px; } } /* Smooth scrollbar for form container */ #wa-form-container::-webkit-scrollbar { width: 6px; } #wa-form-container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } #wa-form-container::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 10px; } #wa-form-container::-webkit-scrollbar-thumb:hover { background: #a8a8a8; } /* Loading state for button */ #sendMessageCrmInbox.loading { pointer-events: none; opacity: 0.7; } #sendMessageCrmInbox.loading::after { content: ''; position: absolute; width: 16px; height: 16px; top: 50%; left: 50%; margin-left: -8px; margin-top: -8px; border: 2px solid #ffffff; border-radius: 50%; border-top-color: transparent; animation: spin 0.8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } </style>